mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1420514 - Remove pref app.update.enabled from the update mechanism r=rstrong
Getting rid of this pref allowed some other code to be removed: - Changed nsIUpdateService::stopChecking(duration) to nsIUpdateService::stopCurrentCheck() and got rid of the constants representing durations. The available durations were CURRENT_CHECK, CURRENT_SESSION, and ANY_CHECKS, but only CURRENT_CHECK was ever used. - nsIUpdateChecker::stopChecking(CURRENT_SESSION) and nsIUpdateChecker::stopChecking(ANY_CHECKS) were the only mechanisms for setting Checker::_enabled to false, so Checker::_enabled and Checker::enabled were removed. References to Checker::enabled were replaced with checks for nsUpdateService::canCheckForUpdates. - In browser/base/content/aboutDialog-appUpdater.js, the updateDisabledAndLocked() function was renamed to updateDisabledByPolicy, since the old name is no longer accurate and the new function name is a better description of the function's actual use. MozReview-Commit-ID: 4wwqo4ROr1V --HG-- extra : rebase_source : ea2e0f157dccc02eece585d3d15ebb67a38813d8 extra : intermediate-source : 00f6d87c63dfb940c439b49c8310b3a91be3a912 extra : source : 83c69c5f289572aee6ff5a8c85237bbeaac3cb8b
This commit is contained in:
parent
ac7e7375e6
commit
35440f6dd0
@ -20,7 +20,7 @@ var gAppUpdater;
|
||||
|
||||
function onUnload(aEvent) {
|
||||
if (gAppUpdater.isChecking)
|
||||
gAppUpdater.checker.stopChecking(Ci.nsIUpdateChecker.CURRENT_CHECK);
|
||||
gAppUpdater.checker.stopCurrentCheck();
|
||||
// Safe to call even when there isn't a download in progress.
|
||||
gAppUpdater.removeDownloadListener();
|
||||
gAppUpdater = null;
|
||||
@ -60,8 +60,8 @@ function appUpdater(options = {}) {
|
||||
manualLink.href = manualURL;
|
||||
document.getElementById("failedLink").href = manualURL;
|
||||
|
||||
if (this.updateDisabledAndLocked) {
|
||||
this.selectPanel("adminDisabled");
|
||||
if (this.updateDisabledByPolicy) {
|
||||
this.selectPanel("policyDisabled");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -81,16 +81,6 @@ function appUpdater(options = {}) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Honor the "Never check for updates" option by not only disabling background
|
||||
// update checks, but also in the About dialog, by presenting a
|
||||
// "Check for updates" button.
|
||||
// If updates are found, the user is then asked if he wants to "Update to <version>".
|
||||
if (!this.updateEnabled ||
|
||||
Services.prefs.prefHasUserValue(PREF_APP_UPDATE_ELEVATE_NEVER)) {
|
||||
this.selectPanel("checkForUpdates");
|
||||
return;
|
||||
}
|
||||
|
||||
// That leaves the options
|
||||
// "Check for updates, but let me choose whether to install them", and
|
||||
// "Automatically install updates".
|
||||
@ -135,25 +125,14 @@ appUpdater.prototype =
|
||||
this.um.activeUpdate.state == "downloading";
|
||||
},
|
||||
|
||||
// true when updating is disabled by an administrator.
|
||||
get updateDisabledAndLocked() {
|
||||
return (!this.updateEnabled &&
|
||||
Services.prefs.prefIsLocked("app.update.enabled")) ||
|
||||
(Services.policies &&
|
||||
!Services.policies.isAllowed("appUpdate"));
|
||||
},
|
||||
|
||||
// true when updating is enabled.
|
||||
get updateEnabled() {
|
||||
try {
|
||||
return Services.prefs.getBoolPref("app.update.enabled");
|
||||
} catch (e) { }
|
||||
return true; // Firefox default is true
|
||||
// true when updating has been disabled by enterprise policy
|
||||
get updateDisabledByPolicy() {
|
||||
return Services.policies && !Services.policies.isAllowed("appUpdate");
|
||||
},
|
||||
|
||||
// true when updating in background is enabled.
|
||||
get backgroundUpdateEnabled() {
|
||||
return this.updateEnabled &&
|
||||
return !this.updateDisabledByPolicy &&
|
||||
gAppUpdater.aus.canStageUpdates;
|
||||
},
|
||||
|
||||
|
@ -93,7 +93,7 @@
|
||||
<hbox id="downloadFailed" align="center">
|
||||
<label>&update.failed.start;</label><label id="failedLink" class="text-link">&update.failed.linkText;</label><label>&update.failed.end;</label>
|
||||
</hbox>
|
||||
<hbox id="adminDisabled" align="center">
|
||||
<hbox id="policyDisabled" align="center">
|
||||
<label>&update.adminDisabled;</label>
|
||||
</hbox>
|
||||
<hbox id="noUpdatesFound" align="center">
|
||||
|
@ -771,7 +771,6 @@ BrowserGlue.prototype = {
|
||||
_checkForOldBuildUpdates() {
|
||||
// check for update if our build is old
|
||||
if (AppConstants.MOZ_UPDATER &&
|
||||
Services.prefs.getBoolPref("app.update.enabled") &&
|
||||
Services.prefs.getBoolPref("app.update.checkInstallTime")) {
|
||||
|
||||
let buildID = Services.appinfo.appBuildID;
|
||||
|
@ -484,7 +484,7 @@
|
||||
accesskey="&update.checkForUpdatesButton.accesskey;"
|
||||
oncommand="gAppUpdater.checkForUpdates();"/>
|
||||
</hbox>
|
||||
<hbox id="adminDisabled" align="start">
|
||||
<hbox id="policyDisabled" align="start">
|
||||
<label>&update.adminDisabled;</label>
|
||||
<spacer flex="1"/>
|
||||
<button label="&update.checkForUpdatesButton.label;"
|
||||
|
@ -14,10 +14,10 @@ ChromeUtils.import("resource://gre/modules/UpdateTelemetry.jsm", this);
|
||||
|
||||
const XMLNS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
|
||||
const PREF_APP_UPDATE_AUTO = "app.update.auto";
|
||||
const PREF_APP_UPDATE_BACKGROUNDERRORS = "app.update.backgroundErrors";
|
||||
const PREF_APP_UPDATE_CERT_ERRORS = "app.update.cert.errors";
|
||||
const PREF_APP_UPDATE_ELEVATE_NEVER = "app.update.elevate.never";
|
||||
const PREF_APP_UPDATE_ENABLED = "app.update.enabled";
|
||||
const PREF_APP_UPDATE_LOG = "app.update.log";
|
||||
const PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED = "app.update.notifiedUnsupported";
|
||||
const PREF_APP_UPDATE_URL_MANUAL = "app.update.url.manual";
|
||||
@ -492,7 +492,7 @@ var gCheckingPage = {
|
||||
* Manager control, so stop checking for updates.
|
||||
*/
|
||||
onWizardCancel() {
|
||||
this._checker.stopChecking(Ci.nsIUpdateChecker.CURRENT_CHECK);
|
||||
this._checker.stopCurrentCheck();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -561,8 +561,7 @@ var gNoUpdatesPage = {
|
||||
onPageShow() {
|
||||
LOG("gNoUpdatesPage", "onPageShow - could not select an appropriate " +
|
||||
"update. Either there were no updates or |selectUpdate| failed");
|
||||
|
||||
if (Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true))
|
||||
if (Services.prefs.getBoolPref(PREF_APP_UPDATE_AUTO, true))
|
||||
document.getElementById("noUpdatesAutoEnabled").hidden = false;
|
||||
else
|
||||
document.getElementById("noUpdatesAutoDisabled").hidden = false;
|
||||
|
@ -275,30 +275,15 @@ interface nsIUpdateChecker : nsISupports
|
||||
* current value of the user's update settings. This is used by
|
||||
* any piece of UI that offers the user the imperative option to
|
||||
* check for updates now, regardless of their update settings.
|
||||
* force will not work if the system administrator has locked
|
||||
* the app.update.enabled preference.
|
||||
* However, if updates are disabled by policy, setting force to true
|
||||
* will not override the the policy.
|
||||
*/
|
||||
void checkForUpdates(in nsIUpdateCheckListener listener, in boolean force);
|
||||
|
||||
/**
|
||||
* Constants for the |stopChecking| function that tell the Checker how long
|
||||
* to stop checking:
|
||||
*
|
||||
* CURRENT_CHECK: Stops the current (active) check only
|
||||
* CURRENT_SESSION: Stops all checking for the current session
|
||||
* ANY_CHECKS: Stops all checking, any session from now on
|
||||
* (disables update checking preferences)
|
||||
*/
|
||||
const unsigned short CURRENT_CHECK = 1;
|
||||
const unsigned short CURRENT_SESSION = 2;
|
||||
const unsigned short ANY_CHECKS = 3;
|
||||
|
||||
/**
|
||||
* Ends any pending update check.
|
||||
* @param duration
|
||||
* A value representing the set of checks to stop doing.
|
||||
*/
|
||||
void stopChecking(in unsigned short duration);
|
||||
void stopCurrentCheck();
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -32,7 +32,7 @@ const PREF_APP_UPDATE_ELEVATE_NEVER = "app.update.elevate.never";
|
||||
const PREF_APP_UPDATE_ELEVATE_VERSION = "app.update.elevate.version";
|
||||
const PREF_APP_UPDATE_ELEVATE_ATTEMPTS = "app.update.elevate.attempts";
|
||||
const PREF_APP_UPDATE_ELEVATE_MAXATTEMPTS = "app.update.elevate.maxAttempts";
|
||||
const PREF_APP_UPDATE_ENABLED = "app.update.enabled";
|
||||
const PREF_APP_UPDATE_DISABLEDFORTESTING = "app.update.disabledForTesting";
|
||||
const PREF_APP_UPDATE_IDLETIME = "app.update.idletime";
|
||||
const PREF_APP_UPDATE_LOG = "app.update.log";
|
||||
const PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED = "app.update.notifiedUnsupported";
|
||||
@ -519,40 +519,6 @@ function getCanStageUpdates() {
|
||||
return gCanStageUpdatesSession;
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gCanCheckForUpdates", function aus_gCanCheckForUpdates() {
|
||||
// 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 = 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.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Services.policies && !Services.policies.isAllowed("appUpdate")) {
|
||||
LOG("gCanCheckForUpdates - unable to automatically check for updates. " +
|
||||
"Functionality disabled by enterprise policy.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we don't know the binary platform we're updating, we can't update.
|
||||
if (!UpdateUtils.ABI) {
|
||||
LOG("gCanCheckForUpdates - unable to check for updates, unknown ABI");
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we don't know the OS version we're updating, we can't update.
|
||||
if (!UpdateUtils.OSVersion) {
|
||||
LOG("gCanCheckForUpdates - unable to check for updates, unknown OS " +
|
||||
"version");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG("gCanCheckForUpdates - able to check for updates");
|
||||
return true;
|
||||
});
|
||||
|
||||
/**
|
||||
* Logs a string to the error console.
|
||||
* @param string
|
||||
@ -2016,11 +1982,6 @@ UpdateService.prototype = {
|
||||
// UPDATE_LAST_NOTIFY_INTERVAL_DAYS_NOTIFY
|
||||
AUSTLMY.pingLastUpdateTime(this._pingSuffix);
|
||||
// Histogram IDs:
|
||||
// UPDATE_NOT_PREF_UPDATE_ENABLED_EXTERNAL
|
||||
// UPDATE_NOT_PREF_UPDATE_ENABLED_NOTIFY
|
||||
AUSTLMY.pingBoolPref("UPDATE_NOT_PREF_UPDATE_ENABLED_" + this._pingSuffix,
|
||||
PREF_APP_UPDATE_ENABLED, true, true);
|
||||
// Histogram IDs:
|
||||
// UPDATE_NOT_PREF_UPDATE_AUTO_EXTERNAL
|
||||
// UPDATE_NOT_PREF_UPDATE_AUTO_NOTIFY
|
||||
AUSTLMY.pingBoolPref("UPDATE_NOT_PREF_UPDATE_AUTO_" + this._pingSuffix,
|
||||
@ -2098,14 +2059,12 @@ UpdateService.prototype = {
|
||||
} else if (!validUpdateURL) {
|
||||
AUSTLMY.pingCheckCode(this._pingSuffix,
|
||||
AUSTLMY.CHK_INVALID_DEFAULT_URL);
|
||||
} else if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true)) {
|
||||
} else if (this.disabledByPolicy) {
|
||||
AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_PREF_DISABLED);
|
||||
} else if (!hasUpdateMutex()) {
|
||||
AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_NO_MUTEX);
|
||||
} else if (!gCanCheckForUpdates) {
|
||||
} else if (!this.canCheckForUpdates) {
|
||||
AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_UNABLE_TO_CHECK);
|
||||
} else if (!this.backgroundChecker._enabled) {
|
||||
AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_DISABLED_FOR_SESSION);
|
||||
}
|
||||
|
||||
this.backgroundChecker.checkForUpdates(this, false);
|
||||
@ -2251,8 +2210,7 @@ UpdateService.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
var updateEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true);
|
||||
if (!updateEnabled) {
|
||||
if (this.disabledByPolicy) {
|
||||
AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_PREF_DISABLED);
|
||||
LOG("UpdateService:_selectAndInstallUpdate - not prompting because " +
|
||||
"update is disabled");
|
||||
@ -2344,11 +2302,48 @@ UpdateService.prototype = {
|
||||
return this._backgroundChecker;
|
||||
},
|
||||
|
||||
get disabledForTesting() {
|
||||
return Cu.isInAutomation &&
|
||||
Services.prefs.getBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, false);
|
||||
},
|
||||
|
||||
get disabledByPolicy() {
|
||||
return (Services.policies && !Services.policies.isAllowed("appUpdate")) ||
|
||||
this.disabledForTesting;
|
||||
},
|
||||
|
||||
/**
|
||||
* See nsIUpdateService.idl
|
||||
*/
|
||||
get canCheckForUpdates() {
|
||||
return gCanCheckForUpdates && hasUpdateMutex();
|
||||
if (this.disabledByPolicy) {
|
||||
LOG("UpdateService.canCheckForUpdates - unable to automatically check " +
|
||||
"for updates, the option has been disabled by the administrator.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we don't know the binary platform we're updating, we can't update.
|
||||
if (!UpdateUtils.ABI) {
|
||||
LOG("UpdateService.canCheckForUpdates - unable to check for updates, " +
|
||||
"unknown ABI");
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we don't know the OS version we're updating, we can't update.
|
||||
if (!UpdateUtils.OSVersion) {
|
||||
LOG("UpdateService.canCheckForUpdates - unable to check for updates, " +
|
||||
"unknown OS version");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!hasUpdateMutex()) {
|
||||
LOG("UpdateService.canCheckForUpdates - unable to check for updates, " +
|
||||
"unable to acquire update mutex");
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG("UpdateService.canCheckForUpdates - able to check for updates");
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -2964,7 +2959,13 @@ Checker.prototype = {
|
||||
throw Cr.NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
if (!this.enabled && !force) {
|
||||
let UpdateServiceInstance = UpdateServiceFactory.createInstance();
|
||||
// |force| can override |canCheckForUpdates| since |force| indicates a
|
||||
// manual update check. But nothing should override enterprise policies.
|
||||
if (UpdateServiceInstance.disabledByPolicy) {
|
||||
return;
|
||||
}
|
||||
if (!UpdateServiceInstance.canCheckForUpdates && !force) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3143,33 +3144,13 @@ Checker.prototype = {
|
||||
this._request = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Whether or not we are allowed to do update checking.
|
||||
*/
|
||||
_enabled: true,
|
||||
get enabled() {
|
||||
return Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true) &&
|
||||
gCanCheckForUpdates && hasUpdateMutex() && this._enabled;
|
||||
},
|
||||
|
||||
/**
|
||||
* See nsIUpdateService.idl
|
||||
*/
|
||||
stopChecking: function UC_stopChecking(duration) {
|
||||
stopCurrentCheck: function UC_stopCurrentCheck() {
|
||||
// Always stop the current check
|
||||
if (this._request)
|
||||
this._request.abort();
|
||||
|
||||
switch (duration) {
|
||||
case Ci.nsIUpdateChecker.CURRENT_SESSION:
|
||||
this._enabled = false;
|
||||
break;
|
||||
case Ci.nsIUpdateChecker.ANY_CHECKS:
|
||||
this._enabled = false;
|
||||
Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, this._enabled);
|
||||
break;
|
||||
}
|
||||
|
||||
this._callback = null;
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user