summaryrefslogtreecommitdiff
path: root/toolkit/components
diff options
context:
space:
mode:
authorAscrod <32915892+Ascrod@users.noreply.github.com>2019-03-24 20:22:03 -0400
committerAscrod <32915892+Ascrod@users.noreply.github.com>2019-03-24 20:22:03 -0400
commitc9d2e9bcfb77657b3be7d368e57f43747c23ddc4 (patch)
tree0956b0a08cd9b742821205535942913835ec97bc /toolkit/components
parentcac3f9678de46298a93537e8913912bba28d89f7 (diff)
downloaduxp-c9d2e9bcfb77657b3be7d368e57f43747c23ddc4.tar.gz
Remove obsolete getPref helpers.
Diffstat (limited to 'toolkit/components')
-rw-r--r--toolkit/components/blocklist/nsBlocklistService.js43
-rw-r--r--toolkit/components/search/current/nsSearchService.js26
-rw-r--r--toolkit/components/search/orginal/nsSearchService.js26
-rw-r--r--toolkit/components/timermanager/nsUpdateTimerManager.js32
4 files changed, 31 insertions, 96 deletions
diff --git a/toolkit/components/blocklist/nsBlocklistService.js b/toolkit/components/blocklist/nsBlocklistService.js
index 1cd2ed8066..49033fc8f6 100644
--- a/toolkit/components/blocklist/nsBlocklistService.js
+++ b/toolkit/components/blocklist/nsBlocklistService.js
@@ -169,27 +169,6 @@ function LOG(string) {
}
/**
- * Gets a preference value, handling the case where there is no default.
- * @param func
- * The name of the preference function to call, on nsIPrefBranch
- * @param preference
- * The name of the preference
- * @param defaultValue
- * The default value to return in the event the preference has
- * no setting
- * @returns The value of the preference, or undefined if there was no
- * user or default value.
- */
-function getPref(func, preference, defaultValue) {
- try {
- return gPref[func](preference);
- }
- catch (e) {
- }
- return defaultValue;
-}
-
-/**
* Constructs a URI to a spec.
* @param spec
* The spec to construct a URI to
@@ -297,9 +276,9 @@ function parseRegExp(aStr) {
function Blocklist() {
Services.obs.addObserver(this, "xpcom-shutdown", false);
Services.obs.addObserver(this, "sessionstore-windows-restored", false);
- gLoggingEnabled = getPref("getBoolPref", PREF_EM_LOGGING_ENABLED, false);
- gBlocklistEnabled = getPref("getBoolPref", PREF_BLOCKLIST_ENABLED, true);
- gBlocklistLevel = Math.min(getPref("getIntPref", PREF_BLOCKLIST_LEVEL, DEFAULT_LEVEL),
+ gLoggingEnabled = Services.prefs.getBoolPref(PREF_EM_LOGGING_ENABLED, false);
+ gBlocklistEnabled = Services.prefs.getBoolPref(PREF_BLOCKLIST_ENABLED, true);
+ gBlocklistLevel = Math.min(Services.prefs.getIntPref(PREF_BLOCKLIST_LEVEL, DEFAULT_LEVEL),
MAX_BLOCK_LEVEL);
gPref.addObserver("extensions.blocklist.", this, false);
gPref.addObserver(PREF_EM_LOGGING_ENABLED, this, false);
@@ -345,15 +324,15 @@ Blocklist.prototype = {
case "nsPref:changed":
switch (aData) {
case PREF_EM_LOGGING_ENABLED:
- gLoggingEnabled = getPref("getBoolPref", PREF_EM_LOGGING_ENABLED, false);
+ gLoggingEnabled = Services.prefs.getBoolPref(PREF_EM_LOGGING_ENABLED, false);
break;
case PREF_BLOCKLIST_ENABLED:
- gBlocklistEnabled = getPref("getBoolPref", PREF_BLOCKLIST_ENABLED, true);
+ gBlocklistEnabled = Services.prefs.getBoolPref(PREF_BLOCKLIST_ENABLED, true);
this._loadBlocklist();
this._blocklistUpdated(null, null);
break;
case PREF_BLOCKLIST_LEVEL:
- gBlocklistLevel = Math.min(getPref("getIntPref", PREF_BLOCKLIST_LEVEL, DEFAULT_LEVEL),
+ gBlocklistLevel = Math.min(Services.prefs.getIntPref(PREF_BLOCKLIST_LEVEL, DEFAULT_LEVEL),
MAX_BLOCK_LEVEL);
this._blocklistUpdated(null, null);
break;
@@ -525,8 +504,8 @@ Blocklist.prototype = {
return;
}
- var pingCountVersion = getPref("getIntPref", PREF_BLOCKLIST_PINGCOUNTVERSION, 0);
- var pingCountTotal = getPref("getIntPref", PREF_BLOCKLIST_PINGCOUNTTOTAL, 1);
+ var pingCountVersion = Services.prefs.getIntPref(PREF_BLOCKLIST_PINGCOUNTVERSION, 0);
+ var pingCountTotal = Services.prefs.getIntPref(PREF_BLOCKLIST_PINGCOUNTTOTAL, 1);
var daysSinceLastPing = 0;
if (pingCountVersion == 0) {
daysSinceLastPing = "new";
@@ -535,7 +514,7 @@ Blocklist.prototype = {
// Seconds in one day is used because nsIUpdateTimerManager stores the
// last update time in seconds.
let secondsInDay = 60 * 60 * 24;
- let lastUpdateTime = getPref("getIntPref", PREF_BLOCKLIST_LASTUPDATETIME, 0);
+ let lastUpdateTime = Services.prefs.getIntPref(PREF_BLOCKLIST_LASTUPDATETIME, 0);
if (lastUpdateTime == 0) {
daysSinceLastPing = "invalid";
}
@@ -894,7 +873,7 @@ Blocklist.prototype = {
return;
}
- var populateCertBlocklist = getPref("getBoolPref", PREF_ONECRL_VIA_AMO, true);
+ var populateCertBlocklist = Services.prefs.getBoolPref(PREF_ONECRL_VIA_AMO, true);
var childNodes = doc.documentElement.childNodes;
for (let element of childNodes) {
@@ -1466,7 +1445,7 @@ Blocklist.prototype = {
Services.obs.addObserver(applyBlocklistChanges, "addon-blocklist-closed", false);
- if (getPref("getBoolPref", PREF_BLOCKLIST_SUPPRESSUI, false)) {
+ if (Services.prefs.getBoolPref(PREF_BLOCKLIST_SUPPRESSUI, false)) {
applyBlocklistChanges();
return;
}
diff --git a/toolkit/components/search/current/nsSearchService.js b/toolkit/components/search/current/nsSearchService.js
index 6e8f6da436..2a86010780 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);
}
};
@@ -908,18 +908,6 @@ function getLocalizedPref(aPrefName, 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
* no valid characters).
@@ -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 6b23724a75..5b5ce7a577 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;
@@ -934,18 +934,6 @@ function setLocalizedPref(aPrefName, aValue) {
}
/**
- * 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
* A name to "sanitize". Can be an empty string, in which case a random
@@ -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;
diff --git a/toolkit/components/timermanager/nsUpdateTimerManager.js b/toolkit/components/timermanager/nsUpdateTimerManager.js
index d7fc159602..3ba82f8c0f 100644
--- a/toolkit/components/timermanager/nsUpdateTimerManager.js
+++ b/toolkit/components/timermanager/nsUpdateTimerManager.js
@@ -16,30 +16,10 @@ const PREF_APP_UPDATE_LOG = "app.update.log";
const CATEGORY_UPDATE_TIMER = "update-timer";
XPCOMUtils.defineLazyGetter(this, "gLogEnabled", function tm_gLogEnabled() {
- return getPref("getBoolPref", PREF_APP_UPDATE_LOG, false);
+ return Services.prefs.getBoolPref(PREF_APP_UPDATE_LOG, false);
});
/**
- * Gets a preference value, handling the case where there is no default.
- * @param func
- * The name of the preference function to call, on nsIPrefBranch
- * @param preference
- * The name of the preference
- * @param defaultValue
- * The default value to return in the event the preference has
- * no setting
- * @returns The value of the preference, or undefined if there was no
- * user or default value.
- */
-function getPref(func, preference, defaultValue) {
- try {
- return Services.prefs[func](preference);
- } catch (e) {
- }
- return defaultValue;
-}
-
-/**
* Logs a string to the error console.
* @param string
* The string to write to the error console.
@@ -93,13 +73,13 @@ TimerManager.prototype = {
minInterval = 500;
minFirstInterval = 500;
case "profile-after-change":
- this._timerMinimumDelay = Math.max(1000 * getPref("getIntPref", PREF_APP_UPDATE_TIMERMINIMUMDELAY, 120),
+ this._timerMinimumDelay = Math.max(1000 * Services.prefs.getIntPref(PREF_APP_UPDATE_TIMERMINIMUMDELAY, 120),
minInterval);
// Prevent the timer delay between notifications to other consumers from
// being greater than 5 minutes which is 300000 milliseconds.
this._timerMinimumDelay = Math.min(this._timerMinimumDelay, 300000);
// Prevent the first interval from being less than the value of minFirstInterval
- let firstInterval = Math.max(getPref("getIntPref", PREF_APP_UPDATE_TIMERFIRSTINTERVAL,
+ let firstInterval = Math.max(Services.prefs.getIntPref(PREF_APP_UPDATE_TIMERFIRSTINTERVAL,
30000), minFirstInterval);
// Prevent the first interval from being greater than 2 minutes which is
// 120000 milliseconds.
@@ -189,7 +169,7 @@ TimerManager.prototype = {
continue;
}
- let interval = getPref("getIntPref", prefInterval, defaultInterval);
+ let interval = Services.prefs.getIntPref(prefInterval, defaultInterval);
// Allow the update-timer category to specify a maximum value to prevent
// values larger than desired.
maxInterval = parseInt(maxInterval);
@@ -200,7 +180,7 @@ TimerManager.prototype = {
timerID);
// Initialize the last update time to 0 when the preference isn't set so
// the timer will be notified soon after a new profile's first use.
- lastUpdateTime = getPref("getIntPref", prefLastUpdate, 0);
+ lastUpdateTime = Services.prefs.getIntPref(prefLastUpdate, 0);
// If the last update time is greater than the current time then reset
// it to 0 and the timer manager will correct the value when it fires
@@ -315,7 +295,7 @@ TimerManager.prototype = {
let prefLastUpdate = PREF_APP_UPDATE_LASTUPDATETIME_FMT.replace(/%ID%/, id);
// Initialize the last update time to 0 when the preference isn't set so
// the timer will be notified soon after a new profile's first use.
- let lastUpdateTime = getPref("getIntPref", prefLastUpdate, 0);
+ let lastUpdateTime = Services.prefs.getIntPref(prefLastUpdate, 0);
let now = Math.round(Date.now() / 1000);
if (lastUpdateTime > now) {
lastUpdateTime = 0;