From c9d2e9bcfb77657b3be7d368e57f43747c23ddc4 Mon Sep 17 00:00:00 2001 From: Ascrod <32915892+Ascrod@users.noreply.github.com> Date: Sun, 24 Mar 2019 20:22:03 -0400 Subject: Remove obsolete getPref helpers. --- .../components/search/current/nsSearchService.js | 26 ++++++---------------- .../components/search/orginal/nsSearchService.js | 26 ++++++---------------- 2 files changed, 14 insertions(+), 38 deletions(-) (limited to 'toolkit/components/search') diff --git a/toolkit/components/search/current/nsSearchService.js b/toolkit/components/search/current/nsSearchService.js index 6e8f6da43..2a8601078 100644 --- a/toolkit/components/search/current/nsSearchService.js +++ b/toolkit/components/search/current/nsSearchService.js @@ -234,7 +234,7 @@ var LOG = function() {}; if (AppConstants.DEBUG) { LOG = function (aText) { - if (getBoolPref(BROWSER_SEARCH_PREF + "log", false)) { + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "log", false)) { DO_LOG(aText); } }; @@ -907,18 +907,6 @@ function getLocalizedPref(aPrefName, aDefault) { return aDefault; } -/** - * Wrapper for nsIPrefBranch::getBoolPref. - * @param aPrefName - * The name of the pref to get. - * @returns aDefault if the requested pref doesn't exist. - */ -function getBoolPref(aName, aDefault) { - if (Services.prefs.getPrefType(aName) != Ci.nsIPrefBranch.PREF_BOOL) - return aDefault; - return Services.prefs.getBoolPref(aName); -} - /** * @return a sanitized name to be used as a filename, or a random name * if a sanitized name cannot be obtained (if aName contains @@ -1534,7 +1522,7 @@ Engine.prototype = { stringBundle.formatStringFromName("addEngineConfirmation", [this._name, this._uri.host], 2); var checkboxMessage = null; - if (!getBoolPref(BROWSER_SEARCH_PREF + "noCurrentEngine", false)) + if (!Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "noCurrentEngine", false)) checkboxMessage = stringBundle.GetStringFromName("addEngineAsCurrentText"); var addButtonLabel = @@ -2658,7 +2646,7 @@ function checkForSyncCompletion(aPromise) { // nsIBrowserSearchService function SearchService() { // Replace empty LOG function with the useful one if the log pref is set. - if (getBoolPref(BROWSER_SEARCH_PREF + "log", false)) + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "log", false)) LOG = DO_LOG; this._initObservers = Promise.defer(); @@ -3770,7 +3758,7 @@ SearchService.prototype = { // If the user has specified a custom engine order, read the order // information from the metadata instead of the default prefs. - if (getBoolPref(BROWSER_SEARCH_PREF + "useDBForOrder", false)) { + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "useDBForOrder", false)) { LOG("_buildSortedEngineList: using db for order"); // Flag to keep track of whether or not we need to call _saveSortedEngineList. @@ -4624,7 +4612,7 @@ SearchService.prototype = { notify: function SRCH_SVC_notify(aTimer) { LOG("_notify: checking for updates"); - if (!getBoolPref(BROWSER_SEARCH_PREF + "update", true)) + if (!Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "update", true)) return; // Our timer has expired, but unfortunately, we can't get any data from it. @@ -4735,7 +4723,7 @@ const SEARCH_UPDATE_LOG_PREFIX = "*** Search update: "; * logging pref (browser.search.update.log) is set to true. */ function ULOG(aText) { - if (getBoolPref(BROWSER_SEARCH_PREF + "update.log", false)) { + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "update.log", false)) { dump(SEARCH_UPDATE_LOG_PREFIX + aText + "\n"); Services.console.logStringMessage(aText); } @@ -4751,7 +4739,7 @@ var engineUpdateService = { update: function eus_Update(aEngine) { let engine = aEngine.wrappedJSObject; ULOG("update called for " + aEngine._name); - if (!getBoolPref(BROWSER_SEARCH_PREF + "update", true) || !engine._hasUpdates) + if (!Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "update", true) || !engine._hasUpdates) return; let testEngine = null; diff --git a/toolkit/components/search/orginal/nsSearchService.js b/toolkit/components/search/orginal/nsSearchService.js index 6b23724a7..5b5ce7a57 100644 --- a/toolkit/components/search/orginal/nsSearchService.js +++ b/toolkit/components/search/orginal/nsSearchService.js @@ -248,7 +248,7 @@ function DO_LOG(aText) { * to allow enabling/disabling without a restart. */ function PREF_LOG(aText) { - if (getBoolPref(BROWSER_SEARCH_PREF + "log", false)) + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "log", false)) DO_LOG(aText); } var LOG = PREF_LOG; @@ -933,18 +933,6 @@ function setLocalizedPref(aPrefName, aValue) { } catch (ex) {} } -/** - * Wrapper for nsIPrefBranch::getBoolPref. - * @param aPrefName - * The name of the pref to get. - * @returns aDefault if the requested pref doesn't exist. - */ -function getBoolPref(aName, aDefault) { - if (Services.prefs.getPrefType(aName) != Ci.nsIPrefBranch.PREF_BOOL) - return aDefault; - return Services.prefs.getBoolPref(aName); -} - /** * Get a unique nsIFile object with a sanitized name, based on the engine name. * @param aName @@ -1591,7 +1579,7 @@ Engine.prototype = { stringBundle.formatStringFromName("addEngineConfirmation", [this._name, this._uri.host], 2); var checkboxMessage = null; - if (!getBoolPref(BROWSER_SEARCH_PREF + "noCurrentEngine", false)) + if (!Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "noCurrentEngine", false)) checkboxMessage = stringBundle.GetStringFromName("addEngineAsCurrentText"); var addButtonLabel = @@ -2889,7 +2877,7 @@ function checkForSyncCompletion(aPromise) { // nsIBrowserSearchService function SearchService() { // Replace empty LOG function with the useful one if the log pref is set. - if (getBoolPref(BROWSER_SEARCH_PREF + "log", false)) + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "log", false)) LOG = DO_LOG; this._initObservers = Promise.defer(); @@ -3814,7 +3802,7 @@ SearchService.prototype = { // If the user has specified a custom engine order, read the order // information from the engineMetadataService instead of the default // prefs. - if (getBoolPref(BROWSER_SEARCH_PREF + "useDBForOrder", false)) { + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "useDBForOrder", false)) { LOG("_buildSortedEngineList: using db for order"); // Flag to keep track of whether or not we need to call _saveSortedEngineList. @@ -4595,7 +4583,7 @@ SearchService.prototype = { notify: function SRCH_SVC_notify(aTimer) { LOG("_notify: checking for updates"); - if (!getBoolPref(BROWSER_SEARCH_PREF + "update", true)) + if (!Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "update", true)) return; // Our timer has expired, but unfortunately, we can't get any data from it. @@ -4938,7 +4926,7 @@ const SEARCH_UPDATE_LOG_PREFIX = "*** Search update: "; * logging pref (browser.search.update.log) is set to true. */ function ULOG(aText) { - if (getBoolPref(BROWSER_SEARCH_PREF + "update.log", false)) { + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "update.log", false)) { dump(SEARCH_UPDATE_LOG_PREFIX + aText + "\n"); Services.console.logStringMessage(aText); } @@ -4955,7 +4943,7 @@ var engineUpdateService = { update: function eus_Update(aEngine) { let engine = aEngine.wrappedJSObject; ULOG("update called for " + aEngine._name); - if (!getBoolPref(BROWSER_SEARCH_PREF + "update", true) || !engine._hasUpdates) + if (!Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "update", true) || !engine._hasUpdates) return; let testEngine = null; -- cgit v1.2.3