diff options
Diffstat (limited to 'toolkit/mozapps/extensions')
11 files changed, 39 insertions, 186 deletions
diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm index 4cd2c3d0a..a48e0034f 100644 --- a/toolkit/mozapps/extensions/AddonManager.jsm +++ b/toolkit/mozapps/extensions/AddonManager.jsm @@ -135,12 +135,7 @@ var PrefObserver = { Services.obs.removeObserver(this, "xpcom-shutdown"); } else if (aTopic == NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) { - let debugLogEnabled = false; - try { - debugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED); - } - catch (e) { - } + let debugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED, false); if (debugLogEnabled) { parentLogger.level = Log.Level.Debug; } @@ -791,11 +786,7 @@ var AddonManagerInternal = { } catch (e) { } - let oldPlatformVersion = null; - try { - oldPlatformVersion = Services.prefs.getCharPref(PREF_EM_LAST_PLATFORM_VERSION); - } - catch (e) { } + let oldPlatformVersion = Services.prefs.getCharPref(PREF_EM_LAST_PLATFORM_VERSION, ""); if (appChanged !== false) { logger.debug("Application has been upgraded"); @@ -808,40 +799,30 @@ var AddonManagerInternal = { this.validateBlocklist(); } - try { - gCheckCompatibility = Services.prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY); - } catch (e) {} + gCheckCompatibility = Services.prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY, + gCheckCompatibility); Services.prefs.addObserver(PREF_EM_CHECK_COMPATIBILITY, this, false); - try { - gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY); - } catch (e) {} + gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY, + gStrictCompatibility); Services.prefs.addObserver(PREF_EM_STRICT_COMPATIBILITY, this, false); - try { - let defaultBranch = Services.prefs.getDefaultBranch(""); - gCheckUpdateSecurityDefault = defaultBranch.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY); - } catch(e) {} + let defaultBranch = Services.prefs.getDefaultBranch(""); + gCheckUpdateSecurityDefault = defaultBranch.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, + gCheckUpdateSecurityDefault); - try { - gCheckUpdateSecurity = Services.prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY); - } catch (e) {} + gCheckUpdateSecurity = Services.prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, + gCheckUpdateSecurity); Services.prefs.addObserver(PREF_EM_CHECK_UPDATE_SECURITY, this, false); - try { - gUpdateEnabled = Services.prefs.getBoolPref(PREF_EM_UPDATE_ENABLED); - } catch (e) {} + gUpdateEnabled = Services.prefs.getBoolPref(PREF_EM_UPDATE_ENABLED, gUpdateEnabled); Services.prefs.addObserver(PREF_EM_UPDATE_ENABLED, this, false); - try { - gAutoUpdateDefault = Services.prefs.getBoolPref(PREF_EM_AUTOUPDATE_DEFAULT); - } catch (e) {} + gAutoUpdateDefault = Services.prefs.getBoolPref(PREF_EM_AUTOUPDATE_DEFAULT, + gAutoUpdateDefault); Services.prefs.addObserver(PREF_EM_AUTOUPDATE_DEFAULT, this, false); - let defaultProvidersEnabled = true; - try { - defaultProvidersEnabled = Services.prefs.getBoolPref(PREF_DEFAULT_PROVIDERS_ENABLED); - } catch (e) {} + let defaultProvidersEnabled = Services.prefs.getBoolPref(PREF_DEFAULT_PROVIDERS_ENABLED, true); AddonManagerPrivate.recordSimpleMeasure("default_providers", defaultProvidersEnabled); // Ensure all default providers have had a chance to register themselves @@ -1167,11 +1148,7 @@ var AddonManagerInternal = { switch (aData) { case PREF_EM_CHECK_COMPATIBILITY: { let oldValue = gCheckCompatibility; - try { - gCheckCompatibility = Services.prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY); - } catch(e) { - gCheckCompatibility = true; - } + gCheckCompatibility = Services.prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY, true); this.callManagerListeners("onCompatibilityModeChanged"); @@ -1182,11 +1159,7 @@ var AddonManagerInternal = { } case PREF_EM_STRICT_COMPATIBILITY: { let oldValue = gStrictCompatibility; - try { - gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY); - } catch(e) { - gStrictCompatibility = true; - } + gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY, true); this.callManagerListeners("onCompatibilityModeChanged"); @@ -1197,11 +1170,7 @@ var AddonManagerInternal = { } case PREF_EM_CHECK_UPDATE_SECURITY: { let oldValue = gCheckUpdateSecurity; - try { - gCheckUpdateSecurity = Services.prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY); - } catch(e) { - gCheckUpdateSecurity = true; - } + gCheckUpdateSecurity = Services.prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, true); this.callManagerListeners("onCheckUpdateSecurityChanged"); @@ -1212,22 +1181,14 @@ var AddonManagerInternal = { } case PREF_EM_UPDATE_ENABLED: { let oldValue = gUpdateEnabled; - try { - gUpdateEnabled = Services.prefs.getBoolPref(PREF_EM_UPDATE_ENABLED); - } catch(e) { - gUpdateEnabled = true; - } + gUpdateEnabled = Services.prefs.getBoolPref(PREF_EM_UPDATE_ENABLED, true); this.callManagerListeners("onUpdateModeChanged"); break; } case PREF_EM_AUTOUPDATE_DEFAULT: { let oldValue = gAutoUpdateDefault; - try { - gAutoUpdateDefault = Services.prefs.getBoolPref(PREF_EM_AUTOUPDATE_DEFAULT); - } catch(e) { - gAutoUpdateDefault = true; - } + gAutoUpdateDefault = Services.prefs.getBoolPref(PREF_EM_AUTOUPDATE_DEFAULT, true); this.callManagerListeners("onUpdateModeChanged"); break; diff --git a/toolkit/mozapps/extensions/DeferredSave.jsm b/toolkit/mozapps/extensions/DeferredSave.jsm index 89f82b265..f1537fe4b 100644 --- a/toolkit/mozapps/extensions/DeferredSave.jsm +++ b/toolkit/mozapps/extensions/DeferredSave.jsm @@ -64,12 +64,7 @@ var PrefObserver = { Services.obs.removeObserver(this, "xpcom-shutdown"); } else if (aTopic == NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) { - let debugLogEnabled = false; - try { - debugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED); - } - catch (e) { - } + let debugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED, false); if (debugLogEnabled) { parentLogger.level = Log.Level.Debug; } 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; }, diff --git a/toolkit/mozapps/extensions/GMPUtils.jsm b/toolkit/mozapps/extensions/GMPUtils.jsm index 9e41a7a61..a199b4d86 100644 --- a/toolkit/mozapps/extensions/GMPUtils.jsm +++ b/toolkit/mozapps/extensions/GMPUtils.jsm @@ -154,13 +154,7 @@ this.GMPPrefs = { get: function(aKey, aDefaultValue, aPlugin) { if (aKey === this.KEY_APP_DISTRIBUTION || aKey === this.KEY_APP_DISTRIBUTION_VERSION) { - let prefValue = "default"; - try { - prefValue = Services.prefs.getDefaultBranch(null).getCharPref(aKey); - } catch (e) { - // use default when pref not found - } - return prefValue; + return Services.prefs.getDefaultBranch(null).getCharPref(aKey, "default"); } return Preferences.get(this.getPrefKey(aKey, aPlugin), aDefaultValue); }, diff --git a/toolkit/mozapps/extensions/LightweightThemeManager.jsm b/toolkit/mozapps/extensions/LightweightThemeManager.jsm index 372a9f3b8..a4cbf3833 100644 --- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm +++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm @@ -49,12 +49,7 @@ this.__defineGetter__("_prefs", function prefsGetter() { this.__defineGetter__("_maxUsedThemes", function maxUsedThemesGetter() { delete this._maxUsedThemes; - try { - this._maxUsedThemes = _prefs.getIntPref("maxUsedThemes"); - } - catch (e) { - this._maxUsedThemes = DEFAULT_MAX_USED_THEMES_COUNT; - } + this._maxUsedThemes = _prefs.getIntPref("maxUsedThemes", DEFAULT_MAX_USED_THEMES_COUNT); return this._maxUsedThemes; }); @@ -719,12 +714,8 @@ var _previewTimerCallback = { function _prefObserver(aSubject, aTopic, aData) { switch (aData) { case "maxUsedThemes": - try { - _maxUsedThemes = _prefs.getIntPref(aData); - } - catch (e) { - _maxUsedThemes = DEFAULT_MAX_USED_THEMES_COUNT; - } + _maxUsedThemes = _prefs.getIntPref(aData, DEFAULT_MAX_USED_THEMES_COUNT); + // Update the theme list to remove any themes over the number we keep _updateUsedThemes(LightweightThemeManager.usedThemes); break; diff --git a/toolkit/mozapps/extensions/amWebInstallListener.js b/toolkit/mozapps/extensions/amWebInstallListener.js index 088f56640..9b9c53f44 100644 --- a/toolkit/mozapps/extensions/amWebInstallListener.js +++ b/toolkit/mozapps/extensions/amWebInstallListener.js @@ -172,10 +172,6 @@ Installer.prototype = { args.wrappedJSObject = args; try { - Cc["@mozilla.org/base/telemetry;1"]. - getService(Ci.nsITelemetry). - getHistogramById("SECURITY_UI"). - add(Ci.nsISecurityUITelemetry.WARNING_CONFIRM_ADDON_INSTALL); let parentWindow = null; if (this.browser) { parentWindow = this.browser.ownerDocument.defaultView; diff --git a/toolkit/mozapps/extensions/content/xpinstallConfirm.js b/toolkit/mozapps/extensions/content/xpinstallConfirm.js index 5660cdaaf..29be5f5e9 100644 --- a/toolkit/mozapps/extensions/content/xpinstallConfirm.js +++ b/toolkit/mozapps/extensions/content/xpinstallConfirm.js @@ -179,10 +179,6 @@ XPInstallConfirm.init = function() XPInstallConfirm.onOK = function() { - Components.classes["@mozilla.org/base/telemetry;1"]. - getService(Components.interfaces.nsITelemetry). - getHistogramById("SECURITY_UI"). - add(Components.interfaces.nsISecurityUITelemetry.WARNING_CONFIRM_ADDON_INSTALL_CLICK_THROUGH); // Perform the install or cancel after the window has unloaded XPInstallConfirm._installOK = true; return true; diff --git a/toolkit/mozapps/extensions/internal/AddonLogging.jsm b/toolkit/mozapps/extensions/internal/AddonLogging.jsm index f05a6fe6c..ffa92c791 100644 --- a/toolkit/mozapps/extensions/internal/AddonLogging.jsm +++ b/toolkit/mozapps/extensions/internal/AddonLogging.jsm @@ -179,12 +179,7 @@ var PrefObserver = { Services.obs.removeObserver(this, "xpcom-shutdown"); } else if (aTopic == NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) { - try { - gDebugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED); - } - catch (e) { - gDebugLogEnabled = false; - } + gDebugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED, false); } } }; diff --git a/toolkit/mozapps/extensions/internal/AddonRepository.jsm b/toolkit/mozapps/extensions/internal/AddonRepository.jsm index 76a7528c7..9750e9944 100644 --- a/toolkit/mozapps/extensions/internal/AddonRepository.jsm +++ b/toolkit/mozapps/extensions/internal/AddonRepository.jsm @@ -486,14 +486,7 @@ this.AddonRepository = { } let preference = PREF_GETADDONS_CACHE_ENABLED; - let enabled = false; - try { - enabled = Services.prefs.getBoolPref(preference); - } catch(e) { - logger.warn("cacheEnabled: Couldn't get pref: " + preference); - } - - return enabled; + return Services.prefs.getBoolPref(preference, false); }, // A cache of the add-ons stored in the database @@ -541,11 +534,7 @@ this.AddonRepository = { metadataAge: function() { let now = Math.round(Date.now() / 1000); - - let lastUpdate = 0; - try { - lastUpdate = Services.prefs.getIntPref(PREF_METADATA_LASTUPDATE); - } catch (e) {} + let lastUpdate = Services.prefs.getIntPref(PREF_METADATA_LASTUPDATE, 0); // Handle clock jumps if (now < lastUpdate) { @@ -555,10 +544,8 @@ this.AddonRepository = { }, isMetadataStale: function AddonRepo_isMetadataStale() { - let threshold = DEFAULT_METADATA_UPDATETHRESHOLD_SEC; - try { - threshold = Services.prefs.getIntPref(PREF_METADATA_UPDATETHRESHOLD_SEC); - } catch (e) {} + let threshold = Services.prefs.getIntPref(PREF_METADATA_UPDATETHRESHOLD_SEC, + DEFAULT_METADATA_UPDATETHRESHOLD_SEC); return (this.metadataAge() > threshold); }, @@ -1543,10 +1530,8 @@ this.AddonRepository = { // Create url from preference, returning null if preference does not exist _formatURLPref: function AddonRepo_formatURLPref(aPreference, aSubstitutions) { - let url = null; - try { - url = Services.prefs.getCharPref(aPreference); - } catch(e) { + let url = Services.prefs.getCharPref(aPreference, ""); + if (!url) { logger.warn("_formatURLPref: Couldn't get pref: " + aPreference); return null; } @@ -1639,10 +1624,7 @@ var AddonDatabase = { // Create a blank addons.json file this._saveDBToDisk(); - let dbSchema = 0; - try { - dbSchema = Services.prefs.getIntPref(PREF_GETADDONS_DB_SCHEMA); - } catch (e) {} + let dbSchema = Services.prefs.getIntPref(PREF_GETADDONS_DB_SCHEMA, 0); if (dbSchema < DB_MIN_JSON_SCHEMA) { let results = yield new Promise((resolve, reject) => { diff --git a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm index c06dca1d5..a475f7f1f 100644 --- a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm +++ b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm @@ -608,12 +608,7 @@ function UpdateParser(aId, aUpdateKey, aUrl, aObserver) { this.observer = aObserver; this.url = aUrl; - let requireBuiltIn = true; - try { - requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS); - } - catch (e) { - } + let requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS, true); logger.debug("Requesting " + aUrl); try { @@ -651,12 +646,7 @@ UpdateParser.prototype = { this.request = null; this._doneAt = new Error("place holder"); - let requireBuiltIn = true; - try { - requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS); - } - catch (e) { - } + let requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS, true); try { CertUtils.checkCert(request.channel, !requireBuiltIn); diff --git a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js index f2420bd1a..69d774e4a 100644 --- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js +++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js @@ -1410,10 +1410,7 @@ this.XPIDatabase = { // when a lightweight theme is applied for example) text += "\r\n[ThemeDirs]\r\n"; - let dssEnabled = false; - try { - dssEnabled = Services.prefs.getBoolPref(PREF_EM_DSS_ENABLED); - } catch (e) {} + let dssEnabled = Services.prefs.getBoolPref(PREF_EM_DSS_ENABLED, false); let themes = []; if (dssEnabled) { |