Bug 1436851 - Implement mechanism to disable system addon updates via enterprise policy
This patch additionally removes the check where if AddonManagerPrivate.backgroundUpdateTimerHandler does not call AddonManagerInternal.backgroundUpdateCheck if updates to all addons are disabled. The check is redundant as AddonManagerInternal.backgroundUpdateCheck makes those same checks.
MozReview-Commit-ID: FxS8127JYkn
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -1320,31 +1320,40 @@ var AddonManagerInternal = {
addon: info.addon,
permissions: difference,
resolve, reject
}};
Services.obs.notifyObservers(subject, "webextension-update-permissions");
});
},
+ // Returns true if System Addons should be updated
+ systemUpdateEnabled() {
+ if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED) ||
+ !Services.prefs.getBoolPref(PREF_APP_UPDATE_AUTO)) {
+ return false;
+ }
+ if (Services.policies && !Services.policies.isAllowed("SysAddonUpdate")) {
+ return false;
+ }
+ return true;
+ },
+
/**
* Performs a background update check by starting an update for all add-ons
* that can be updated.
* @return Promise{null} Resolves when the background update check is complete
* (the resulting addon installations may still be in progress).
*/
backgroundUpdateCheck() {
if (!gStarted)
throw Components.Exception("AddonManager is not initialized",
Cr.NS_ERROR_NOT_INITIALIZED);
let buPromise = (async () => {
- let appUpdateEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED) &&
- Services.prefs.getBoolPref(PREF_APP_UPDATE_AUTO);
-
logger.debug("Background update check beginning");
Services.obs.notifyObservers(null, "addons-background-update-start");
if (this.updateEnabled) {
let scope = {};
ChromeUtils.import("resource://gre/modules/LightweightThemeManager.jsm", scope);
scope.LightweightThemeManager.updateCurrentTheme();
@@ -1381,17 +1390,17 @@ var AddonManagerInternal = {
onUpdateFinished: aAddon => { logger.debug("onUpdateFinished for ${id}", aAddon); resolve(); }
}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
}));
}
await Promise.all(updates);
}
- if (appUpdateEnabled) {
+ if (AddonManagerInternal.systemUpdateEnabled()) {
try {
await AddonManagerInternal._getProviderByName("XPIProvider").updateSystemAddons();
} catch (e) {
logger.warn("Failed to update system addons", e);
}
}
logger.debug("Background update check complete");
@@ -2999,24 +3008,16 @@ var AddonManagerPrivate = {
AddonManagerInternal.markProviderSafe(aProvider);
},
backgroundUpdateCheck() {
return AddonManagerInternal.backgroundUpdateCheck();
},
backgroundUpdateTimerHandler() {
- // Don't call through to the real update check if no checks are enabled.
- let appUpdateEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED) &&
- Services.prefs.getBoolPref(PREF_APP_UPDATE_AUTO);
-
- if (!AddonManagerInternal.updateEnabled && !appUpdateEnabled) {
- logger.info("Skipping background update check");
- return;
- }
// Don't return the promise here, since the caller doesn't care.
AddonManagerInternal.backgroundUpdateCheck();
},
addStartupChange(aType, aID) {
AddonManagerInternal.addStartupChange(aType, aID);
},