summaryrefslogtreecommitdiffstats
path: root/toolkit/modules/UpdateChannel.jsm
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-11 09:25:10 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-11 09:25:10 -0500
commit97ff781ee8ffc7f5298cb287d72d01d7e9cf9bbc (patch)
tree22f1cc00fe307ea686a98e4e5983a0dd7a0c832c /toolkit/modules/UpdateChannel.jsm
parent203eb0f61a09372310a2a8fb57e169cb3f47800b (diff)
downloadUXP-97ff781ee8ffc7f5298cb287d72d01d7e9cf9bbc.tar
UXP-97ff781ee8ffc7f5298cb287d72d01d7e9cf9bbc.tar.gz
UXP-97ff781ee8ffc7f5298cb287d72d01d7e9cf9bbc.tar.lz
UXP-97ff781ee8ffc7f5298cb287d72d01d7e9cf9bbc.tar.xz
UXP-97ff781ee8ffc7f5298cb287d72d01d7e9cf9bbc.zip
Add UpdateChannel.jsm
Diffstat (limited to 'toolkit/modules/UpdateChannel.jsm')
-rw-r--r--toolkit/modules/UpdateChannel.jsm47
1 files changed, 47 insertions, 0 deletions
diff --git a/toolkit/modules/UpdateChannel.jsm b/toolkit/modules/UpdateChannel.jsm
new file mode 100644
index 000000000..c2bdce8ad
--- /dev/null
+++ b/toolkit/modules/UpdateChannel.jsm
@@ -0,0 +1,47 @@
+#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;
+ }
+};