Bug 1429150 - Change nsIApplicationUpdateService::canCheckForUpdates implementation to respect new enterprise policy preventing app update draft
authorKirk Steuber <ksteuber@mozilla.com>
Thu, 08 Feb 2018 09:41:54 -0800
changeset 753190 3524a8f99ba5c5677e875c644446a1f87854a2ed
parent 752153 65133e49fbfd5306632301f74be7cd15890bdf9f
child 753191 2083298bf813206f209c250053cc7e921cbe32b6
push id98509
push userksteuber@mozilla.com
push dateFri, 09 Feb 2018 19:18:56 +0000
bugs1429150
milestone60.0a1
Bug 1429150 - Change nsIApplicationUpdateService::canCheckForUpdates implementation to respect new enterprise policy preventing app update MozReview-Commit-ID: 7vPaDbONcRr
browser/base/content/aboutDialog-appUpdater.js
toolkit/mozapps/update/nsUpdateService.js
--- a/browser/base/content/aboutDialog-appUpdater.js
+++ b/browser/base/content/aboutDialog-appUpdater.js
@@ -132,18 +132,20 @@ appUpdater.prototype =
     if (this.update)
       return this.update.state == "downloading";
     return this.um.activeUpdate &&
            this.um.activeUpdate.state == "downloading";
   },
 
   // true when updating is disabled by an administrator.
   get updateDisabledAndLocked() {
-    return !this.updateEnabled &&
-           Services.prefs.prefIsLocked("app.update.enabled");
+    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
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -533,16 +533,22 @@ XPCOMUtils.defineLazyGetter(this, "gCanC
   // 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) {