summaryrefslogtreecommitdiff
path: root/netwerk
diff options
context:
space:
mode:
authorJustOff <Off.Just.Off@gmail.com>2020-03-24 22:56:31 +0200
committerJustOff <Off.Just.Off@gmail.com>2020-03-24 22:56:31 +0200
commite74509ec540e84230508cc1a634eee9551e68ac8 (patch)
treec8bcf4aaa07c17498a784579deed45104e25bcfb /netwerk
parent9308c03f5ebeeb888e350a8c3a5b9dc0be813f99 (diff)
downloaduxp-e74509ec540e84230508cc1a634eee9551e68ac8.tar.gz
Issue #1473 - Fix building `%OS_SLICE%` on non-Windows platforms
Diffstat (limited to 'netwerk')
-rw-r--r--netwerk/protocol/http/UserAgentOverrides.jsm23
-rw-r--r--netwerk/protocol/http/moz.build4
2 files changed, 22 insertions, 5 deletions
diff --git a/netwerk/protocol/http/UserAgentOverrides.jsm b/netwerk/protocol/http/UserAgentOverrides.jsm
index 425bdfd726..e106f817ad 100644
--- a/netwerk/protocol/http/UserAgentOverrides.jsm
+++ b/netwerk/protocol/http/UserAgentOverrides.jsm
@@ -2,6 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+#ifdef XP_WIN
+#define UA_SPARE_PLATFORM
+#endif
+
"use strict";
this.EXPORTED_SYMBOLS = [ "UserAgentOverrides" ];
@@ -18,9 +22,14 @@ const PREF_OVERRIDES_ENABLED = "general.useragent.site_specific_overrides";
const DEFAULT_UA = Cc["@mozilla.org/network/protocol;1?name=http"]
.getService(Ci.nsIHttpProtocolHandler)
.userAgent;
-const OS_SLICE = Cc["@mozilla.org/network/protocol;1?name=http"]
+const OSCPU = Cc["@mozilla.org/network/protocol;1?name=http"]
+ .getService(Ci.nsIHttpProtocolHandler)
+ .oscpu;
+#ifndef UA_SPARE_PLATFORM
+const PLATFORM = Cc["@mozilla.org/network/protocol;1?name=http"]
.getService(Ci.nsIHttpProtocolHandler)
- .oscpu + ";";
+ .platform;
+#endif
const MAX_OVERRIDE_FOR_HOST_CACHE_SIZE = 250;
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
@@ -37,12 +46,20 @@ var gOverrideFunctions = [
function (aHttpChannel) { return UserAgentOverrides.getOverrideForURI(aHttpChannel.URI); }
];
var gBuiltUAs = new Map;
+var gOSSlice;
this.UserAgentOverrides = {
init: function uao_init() {
if (gInitialized)
return;
+ gOSSlice = OSCPU + ";";
+#ifndef UA_SPARE_PLATFORM
+ if (PLATFORM != "") {
+ gOSSlice = PLATFORM + "; " + gOSSlice;
+ }
+#endif
+
gPrefBranch = Services.prefs.getBranch("general.useragent.override.");
gPrefBranch.addObserver("", buildOverrides, false);
@@ -151,7 +168,7 @@ function getUserAgentFromOverride(override)
if (search && replace) {
userAgent = DEFAULT_UA.replace(new RegExp(search, "g"), replace);
} else {
- userAgent = override.replace(/%OS_SLICE%/g, OS_SLICE);
+ userAgent = override.replace(/%OS_SLICE%/g, gOSSlice);
}
gBuiltUAs.set(override, userAgent);
return userAgent;
diff --git a/netwerk/protocol/http/moz.build b/netwerk/protocol/http/moz.build
index 37e801f2f9..a1b57876bb 100644
--- a/netwerk/protocol/http/moz.build
+++ b/netwerk/protocol/http/moz.build
@@ -99,9 +99,9 @@ IPDL_SOURCES += [
'PHttpChannel.ipdl',
]
-EXTRA_JS_MODULES += ['UserAgentOverrides.jsm']
+EXTRA_JS_MODULES += ['UserAgentUpdates.jsm']
-EXTRA_PP_JS_MODULES += ['UserAgentUpdates.jsm']
+EXTRA_PP_JS_MODULES += ['UserAgentOverrides.jsm']
include('/ipc/chromium/chromium-config.mozbuild')