summaryrefslogtreecommitdiffstats
path: root/toolkit
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/components/blocklist/nsBlocklistService.js15
-rw-r--r--toolkit/modules/UpdateChannel.jsm47
-rw-r--r--toolkit/modules/UpdateUtils.jsm15
-rw-r--r--toolkit/modules/moz.build3
-rw-r--r--toolkit/mozapps/extensions/GMPInstallManager.jsm50
5 files changed, 23 insertions, 107 deletions
diff --git a/toolkit/components/blocklist/nsBlocklistService.js b/toolkit/components/blocklist/nsBlocklistService.js
index b0115e25d..788ce192f 100644
--- a/toolkit/components/blocklist/nsBlocklistService.js
+++ b/toolkit/components/blocklist/nsBlocklistService.js
@@ -4,6 +4,8 @@
* 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/. */
+#filter substitution
+
"use strict";
const Cc = Components.classes;
@@ -24,8 +26,6 @@ try {
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
"resource://gre/modules/FileUtils.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "UpdateChannel",
- "resource://gre/modules/UpdateChannel.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ServiceRequest",
@@ -525,18 +525,19 @@ Blocklist.prototype = {
pingCountTotal = 1;
dsURI = dsURI.replace(/%APP_ID%/g, gApp.ID);
+
// Not all applications implement nsIXULAppInfo (e.g. xpcshell doesn't).
- if (gApp.version)
+ if (gApp.version) {
dsURI = dsURI.replace(/%APP_VERSION%/g, gApp.version);
- dsURI = dsURI.replace(/%PRODUCT%/g, gApp.name);
- // Not all applications implement nsIXULAppInfo (e.g. xpcshell doesn't).
- if (gApp.version)
dsURI = dsURI.replace(/%VERSION%/g, gApp.version);
+ }
+
+ dsURI = dsURI.replace(/%PRODUCT%/g, gApp.name);
dsURI = dsURI.replace(/%BUILD_ID%/g, gApp.appBuildID);
dsURI = dsURI.replace(/%BUILD_TARGET%/g, gApp.OS + "_" + gABI);
dsURI = dsURI.replace(/%OS_VERSION%/g, gOSVersion);
dsURI = dsURI.replace(/%LOCALE%/g, getLocale());
- dsURI = dsURI.replace(/%CHANNEL%/g, UpdateChannel.get());
+ dsURI = dsURI.replace(/%CHANNEL%/g, "@MOZ_UPDATE_CHANNEL@");
dsURI = dsURI.replace(/%PLATFORM_VERSION%/g, gApp.platformVersion);
dsURI = dsURI.replace(/%DISTRIBUTION%/g,
getDistributionPrefValue(PREF_APP_DISTRIBUTION));
diff --git a/toolkit/modules/UpdateChannel.jsm b/toolkit/modules/UpdateChannel.jsm
deleted file mode 100644
index c2bdce8ad..000000000
--- a/toolkit/modules/UpdateChannel.jsm
+++ /dev/null
@@ -1,47 +0,0 @@
-#filter substitution
-
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-this.EXPORTED_SYMBOLS = ["UpdateChannel"];
-
-const Cu = Components.utils;
-
-Cu.import("resource://gre/modules/Services.jsm");
-
-this.UpdateChannel = {
- /**
- * Read the update channel from defaults only. We do this to ensure that
- * the channel is tightly coupled with the application and does not apply
- * to other instances of the application that may use the same profile.
- *
- * @param [optional] aIncludePartners
- * Whether or not to include the partner bits. Default: true.
- */
- get: function UpdateChannel_get(aIncludePartners = true) {
- let channel = "@MOZ_UPDATE_CHANNEL@";
- let defaults = Services.prefs.getDefaultBranch(null);
- try {
- channel = defaults.getCharPref("app.update.channel");
- } catch (e) {
- // use default value when pref not found
- }
-
- if (aIncludePartners) {
- try {
- let partners = Services.prefs.getChildList("app.partner.").sort();
- if (partners.length) {
- channel += "-cck";
- partners.forEach(function (prefName) {
- channel += "-" + Services.prefs.getCharPref(prefName);
- });
- }
- } catch (e) {
- Cu.reportError(e);
- }
- }
-
- return channel;
- }
-};
diff --git a/toolkit/modules/UpdateUtils.jsm b/toolkit/modules/UpdateUtils.jsm
index 4e796a2da..4c6e7776d 100644
--- a/toolkit/modules/UpdateUtils.jsm
+++ b/toolkit/modules/UpdateUtils.jsm
@@ -2,6 +2,8 @@
* 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/. */
+#filter substitution
+
this.EXPORTED_SYMBOLS = ["UpdateUtils"];
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
@@ -65,23 +67,28 @@ this.UpdateUtils = {
* @return The formatted URL.
*/
formatUpdateURL(url) {
+ url = url.replace(/%ID%/g, Services.appinfo.ID);
url = url.replace(/%PRODUCT%/g, Services.appinfo.name);
url = url.replace(/%VERSION%/g, Services.appinfo.version);
url = url.replace(/%BUILD_ID%/g, Services.appinfo.appBuildID);
url = url.replace(/%BUILD_TARGET%/g, Services.appinfo.OS + "_" + this.ABI);
url = url.replace(/%OS_VERSION%/g, this.OSVersion);
- url = url.replace(/%SYSTEM_CAPABILITIES%/g, gSystemCapabilities);
+ url = url.replace(/%WIDGET_TOOLKIT%/g, "@MOZ_WIDGET_TOOLKIT@");
+ url = url.replace(/%CHANNEL%/g, this.UpdateChannel);
+
if (/%LOCALE%/.test(url)) {
url = url.replace(/%LOCALE%/g, this.Locale);
}
- url = url.replace(/%CHANNEL%/g, this.UpdateChannel);
+
+ url = url.replace(/%CUSTOM%/g, Preferences.get(PREF_APP_UPDATE_CUSTOM, ""));
+ url = url.replace(/\+/g, "%2B");
+
+ url = url.replace(/%SYSTEM_CAPABILITIES%/g, gSystemCapabilities);
url = url.replace(/%PLATFORM_VERSION%/g, Services.appinfo.platformVersion);
url = url.replace(/%DISTRIBUTION%/g,
getDistributionPrefValue(PREF_APP_DISTRIBUTION));
url = url.replace(/%DISTRIBUTION_VERSION%/g,
getDistributionPrefValue(PREF_APP_DISTRIBUTION_VERSION));
- url = url.replace(/%CUSTOM%/g, Preferences.get(PREF_APP_UPDATE_CUSTOM, ""));
- url = url.replace(/\+/g, "%2B");
return url;
}
diff --git a/toolkit/modules/moz.build b/toolkit/modules/moz.build
index 8f66417c1..4e647bd7f 100644
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -92,7 +92,6 @@ EXTRA_JS_MODULES += [
'Sqlite.jsm',
'Task.jsm',
'Timer.jsm',
- 'UpdateUtils.jsm',
'WebChannel.jsm',
'WindowDraggingUtils.jsm',
'ZipUtils.jsm',
@@ -103,7 +102,7 @@ EXTRA_JS_MODULES.sessionstore += ['sessionstore/Utils.jsm']
EXTRA_PP_JS_MODULES += [
'NewTabUtils.jsm',
'Troubleshoot.jsm',
- 'UpdateChannel.jsm',
+ 'UpdateUtils.jsm',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'cocoa'):
diff --git a/toolkit/mozapps/extensions/GMPInstallManager.jsm b/toolkit/mozapps/extensions/GMPInstallManager.jsm
index b9ebe5d7e..fe4e2de10 100644
--- a/toolkit/mozapps/extensions/GMPInstallManager.jsm
+++ b/toolkit/mozapps/extensions/GMPInstallManager.jsm
@@ -38,8 +38,8 @@ XPCOMUtils.defineLazyGetter(this, "gCertUtils", function() {
return temp;
});
-XPCOMUtils.defineLazyModuleGetter(this, "UpdateChannel",
- "resource://gre/modules/UpdateChannel.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
+ "resource://gre/modules/UpdateUtils.jsm");
/**
* Number of milliseconds after which we need to cancel `checkForAddons`.
@@ -190,33 +190,6 @@ XPCOMUtils.defineLazyGetter(this, "gOSVersion", function aus_gOSVersion() {
return osVersion;
});
-// This is copied directly from nsUpdateService.js
-// It is used for calculating the URL string w/ var replacement.
-// TODO: refactor this out somewhere else
-XPCOMUtils.defineLazyGetter(this, "gABI", function aus_gABI() {
- let abi = null;
- try {
- abi = Services.appinfo.XPCOMABI;
- }
- catch (e) {
- LOG("gABI - XPCOM ABI unknown: updates are not possible.");
- }
-#ifdef XP_MACOSX
- // Mac universal build should report a different ABI than either macppc
- // or mactel.
- let macutils = Cc["@mozilla.org/xpcom/mac-utils;1"].
- getService(Ci.nsIMacUtils);
-
- if (macutils.isUniversalBinary)
- abi += "-u-" + macutils.architecturesInBinary;
-#ifdef MOZ_SHARK
- // Disambiguate optimised and shark nightlies
- abi += "-shark"
-#endif
-#endif
- return abi;
-});
-
/**
* Provides an easy API for downloading and installing GMP Addons
*/
@@ -241,24 +214,7 @@ GMPInstallManager.prototype = {
log.info("Using url: " + url);
}
- url =
- url.replace(/%PRODUCT%/g, Services.appinfo.name)
- .replace(/%VERSION%/g, Services.appinfo.version)
- .replace(/%BUILD_ID%/g, Services.appinfo.appBuildID)
- .replace(/%BUILD_TARGET%/g, Services.appinfo.OS + "_" + gABI)
- .replace(/%OS_VERSION%/g, gOSVersion);
- if (/%LOCALE%/.test(url)) {
- // TODO: Get the real local, does it actually matter for GMP plugins?
- url = url.replace(/%LOCALE%/g, "en-US");
- }
- url =
- url.replace(/%CHANNEL%/g, UpdateChannel.get())
- .replace(/%PLATFORM_VERSION%/g, Services.appinfo.platformVersion)
- .replace(/%DISTRIBUTION%/g,
- GMPPrefs.get(GMPPrefs.KEY_APP_DISTRIBUTION))
- .replace(/%DISTRIBUTION_VERSION%/g,
- GMPPrefs.get(GMPPrefs.KEY_APP_DISTRIBUTION_VERSION))
- .replace(/\+/g, "%2B");
+ url = UpdateUtils.formatUpdateURL(url);
log.info("Using url (with replacement): " + url);
return url;
},