1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/modules/UpdateChannel.jsm Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,47 @@ 1.4 +#filter substitution 1.5 + 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +this.EXPORTED_SYMBOLS = ["UpdateChannel"]; 1.11 + 1.12 +const Cu = Components.utils; 1.13 + 1.14 +Cu.import("resource://gre/modules/Services.jsm"); 1.15 + 1.16 +this.UpdateChannel = { 1.17 + /** 1.18 + * Read the update channel from defaults only. We do this to ensure that 1.19 + * the channel is tightly coupled with the application and does not apply 1.20 + * to other instances of the application that may use the same profile. 1.21 + * 1.22 + * @param [optional] aIncludePartners 1.23 + * Whether or not to include the partner bits. Default: true. 1.24 + */ 1.25 + get: function UpdateChannel_get(aIncludePartners = true) { 1.26 + let channel = "@MOZ_UPDATE_CHANNEL@"; 1.27 + let defaults = Services.prefs.getDefaultBranch(null); 1.28 + try { 1.29 + channel = defaults.getCharPref("app.update.channel"); 1.30 + } catch (e) { 1.31 + // use default value when pref not found 1.32 + } 1.33 + 1.34 + if (aIncludePartners) { 1.35 + try { 1.36 + let partners = Services.prefs.getChildList("app.partner.").sort(); 1.37 + if (partners.length) { 1.38 + channel += "-cck"; 1.39 + partners.forEach(function (prefName) { 1.40 + channel += "-" + Services.prefs.getCharPref(prefName); 1.41 + }); 1.42 + } 1.43 + } catch (e) { 1.44 + Cu.reportError(e); 1.45 + } 1.46 + } 1.47 + 1.48 + return channel; 1.49 + } 1.50 +};