Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: templates/chromeInfo.js.tmpl

Issue 30041572: Noissue - Detect Chromium-based Microsoft Edge (Closed)
Patch Set: Created April 9, 2019, 2:01 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 "use strict"; 5 "use strict";
6 6
7 let platformVersion = null; 7 let platformVersion = null;
8 let application = null; 8 let application = null;
9 let applicationVersion; 9 let applicationVersion;
10 10
11 let regexp = /(\S+)\/(\S+)(?:\s*\(.*?\))?/g; 11 let regexp = /(\S+)\/(\S+)(?:\s*\(.*?\))?/g;
12 let match; 12 let match;
13 13
14 while (match = regexp.exec(navigator.userAgent)) 14 while (match = regexp.exec(navigator.userAgent))
15 { 15 {
16 let app = match[1]; 16 let app = match[1];
17 let ver = match[2]; 17 let ver = match[2];
18 18
19 if (app == "Chrome") 19 if (app == "Chrome")
20 { 20 {
21 platformVersion = ver; 21 platformVersion = ver;
22 } 22 }
23 else if (app != "Mozilla" && app != "AppleWebKit" && app != "Safari") 23 else if (app != "Mozilla" && app != "AppleWebKit" && app != "Safari")
24 { 24 {
25 // For compatibility with legacy websites, Chrome's UA 25 // For compatibility with legacy websites, Chrome's UA
26 // also includes a Mozilla, AppleWebKit and Safari token. 26 // also includes a Mozilla, AppleWebKit and Safari token.
27 // Any further name/version pair indicates a fork. 27 // Any further name/version pair indicates a fork.
28 application = app == "OPR" ? "opera" : app.toLowerCase(); 28 application = {OPR: "opera", Edg: "edge"}[app] || app.toLowerCase();
29 applicationVersion = ver; 29 applicationVersion = ver;
30 } 30 }
31 } 31 }
32 32
33 // not a Chromium-based UA, probably modifed by the user 33 // not a Chromium-based UA, probably modifed by the user
34 if (!platformVersion) 34 if (!platformVersion)
35 { 35 {
36 application = "unknown"; 36 application = "unknown";
37 applicationVersion = platformVersion = "0"; 37 applicationVersion = platformVersion = "0";
38 } 38 }
39 39
40 // no additional name/version, so this is upstream Chrome 40 // no additional name/version, so this is upstream Chrome
41 if (!application) 41 if (!application)
42 { 42 {
43 application = "chrome"; 43 application = "chrome";
44 applicationVersion = platformVersion; 44 applicationVersion = platformVersion;
45 } 45 }
46 46
47 47
48 exports.addonName = {{ basename|json }}; 48 exports.addonName = {{ basename|json }};
49 exports.addonVersion = {{ version|json }}; 49 exports.addonVersion = {{ version|json }};
50 50
51 exports.application = application; 51 exports.application = application;
52 exports.applicationVersion = applicationVersion; 52 exports.applicationVersion = applicationVersion;
53 53
54 exports.platform = "chromium"; 54 exports.platform = "chromium";
55 exports.platformVersion = platformVersion; 55 exports.platformVersion = platformVersion;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld