mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1428401 - Remove obsolete getPref helpers, r=Gijs.
This commit is contained in:
parent
ebae541f60
commit
e44246d6d2
@ -23,13 +23,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "EventDispatcher",
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
|
||||
|
||||
function getPref(func, preference, defaultValue) {
|
||||
try {
|
||||
return Services.prefs[func](preference);
|
||||
} catch (e) {}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Add-on auto-update management service
|
||||
// -----------------------------------------------------------------------
|
||||
@ -48,7 +41,7 @@ AddonUpdateService.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsITimerCallback]),
|
||||
|
||||
notify: function aus_notify(aTimer) {
|
||||
if (aTimer && !getPref("getBoolPref", PREF_ADDON_UPDATE_ENABLED, true))
|
||||
if (aTimer && !Services.prefs.getBoolPref(PREF_ADDON_UPDATE_ENABLED, true))
|
||||
return;
|
||||
|
||||
// If we already auto-upgraded and installed new versions, ignore this check
|
||||
@ -60,7 +53,7 @@ AddonUpdateService.prototype = {
|
||||
let gmp = new GMPInstallManager();
|
||||
gmp.simpleCheckAndInstall().catch(() => {});
|
||||
|
||||
let interval = 1000 * getPref("getIntPref", PREF_ADDON_UPDATE_INTERVAL, 86400);
|
||||
let interval = 1000 * Services.prefs.getIntPref(PREF_ADDON_UPDATE_INTERVAL, 86400);
|
||||
EventDispatcher.instance.sendRequest({
|
||||
type: "Gecko:ScheduleRun",
|
||||
action: "update-addons",
|
||||
|
@ -15,29 +15,9 @@ 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
|
||||
@ -92,13 +72,15 @@ TimerManager.prototype = {
|
||||
minInterval = 500;
|
||||
minFirstInterval = 500;
|
||||
case "profile-after-change":
|
||||
this._timerMinimumDelay = Math.max(1000 * getPref("getIntPref", PREF_APP_UPDATE_TIMERMINIMUMDELAY, 120),
|
||||
minInterval);
|
||||
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.
|
||||
@ -188,7 +170,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);
|
||||
@ -199,7 +181,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
|
||||
@ -322,7 +304,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;
|
||||
|
@ -157,26 +157,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 Services.prefs[func](preference);
|
||||
} catch (e) {
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
// Restarts the application checking in with observers first
|
||||
function restartApp() {
|
||||
// Notify all windows that an application quit has been requested.
|
||||
@ -253,10 +233,10 @@ function parseRegExp(aStr) {
|
||||
function Blocklist() {
|
||||
Services.obs.addObserver(this, "xpcom-shutdown");
|
||||
Services.obs.addObserver(this, "sessionstore-windows-restored");
|
||||
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),
|
||||
MAX_BLOCK_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);
|
||||
Services.prefs.addObserver("extensions.blocklist.", this);
|
||||
Services.prefs.addObserver(PREF_EM_LOGGING_ENABLED, this);
|
||||
this.wrappedJSObject = this;
|
||||
@ -301,15 +281,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;
|
||||
@ -512,8 +492,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";
|
||||
@ -521,7 +501,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";
|
||||
} else {
|
||||
@ -1416,7 +1396,7 @@ Blocklist.prototype = {
|
||||
|
||||
Services.obs.addObserver(applyBlocklistChanges, "addon-blocklist-closed");
|
||||
|
||||
if (getPref("getBoolPref", PREF_BLOCKLIST_SUPPRESSUI, false)) {
|
||||
if (Services.prefs.getBoolPref(PREF_BLOCKLIST_SUPPRESSUI, false)) {
|
||||
applyBlocklistChanges();
|
||||
return;
|
||||
}
|
||||
|
@ -82,27 +82,6 @@ function openUpdateURL(event) {
|
||||
openURL(event.target.getAttribute("url"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
LOG("General", "getPref - failed to get preference: " + preference);
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* A set of shared data and control functions for the wizard as a whole.
|
||||
*/
|
||||
@ -311,7 +290,7 @@ var gUpdates = {
|
||||
onLoad() {
|
||||
this.wiz = document.documentElement;
|
||||
|
||||
gLogEnabled = getPref("getBoolPref", PREF_APP_UPDATE_LOG, false);
|
||||
gLogEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_LOG, false);
|
||||
|
||||
this.strings = document.getElementById("updateStrings");
|
||||
var brandStrings = document.getElementById("brandStrings");
|
||||
@ -595,7 +574,7 @@ var gNoUpdatesPage = {
|
||||
LOG("gNoUpdatesPage", "onPageShow - could not select an appropriate " +
|
||||
"update. Either there were no updates or |selectUpdate| failed");
|
||||
|
||||
if (getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true))
|
||||
if (Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true))
|
||||
document.getElementById("noUpdatesAutoEnabled").hidden = false;
|
||||
else
|
||||
document.getElementById("noUpdatesAutoDisabled").hidden = false;
|
||||
@ -1295,7 +1274,7 @@ var gFinishedPage = {
|
||||
moreElevatedLinkLabel.setAttribute("hidden", "false");
|
||||
}
|
||||
|
||||
if (getPref("getBoolPref", PREF_APP_UPDATE_TEST_LOOP, false)) {
|
||||
if (Services.prefs.getBoolPref(PREF_APP_UPDATE_TEST_LOOP, false)) {
|
||||
setTimeout(function() { gUpdates.wiz.getButton("finish").click(); },
|
||||
UPDATE_TEST_LOOP_INTERVAL);
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
|
||||
"resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gLogEnabled", function aus_gLogEnabled() {
|
||||
return getPref("getBoolPref", PREF_APP_UPDATE_LOG, false);
|
||||
return Services.prefs.getBoolPref(PREF_APP_UPDATE_LOG, false);
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gUpdateBundle", function aus_gUpdateBundle() {
|
||||
@ -506,7 +506,7 @@ XPCOMUtils.defineLazyGetter(this, "gCanStageUpdatesSession", function aus_gCSUS(
|
||||
*/
|
||||
function getCanStageUpdates() {
|
||||
// If staging updates are disabled, then just bail out!
|
||||
if (!getPref("getBoolPref", PREF_APP_UPDATE_STAGING_ENABLED, false)) {
|
||||
if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_STAGING_ENABLED, false)) {
|
||||
LOG("getCanStageUpdates - staging updates is disabled by preference " +
|
||||
PREF_APP_UPDATE_STAGING_ENABLED);
|
||||
return false;
|
||||
@ -533,7 +533,7 @@ XPCOMUtils.defineLazyGetter(this, "gCanCheckForUpdates", function aus_gCanCheckF
|
||||
// If the administrator has disabled app update and locked the preference so
|
||||
// users can't check for updates. This preference check is ok in this lazy
|
||||
// getter since locked prefs don't change until the application is restarted.
|
||||
var enabled = getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true);
|
||||
var enabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true);
|
||||
if (!enabled && Services.prefs.prefIsLocked(PREF_APP_UPDATE_ENABLED)) {
|
||||
LOG("gCanCheckForUpdates - unable to automatically check for updates, " +
|
||||
"the preference is disabled and admistratively locked.");
|
||||
@ -569,26 +569,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
|
||||
* @return 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a string containing binary values to hex.
|
||||
*/
|
||||
@ -756,7 +736,7 @@ function shouldUseService() {
|
||||
// 2) The maintenance service is installed
|
||||
// 3) The pref for using the service is enabled
|
||||
if (!AppConstants.MOZ_MAINTENANCE_SERVICE || !isServiceInstalled() ||
|
||||
!getPref("getBoolPref", PREF_APP_UPDATE_SERVICE_ENABLED, false)) {
|
||||
!Services.prefs.getBoolPref(PREF_APP_UPDATE_SERVICE_ENABLED, false)) {
|
||||
LOG("shouldUseService - returning false");
|
||||
return false;
|
||||
}
|
||||
@ -946,11 +926,11 @@ function handleUpdateFailure(update, errorCode) {
|
||||
}
|
||||
|
||||
if (update.errorCode == ELEVATION_CANCELED) {
|
||||
if (getPref("getBoolPref", PREF_APP_UPDATE_DOORHANGER, false)) {
|
||||
let elevationAttempts = getPref("getIntPref", PREF_APP_UPDATE_ELEVATE_ATTEMPTS, 0);
|
||||
if (Services.prefs.getBoolPref(PREF_APP_UPDATE_DOORHANGER, false)) {
|
||||
let elevationAttempts = Services.prefs.getIntPref(PREF_APP_UPDATE_ELEVATE_ATTEMPTS, 0);
|
||||
elevationAttempts++;
|
||||
Services.prefs.setIntPref(PREF_APP_UPDATE_ELEVATE_ATTEMPTS, elevationAttempts);
|
||||
let maxAttempts = Math.min(getPref("getIntPref", PREF_APP_UPDATE_ELEVATE_MAXATTEMPTS, 2), 10);
|
||||
let maxAttempts = Math.min(Services.prefs.getIntPref(PREF_APP_UPDATE_ELEVATE_MAXATTEMPTS, 2), 10);
|
||||
|
||||
if (elevationAttempts > maxAttempts) {
|
||||
LOG("handleUpdateFailure - notifying observers of error. " +
|
||||
@ -963,18 +943,18 @@ function handleUpdateFailure(update, errorCode) {
|
||||
}
|
||||
}
|
||||
|
||||
let cancelations = getPref("getIntPref", PREF_APP_UPDATE_CANCELATIONS, 0);
|
||||
let cancelations = Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS, 0);
|
||||
cancelations++;
|
||||
Services.prefs.setIntPref(PREF_APP_UPDATE_CANCELATIONS, cancelations);
|
||||
if (AppConstants.platform == "macosx") {
|
||||
let osxCancelations = getPref("getIntPref",
|
||||
PREF_APP_UPDATE_CANCELATIONS_OSX, 0);
|
||||
let osxCancelations =
|
||||
Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX, 0);
|
||||
osxCancelations++;
|
||||
Services.prefs.setIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX,
|
||||
osxCancelations);
|
||||
let maxCancels = getPref("getIntPref",
|
||||
PREF_APP_UPDATE_CANCELATIONS_OSX_MAX,
|
||||
DEFAULT_CANCELATIONS_OSX_MAX);
|
||||
let maxCancels =
|
||||
Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX_MAX,
|
||||
DEFAULT_CANCELATIONS_OSX_MAX);
|
||||
// Prevent the preference from setting a value greater than 5.
|
||||
maxCancels = Math.min(maxCancels, 5);
|
||||
if (osxCancelations >= maxCancels) {
|
||||
@ -1003,11 +983,9 @@ function handleUpdateFailure(update, errorCode) {
|
||||
}
|
||||
|
||||
if (SERVICE_ERRORS.includes(update.errorCode)) {
|
||||
var failCount = getPref("getIntPref",
|
||||
PREF_APP_UPDATE_SERVICE_ERRORS, 0);
|
||||
var maxFail = getPref("getIntPref",
|
||||
PREF_APP_UPDATE_SERVICE_MAXERRORS,
|
||||
DEFAULT_SERVICE_MAX_ERRORS);
|
||||
var failCount = Services.prefs.getIntPref(PREF_APP_UPDATE_SERVICE_ERRORS, 0);
|
||||
var maxFail = Services.prefs.getIntPref(PREF_APP_UPDATE_SERVICE_MAXERRORS,
|
||||
DEFAULT_SERVICE_MAX_ERRORS);
|
||||
// Prevent the preference from setting a value greater than 10.
|
||||
maxFail = Math.min(maxFail, 10);
|
||||
// As a safety, when the service reaches maximum failures, it will
|
||||
@ -1277,7 +1255,7 @@ function Update(update) {
|
||||
this.isCompleteUpdate = false;
|
||||
this.unsupported = false;
|
||||
this.channel = "default";
|
||||
this.promptWaitTime = getPref("getIntPref", PREF_APP_UPDATE_PROMPTWAITTIME, 43200);
|
||||
this.promptWaitTime = Services.prefs.getIntPref(PREF_APP_UPDATE_PROMPTWAITTIME, 43200);
|
||||
|
||||
// Null <update>, assume this is a message container and do no
|
||||
// further initialization
|
||||
@ -1653,7 +1631,7 @@ UpdateService.prototype = {
|
||||
break;
|
||||
case "nsPref:changed":
|
||||
if (data == PREF_APP_UPDATE_LOG) {
|
||||
gLogEnabled = getPref("getBoolPref", PREF_APP_UPDATE_LOG, false);
|
||||
gLogEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_LOG, false);
|
||||
}
|
||||
break;
|
||||
case "quit-application":
|
||||
@ -1940,11 +1918,11 @@ UpdateService.prototype = {
|
||||
// Send the error code to telemetry
|
||||
AUSTLMY.pingCheckExError(this._pingSuffix, update.errorCode);
|
||||
update.errorCode = BACKGROUNDCHECK_MULTIPLE_FAILURES;
|
||||
let errCount = getPref("getIntPref", PREF_APP_UPDATE_BACKGROUNDERRORS, 0);
|
||||
let errCount = Services.prefs.getIntPref(PREF_APP_UPDATE_BACKGROUNDERRORS, 0);
|
||||
errCount++;
|
||||
Services.prefs.setIntPref(PREF_APP_UPDATE_BACKGROUNDERRORS, errCount);
|
||||
// Don't allow the preference to set a value greater than 20 for max errors.
|
||||
let maxErrors = Math.min(getPref("getIntPref", PREF_APP_UPDATE_BACKGROUNDMAXERRORS, 10), 20);
|
||||
let maxErrors = Math.min(Services.prefs.getIntPref(PREF_APP_UPDATE_BACKGROUNDMAXERRORS, 10), 20);
|
||||
|
||||
if (errCount >= maxErrors) {
|
||||
let prompter = Cc["@mozilla.org/updates/update-prompt;1"].
|
||||
@ -2122,7 +2100,7 @@ UpdateService.prototype = {
|
||||
} else if (!validUpdateURL) {
|
||||
AUSTLMY.pingCheckCode(this._pingSuffix,
|
||||
AUSTLMY.CHK_INVALID_DEFAULT_URL);
|
||||
} else if (!getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true)) {
|
||||
} else if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true)) {
|
||||
AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_PREF_DISABLED);
|
||||
} else if (!hasUpdateMutex()) {
|
||||
AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_NO_MUTEX);
|
||||
@ -2198,9 +2176,8 @@ UpdateService.prototype = {
|
||||
let update = minorUpdate || majorUpdate;
|
||||
if (AppConstants.platform == "macosx" && update) {
|
||||
if (getElevationRequired()) {
|
||||
let installAttemptVersion = getPref("getCharPref",
|
||||
PREF_APP_UPDATE_ELEVATE_VERSION,
|
||||
null);
|
||||
let installAttemptVersion =
|
||||
Services.prefs.getCharPref(PREF_APP_UPDATE_ELEVATE_VERSION, null);
|
||||
if (vc.compare(installAttemptVersion, update.appVersion) != 0) {
|
||||
Services.prefs.setCharPref(PREF_APP_UPDATE_ELEVATE_VERSION,
|
||||
update.appVersion);
|
||||
@ -2212,13 +2189,13 @@ UpdateService.prototype = {
|
||||
Services.prefs.clearUserPref(PREF_APP_UPDATE_ELEVATE_NEVER);
|
||||
}
|
||||
} else {
|
||||
let numCancels = getPref("getIntPref",
|
||||
PREF_APP_UPDATE_CANCELATIONS_OSX, 0);
|
||||
let rejectedVersion = getPref("getCharPref",
|
||||
PREF_APP_UPDATE_ELEVATE_NEVER, "");
|
||||
let maxCancels = getPref("getIntPref",
|
||||
PREF_APP_UPDATE_CANCELATIONS_OSX_MAX,
|
||||
DEFAULT_CANCELATIONS_OSX_MAX);
|
||||
let numCancels =
|
||||
Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX, 0);
|
||||
let rejectedVersion =
|
||||
Services.prefs.getCharPref(PREF_APP_UPDATE_ELEVATE_NEVER, "");
|
||||
let maxCancels =
|
||||
Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX_MAX,
|
||||
DEFAULT_CANCELATIONS_OSX_MAX);
|
||||
if (numCancels >= maxCancels) {
|
||||
LOG("UpdateService:selectUpdate - the user requires elevation to " +
|
||||
"install this update, but the user has exceeded the max " +
|
||||
@ -2276,7 +2253,7 @@ UpdateService.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
var updateEnabled = getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true);
|
||||
var updateEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true);
|
||||
if (!updateEnabled) {
|
||||
AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_PREF_DISABLED);
|
||||
LOG("UpdateService:_selectAndInstallUpdate - not prompting because " +
|
||||
@ -2293,7 +2270,7 @@ UpdateService.prototype = {
|
||||
LOG("UpdateService:_selectAndInstallUpdate - update not supported for " +
|
||||
"this system. Notifying observers. topic: update-available, " +
|
||||
"status: unsupported");
|
||||
if (!getPref("getBoolPref", PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED, false)) {
|
||||
if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED, false)) {
|
||||
LOG("UpdateService:_selectAndInstallUpdate - notifying that the " +
|
||||
"update is not supported for this system");
|
||||
this._showPrompt(update);
|
||||
@ -2330,7 +2307,7 @@ UpdateService.prototype = {
|
||||
* Major Notify
|
||||
* Minor Auto Install
|
||||
*/
|
||||
if (!getPref("getBoolPref", PREF_APP_UPDATE_AUTO, true)) {
|
||||
if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_AUTO, true)) {
|
||||
LOG("UpdateService:_selectAndInstallUpdate - prompting because silent " +
|
||||
"install is disabled. Notifying observers. topic: update-available, " +
|
||||
"status: show-prompt");
|
||||
@ -2828,7 +2805,7 @@ UpdateManager.prototype = {
|
||||
Services.obs.notifyObservers(update, "update-staged", update.state);
|
||||
|
||||
// Only prompt when the UI isn't already open.
|
||||
let windowType = getPref("getCharPref", PREF_APP_UPDATE_ALTWINDOWTYPE, null);
|
||||
let windowType = Services.prefs.getCharPref(PREF_APP_UPDATE_ALTWINDOWTYPE, null);
|
||||
if (Services.wm.getMostRecentWindow(UPDATE_WINDOW_NAME) ||
|
||||
windowType && Services.wm.getMostRecentWindow(windowType)) {
|
||||
return;
|
||||
@ -3165,7 +3142,7 @@ Checker.prototype = {
|
||||
*/
|
||||
_enabled: true,
|
||||
get enabled() {
|
||||
return getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true) &&
|
||||
return Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true) &&
|
||||
gCanCheckForUpdates && hasUpdateMutex() && this._enabled;
|
||||
},
|
||||
|
||||
@ -3711,12 +3688,12 @@ class ChannelDownloader extends CommonDownloader {
|
||||
var shouldRegisterOnlineObserver = false;
|
||||
var shouldRetrySoon = false;
|
||||
var deleteActiveUpdate = false;
|
||||
var retryTimeout = getPref("getIntPref", PREF_APP_UPDATE_SOCKET_RETRYTIMEOUT,
|
||||
DEFAULT_SOCKET_RETRYTIMEOUT);
|
||||
var retryTimeout = Services.prefs.getIntPref(PREF_APP_UPDATE_SOCKET_RETRYTIMEOUT,
|
||||
DEFAULT_SOCKET_RETRYTIMEOUT);
|
||||
// Prevent the preference from setting a value greater than 10000.
|
||||
retryTimeout = Math.min(retryTimeout, 10000);
|
||||
var maxFail = getPref("getIntPref", PREF_APP_UPDATE_SOCKET_MAXERRORS,
|
||||
DEFAULT_SOCKET_MAX_ERRORS);
|
||||
var maxFail = Services.prefs.getIntPref(PREF_APP_UPDATE_SOCKET_MAXERRORS,
|
||||
DEFAULT_SOCKET_MAX_ERRORS);
|
||||
// Prevent the preference from setting a value greater than 20.
|
||||
maxFail = Math.min(maxFail, 20);
|
||||
LOG("ChannelDownloader:finishDownload - status: " + status + ", " +
|
||||
@ -3858,11 +3835,11 @@ class ChannelDownloader extends CommonDownloader {
|
||||
}
|
||||
|
||||
if (allFailed) {
|
||||
if (getPref("getBoolPref", PREF_APP_UPDATE_DOORHANGER, false)) {
|
||||
let downloadAttempts = getPref("getIntPref", PREF_APP_UPDATE_DOWNLOAD_ATTEMPTS, 0);
|
||||
if (Services.prefs.getBoolPref(PREF_APP_UPDATE_DOORHANGER, false)) {
|
||||
let downloadAttempts = Services.prefs.getIntPref(PREF_APP_UPDATE_DOWNLOAD_ATTEMPTS, 0);
|
||||
downloadAttempts++;
|
||||
Services.prefs.setIntPref(PREF_APP_UPDATE_DOWNLOAD_ATTEMPTS, downloadAttempts);
|
||||
let maxAttempts = Math.min(getPref("getIntPref", PREF_APP_UPDATE_DOWNLOAD_MAXATTEMPTS, 2), 10);
|
||||
let maxAttempts = Math.min(Services.prefs.getIntPref(PREF_APP_UPDATE_DOWNLOAD_MAXATTEMPTS, 2), 10);
|
||||
|
||||
if (downloadAttempts > maxAttempts) {
|
||||
LOG("ChannelDownloader:finishDownload - notifying observers of error. " +
|
||||
@ -3999,8 +3976,8 @@ UpdatePrompt.prototype = {
|
||||
* See nsIUpdateService.idl
|
||||
*/
|
||||
showUpdateAvailable: function UP_showUpdateAvailable(update) {
|
||||
if (getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false) ||
|
||||
getPref("getBoolPref", PREF_APP_UPDATE_DOORHANGER, false) ||
|
||||
if (Services.prefs.getBoolPref(PREF_APP_UPDATE_SILENT, false) ||
|
||||
Services.prefs.getBoolPref(PREF_APP_UPDATE_DOORHANGER, false) ||
|
||||
this._getUpdateWindow() || this._getAltUpdateWindow()) {
|
||||
return;
|
||||
}
|
||||
@ -4013,7 +3990,7 @@ UpdatePrompt.prototype = {
|
||||
* See nsIUpdateService.idl
|
||||
*/
|
||||
showUpdateDownloaded: function UP_showUpdateDownloaded(update, background) {
|
||||
if (background && getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false)) {
|
||||
if (background && Services.prefs.getBoolPref(PREF_APP_UPDATE_SILENT, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -4022,7 +3999,7 @@ UpdatePrompt.prototype = {
|
||||
"an update was downloaded. topic: update-downloaded, status: " + update.state);
|
||||
Services.obs.notifyObservers(update, "update-downloaded", update.state);
|
||||
|
||||
if (getPref("getBoolPref", PREF_APP_UPDATE_DOORHANGER, false)) {
|
||||
if (Services.prefs.getBoolPref(PREF_APP_UPDATE_DOORHANGER, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -4042,8 +4019,8 @@ UpdatePrompt.prototype = {
|
||||
* See nsIUpdateService.idl
|
||||
*/
|
||||
showUpdateError: function UP_showUpdateError(update) {
|
||||
if (getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false) ||
|
||||
getPref("getBoolPref", PREF_APP_UPDATE_DOORHANGER, false) ||
|
||||
if (Services.prefs.getBoolPref(PREF_APP_UPDATE_SILENT, false) ||
|
||||
Services.prefs.getBoolPref(PREF_APP_UPDATE_DOORHANGER, false) ||
|
||||
this._getAltUpdateWindow())
|
||||
return;
|
||||
|
||||
@ -4080,7 +4057,7 @@ UpdatePrompt.prototype = {
|
||||
* See nsIUpdateService.idl
|
||||
*/
|
||||
showUpdateElevationRequired: function UP_showUpdateElevationRequired() {
|
||||
if (getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false) ||
|
||||
if (Services.prefs.getBoolPref(PREF_APP_UPDATE_SILENT, false) ||
|
||||
this._getAltUpdateWindow()) {
|
||||
return;
|
||||
}
|
||||
@ -4104,7 +4081,7 @@ UpdatePrompt.prototype = {
|
||||
* application update user interface window.
|
||||
*/
|
||||
_getAltUpdateWindow: function UP__getAltUpdateWindow() {
|
||||
let windowType = getPref("getCharPref", PREF_APP_UPDATE_ALTWINDOWTYPE, null);
|
||||
let windowType = Services.prefs.getCharPref(PREF_APP_UPDATE_ALTWINDOWTYPE, null);
|
||||
if (!windowType)
|
||||
return null;
|
||||
return Services.wm.getMostRecentWindow(windowType);
|
||||
@ -4156,7 +4133,7 @@ UpdatePrompt.prototype = {
|
||||
var idleService = Cc["@mozilla.org/widget/idleservice;1"].
|
||||
getService(Ci.nsIIdleService);
|
||||
// Don't allow the preference to set a value greater than 600 seconds for the idle time.
|
||||
const IDLE_TIME = Math.min(getPref("getIntPref", PREF_APP_UPDATE_IDLETIME, 60), 600);
|
||||
const IDLE_TIME = Math.min(Services.prefs.getIntPref(PREF_APP_UPDATE_IDLETIME, 60), 600);
|
||||
if (idleService.idleTime / 1000 >= IDLE_TIME) {
|
||||
this._showUI(parent, uri, features, name, page, update);
|
||||
return;
|
||||
@ -4201,7 +4178,7 @@ UpdatePrompt.prototype = {
|
||||
getService(Ci.nsIIdleService);
|
||||
|
||||
// Don't allow the preference to set a value greater than 600 seconds for the idle time.
|
||||
const IDLE_TIME = Math.min(getPref("getIntPref", PREF_APP_UPDATE_IDLETIME, 60), 600);
|
||||
const IDLE_TIME = Math.min(Services.prefs.getIntPref(PREF_APP_UPDATE_IDLETIME, 60), 600);
|
||||
if (idleService.idleTime / 1000 >= IDLE_TIME) {
|
||||
this._showUI(parent, uri, features, name, page, update);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user