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

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

Issue 29399569: Issue 5060 - Move require into modules template, make info a module (Closed)
Patch Set: Created March 31, 2017, 5:44 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 | « packagerEdge.py ('k') | templates/geckoInfo.js.tmpl » ('j') | 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 (function() { 7 let platform = "chromium";
8 var platform = "chromium"; 8 let platformVersion = null;
9 var platformVersion = null; 9 let application = null;
10 var application = null; 10 let applicationVersion;
11 var applicationVersion;
12 11
13 var regexp = /(\S+)\/(\S+)(?:\s*\(.*?\))?/g; 12 let regexp = /(\S+)\/(\S+)(?:\s*\(.*?\))?/g;
14 var match; 13 let match;
15 14
16 while (match = regexp.exec(navigator.userAgent)) 15 while (match = regexp.exec(navigator.userAgent))
16 {
17 let app = match[1];
18 let ver = match[2];
19
20 if (app == "Chrome")
17 { 21 {
18 var app = match[1]; 22 platformVersion = ver;
19 var ver = match[2]; 23 }
24 else if (app == "Edge")
25 {
26 platform = "edgehtml";
27 platformVersion = ver;
28 application = "edge";
29 applicationVersion = "0";
30 }
31 else if (app != "Mozilla" && app != "AppleWebKit" && app != "Safari")
32 {
33 // For compatibility with legacy websites, Chrome's UA
34 // also includes a Mozilla, AppleWebKit and Safari token.
35 // Any further name/version pair indicates a fork.
36 application = app == "OPR" ? "opera" : app.toLowerCase();
37 applicationVersion = ver;
38 }
39 }
20 40
21 if (app == "Chrome") 41 // not a Chromium-based UA, probably modifed by the user
22 { 42 if (!platformVersion)
23 platformVersion = ver; 43 {
24 } 44 application = "unknown";
25 else if (app == "Edge") 45 applicationVersion = platformVersion = "0";
26 { 46 }
27 platform = "edgehtml";
28 platformVersion = ver;
29 application = "edge";
30 applicationVersion = "0";
31 }
32 else if (app != "Mozilla" && app != "AppleWebKit" && app != "Safari")
33 {
34 // For compatibility with legacy websites, Chrome's UA
35 // also includes a Mozilla, AppleWebKit and Safari token.
36 // Any further name/version pair indicates a fork.
37 application = app == "OPR" ? "opera" : app.toLowerCase();
38 applicationVersion = ver;
39 }
40 }
41 47
42 // not a Chromium-based UA, probably modifed by the user 48 // no additional name/version, so this is upstream Chrome
43 if (!platformVersion) 49 if (!application)
44 { 50 {
45 application = "unknown"; 51 application = "chrome";
46 applicationVersion = platformVersion = "0"; 52 applicationVersion = platformVersion;
47 } 53 }
48 54
49 // no additional name/version, so this is upstream Chrome 55 module.exports = {
50 if (!application) 56 addonName: {{ basename|json }},
51 { 57 addonVersion: {{ version|json }},
52 application = "chrome";
53 applicationVersion = platformVersion;
54 }
55 58
56 require.scopes.info = { 59 application,
57 addonName: {{ metadata.get('general', 'basename')|json }}, 60 applicationVersion,
58 addonVersion: {{ version|json }},
59 61
60 application: application, 62 platform,
61 applicationVersion: applicationVersion, 63 platformVersion
62 64 };
63 platform: platform,
64 platformVersion: platformVersion
65 };
66 })();
OLDNEW
« no previous file with comments | « packagerEdge.py ('k') | templates/geckoInfo.js.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld