diff options
Diffstat (limited to 'toolkit/mozapps/extensions')
8 files changed, 36 insertions, 131 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/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/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) { |