Bug 1436851 - Implement mechanism to disable system addon updates via enterprise policy r=aswan,Felipe,rhelmer
authorKirk Steuber <ksteuber@mozilla.com>
Mon, 12 Feb 2018 10:44:43 -0800
changeset 406798 da7d8d24de6135355ebe6b2f72eefa8c475a9d30
parent 406797 a30bf832849293bae5b24454518121a74ab4d7bc
child 406799 3a38bc5be24cf2466f7184842bedd199898f66b3
push id33581
push userbtara@mozilla.com
push dateWed, 07 Mar 2018 10:01:53 +0000
treeherdermozilla-central@08802a2ae2b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan, Felipe, rhelmer
bugs1436851
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1436851 - Implement mechanism to disable system addon updates via enterprise policy r=aswan,Felipe,rhelmer 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
toolkit/mozapps/extensions/AddonManager.jsm
--- 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);
   },