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

Delta Between Two Patch Sets: chromeInfo.js.tmpl

Issue 29332680: Issue 3415 - Detect application based on UA for Chromium-based browsers (Closed)
Left Patch Set: Created Dec. 15, 2015, 4:29 p.m.
Right Patch Set: Rebased Created Dec. 15, 2015, 4:56 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 (function() { 5 (function() {
6 var platformVersion = null; 6 var platformVersion = null;
7 var application = null; 7 var application = null;
8 var applicationVersion; 8 var applicationVersion;
9 9
10 var regexp = /(\S+)\/(\S+)(?:\s*\(.*?\))?/g; 10 var regexp = /(\S+)\/(\S+)(?:\s*\(.*?\))?/g;
kzar 2015/12/15 17:26:00 Nit: More descriptive name would be nice, perhaps
Sebastian Noack 2015/12/15 17:31:31 Well, the context here is limitted. And after all
11 var match; 11 var match;
12 12
13 while (match = regexp.exec(navigator.userAgent)) 13 while (match = regexp.exec(navigator.userAgent))
kzar 2015/12/15 17:26:00 Maybe a comment for this loop explaining that we'r
Sebastian Noack 2015/12/15 17:31:31 Well, how could a comment make it more obvious tha
14 { 14 {
15 var app = match[1]; 15 var app = match[1];
16 var ver = match[2]; 16 var ver = match[2];
17 17
18 if (app == "Chrome") 18 if (app == "Chrome")
19 { 19 {
20 platformVersion = ver; 20 platformVersion = ver;
21 } 21 }
22 else if (app != "Mozilla" && app != "AppleWebKit" && app != "Safari") 22 else if (app != "Mozilla" && app != "AppleWebKit" && app != "Safari")
23 { 23 {
24 // For compatibility with legacy websites, Chrome's UA 24 // For compatibility with legacy websites, Chrome's UA
25 // also includes a Mozilla, AppleWebKit and Safari token. 25 // also includes a Mozilla, AppleWebKit and Safari token.
26 // Any further name/version pair indicates a fork. 26 // Any further name/version pair indicates a fork.
27 application = app == "OPR" ? "opera" : app.toLowerCase(); 27 application = app == "OPR" ? "opera" : app.toLowerCase();
kzar 2015/12/15 17:26:00 Nit: Maybe just do `application = app.toLowerCase(
Sebastian Noack 2015/12/15 17:31:31 I don't think that spreading these conversions acr
28 applicationVersion = ver; 28 applicationVersion = ver;
29 } 29 }
30 } 30 }
31 31
32 // not a Chromium-based UA, probably modifed by the user 32 // not a Chromium-based UA, probably modifed by the user
33 if (!platformVersion) 33 if (!platformVersion)
34 { 34 {
35 application = "unknown"; 35 application = "unknown";
36 applicationVersion = platformVersion = "0"; 36 applicationVersion = platformVersion = "0";
37 } 37 }
38 38
39 // no additional name/version, so this is upstream Chrome 39 // no additional name/version, so this is upstream Chrome
40 if (!application) 40 if (!application)
41 { 41 {
42 application = "chrome"; 42 application = "chrome";
43 applicationVersion = platformVersion; 43 applicationVersion = platformVersion;
44 } 44 }
45 45
46 require.scopes.info = { 46 require.scopes.info = {
47 addonName: {{ metadata.get('general', 'basename')|json }}, 47 addonName: {{ metadata.get('general', 'basename')|json }},
48 addonVersion: {{ version|json }}, 48 addonVersion: {{ version|json }},
49 addonRoot: "",
50 49
51 application: application, 50 application: application,
52 applicationVersion: applicationVersion, 51 applicationVersion: applicationVersion,
53 52
54 platform: "chromium", 53 platform: "chromium",
55 platformVersion: platformVersion 54 platformVersion: platformVersion
56 }; 55 };
57 })(); 56 })();
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld