Bug 1487525: Don't reset pending uninstall attribute when disabling theme. r=aswan
☠☠ backed out by 8b3b7ee0fffb ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Thu, 06 Sep 2018 16:52:52 -0700
changeset 436039 a4e3bfaefca5764612e436d1e900ca9fa0620bf8
parent 436038 dcdd547ff76700c4a8aeaee00d645c3a9d3c893a
child 436040 31ff181b5048fb537ac0a6db30f808d982fc897c
push id34625
push userdvarga@mozilla.com
push dateThu, 13 Sep 2018 02:31:40 +0000
treeherdermozilla-central@51e9e9660b3e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1487525
milestone64.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 1487525: Don't reset pending uninstall attribute when disabling theme. r=aswan Differential Revision: https://phabricator.services.mozilla.com/D5218
toolkit/mozapps/extensions/LightweightThemeManager.jsm
toolkit/mozapps/extensions/content/extensions.xml
--- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm
+++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm
@@ -165,16 +165,20 @@ var LightweightThemeManager = {
         } catch (e) {}
       }
     }
 
     return data;
   },
 
   set currentTheme(aData) {
+    _setCurrentTheme(aData, false);
+  },
+
+  setCurrentTheme(aData) {
     return _setCurrentTheme(aData, false);
   },
 
   setLocalTheme(aData) {
     _setCurrentTheme(aData, true);
   },
 
   getUsedTheme(aId) {
@@ -641,32 +645,31 @@ AddonWrapper.prototype = {
     if (_themeIDBeingDisabled == id)
       return true;
 
     let current = LightweightThemeManager.currentTheme;
     return !current || current.id != id;
   },
 
   set userDisabled(val) {
-    if (val == this.userDisabled)
-      return val;
-
-    if (val)
-      LightweightThemeManager.currentTheme = null;
-    else
-      LightweightThemeManager.currentTheme = themeFor(this);
-
-    return val;
+    this.setUserDisabled(val);
   },
 
-  async enable() {
-    this.userDisabled = false;
+  async setUserDisabled(val) {
+    if (val == this.userDisabled)
+      return;
+
+    await LightweightThemeManager.setCurrentTheme(val ? null : themeFor(this));
   },
-  async disable() {
-    this.userDisabled = true;
+
+  enable() {
+    return this.setUserDisabled(false);
+  },
+  disable() {
+    return this.setUserDisabled(true);
   },
 
   // Lightweight themes are never disabled by the application
   get appDisabled() {
     return false;
   },
 
   // Lightweight themes are always compatible
@@ -764,17 +767,17 @@ function _getInternalID(id) {
 }
 
 function _getExternalID(id) {
   if (LightweightThemeManager._builtInThemes.has(id))
     return id;
   return id + ID_SUFFIX;
 }
 
-function _setCurrentTheme(aData, aLocal) {
+async function _setCurrentTheme(aData, aLocal) {
   aData = _sanitizeTheme(aData, null, aLocal);
 
   let cancel = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
   cancel.data = false;
   Services.obs.notifyObservers(cancel, "lightweight-theme-change-requested",
                                JSON.stringify(aData));
 
   let notify = true;
@@ -811,18 +814,18 @@ function _setCurrentTheme(aData, aLocal)
     if (isInstall)
       AddonManagerPrivate.callAddonListeners("onInstalled", wrapper);
   }
 
   if (cancel.data)
     return null;
 
   if (notify) {
-    AddonManagerPrivate.notifyAddonChanged(aData ? _getExternalID(aData.id) : null,
-                                           ADDON_TYPE, false);
+    await AddonManagerPrivate.notifyAddonChanged(aData ? _getExternalID(aData.id) : null,
+                                                 ADDON_TYPE, false);
   }
 
   return LightweightThemeManager.currentTheme;
 }
 
 function _sanitizeTheme(aData, aBaseURI, aLocal) {
   if (!aData || typeof aData != "object")
     return null;
--- a/toolkit/mozapps/extensions/content/extensions.xml
+++ b/toolkit/mozapps/extensions/content/extensions.xml
@@ -1306,20 +1306,20 @@
           // uninstall later.
           if (this.typeHasFlag("SUPPORTS_UNDO_RESTARTLESS_UNINSTALL")) {
             this.mAddon.uninstall(true);
           } else {
             this.setAttribute("wasDisabled", this.mAddon.userDisabled);
 
             // We must set userDisabled to true first, this will call
             // _updateState which will clear any pending attribute set.
-            this.mAddon.disable();
-
-            // This won't update any other add-on manager views (bug 582002)
-            this.setAttribute("pending", "uninstall");
+            this.mAddon.disable().then(() => {
+              // This won't update any other add-on manager views (bug 582002)
+              this.setAttribute("pending", "uninstall");
+            });
           }
         ]]></body>
       </method>
 
       <method name="showPreferences">
         <body><![CDATA[
           gViewController.doCommand("cmd_showItemPreferences", this.mAddon);
         ]]></body>