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

Unified Diff: templates/geckoInfo.js.tmpl

Issue 29516656: Issue 5347 - Add geckoInfo.deviceForm for phone and tablet (Closed) Base URL: https://hg.adblockplus.org/buildtools/
Patch Set: Created Aug. 15, 2017, 4:11 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: templates/geckoInfo.js.tmpl
===================================================================
--- a/templates/geckoInfo.js.tmpl
+++ b/templates/geckoInfo.js.tmpl
@@ -8,17 +8,29 @@
exports.addonVersion = {{ version|json }};
exports.application = "unknown";
exports.applicationVersion = "0";
exports.platform = "gecko";
exports.platformVersion = "0";
-let match = /\brv:(\d+(?:\.\d+)?)\b/.exec(navigator.userAgent);
+exports.deviceForm = "unknown";
+
+// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
+let match = /\(((?:[^;]+; )+)rv:(\d+(?:\.\d+)?)\)/.exec(navigator.userAgent);
if (match)
- exports.platformVersion = match[1];
+{
+ exports.platformVersion = match[2];
+
+ let platformTokens = match[1].split("; ");
+
+ if (platformTokens.includes("Mobile"))
+ exports.deviceForm = "phone";
+ else if (platformTokens.includes("Tablet"))
+ exports.deviceForm = "tablet";
+}
browser.runtime.getBrowserInfo().then(browserInfo =>
{
exports.application = browserInfo.name.toLowerCase();
exports.applicationVersion = browserInfo.version;
});
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld