summaryrefslogtreecommitdiffstats
path: root/netwerk
diff options
context:
space:
mode:
authorJustOff <Off.Just.Off@gmail.com>2020-03-24 22:56:31 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 13:19:20 +0200
commitd86349716a9740226d9175b1cf4b60765cb707fc (patch)
tree5a368b1cdfae46c78e9f3382177650bb114bf1ac /netwerk
parent64a7c9e2d2f8c9ebdc4c70c16c630cebbd5abe53 (diff)
downloadUXP-d86349716a9740226d9175b1cf4b60765cb707fc.tar
UXP-d86349716a9740226d9175b1cf4b60765cb707fc.tar.gz
UXP-d86349716a9740226d9175b1cf4b60765cb707fc.tar.lz
UXP-d86349716a9740226d9175b1cf4b60765cb707fc.tar.xz
UXP-d86349716a9740226d9175b1cf4b60765cb707fc.zip
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 425bdfd72..e106f817a 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 37e801f2f..a1b57876b 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')