Bug 584348 - Update add-on button triggers no action on click/tap event [r=mbrubeck]
authorMark Finkle <mfinkle@mozilla.com>
Wed, 01 Sep 2010 15:13:42 -0400
changeset 1879 4501ce985781be081bbb9ceec51229c29fcce4dd
parent 1878 52227dfa5084166801b9cf77e0b1563ff7f6aa5e
child 1880 3f2893b0c3cf2a0234c05a3379e21a5b453fe35a
push id1662
push usermfinkle@mozilla.com
push dateWed, 01 Sep 2010 19:12:24 +0000
reviewersmbrubeck
bugs584348
Bug 584348 - Update add-on button triggers no action on click/tap event [r=mbrubeck]
app/mobile.js
chrome/content/extensions.js
--- a/app/mobile.js
+++ b/app/mobile.js
@@ -170,23 +170,23 @@ pref("extensions.ignoreMTimeChanges", fa
 pref("extensions.logging.enabled", false);
 pref("extensions.hideInstallButton", true);
 pref("extensions.showMismatchUI", false);
 pref("extensions.hideUpdateButton", false);
 
 pref("extensions.update.url", "https://versioncheck.addons.mozilla.org/update/VersionCheck.php?reqVersion=%REQ_VERSION%&id=%ITEM_ID%&version=%ITEM_VERSION%&maxAppVersion=%ITEM_MAXAPPVERSION%&status=%ITEM_STATUS%&appID=%APP_ID%&appVersion=%APP_VERSION%&appOS=%APP_OS%&appABI=%APP_ABI%&locale=%APP_LOCALE%&currentAppVersion=%CURRENT_APP_VERSION%&updateType=%UPDATE_TYPE%");
 
 /* preferences for the Get Add-ons pane */
-pref("extensions.getAddons.showPane", true);
-pref("extensions.getAddons.browseAddons", "https://addons.mozilla.org/%LOCALE%/mobile/");
+pref("extensions.getAddons.cache.enabled", true);
 pref("extensions.getAddons.maxResults", 5);
 pref("extensions.getAddons.recommended.browseURL", "https://addons.mozilla.org/%LOCALE%/mobile/recommended/");
 pref("extensions.getAddons.recommended.url", "https://services.addons.mozilla.org/%LOCALE%/mobile/api/%API_VERSION%/list/featured/all/10/%OS%/%VERSION%");
 pref("extensions.getAddons.search.browseURL", "https://addons.mozilla.org/%LOCALE%/mobile/search?q=%TERMS%");
 pref("extensions.getAddons.search.url", "https://services.addons.mozilla.org/%LOCALE%/mobile/api/%API_VERSION%/search/%TERMS%/all/10/%OS%/%VERSION%");
+pref("extensions.getAddons.browseAddons", "https://addons.mozilla.org/%LOCALE%/mobile/");
 
 /* blocklist preferences */
 pref("extensions.blocklist.enabled", true);
 pref("extensions.blocklist.interval", 86400);
 pref("extensions.blocklist.url", "https://addons.mozilla.org/blocklist/2/%APP_ID%/%APP_VERSION%/%PRODUCT%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/");
 pref("extensions.blocklist.detailsURL", "https://www.mozilla.com/%LOCALE%/blocklist/");
 
 /* block popups by default, and notify the user about blocked popups */
--- a/chrome/content/extensions.js
+++ b/chrome/content/extensions.js
@@ -275,23 +275,27 @@ var ExtensionsView = {
       this.hideOptions();
   },
 
   getAddonsFromLocal: function ev_getAddonsFromLocal() {
     this.clearSection("local");
 
     let self = this;
     AddonManager.getAddonsByTypes(["extension", "theme", "locale"], function(items) {
+      let anyUpdateable = false;
       for (let i = 0; i < items.length; i++) {
         let addon = items[i];
         let appManaged = (addon.scope == AddonManager.SCOPE_APPLICATION);
         let opType = self._getOpTypeForOperations(addon.pendingOperations);
-        let updateable = (addon.permissions & AddonManager.PERM_CAN_UPDATE) > 0;
+        let updateable = (addon.permissions & AddonManager.PERM_CAN_UPGRADE) > 0;
         let uninstallable = (addon.permissions & AddonManager.PERM_CAN_UNINSTALL) > 0;
 
+        if (updateable)
+          anyUpdateable = true;
+
         let listitem = self._createItem(addon, "local");
         listitem.setAttribute("isDisabled", !addon.isActive);
         listitem.setAttribute("appDisabled", addon.appDisabled);
         listitem.setAttribute("appManaged", appManaged);
         listitem.setAttribute("description", addon.description);
         listitem.setAttribute("optionsURL", addon.optionsURL);
         listitem.setAttribute("opType", opType);
         listitem.setAttribute("updateable", updateable);
@@ -325,20 +329,21 @@ var ExtensionsView = {
         listitem.setAttribute("appManaged", isDefault(engine));
         listitem.setAttribute("description", engine.description || defaultDescription);
         listitem.setAttribute("optionsURL", "");
         listitem.setAttribute("opType", engine.hidden ? "needs-disable" : "");
         listitem.setAttribute("updateable", "false");
         self._list.insertBefore(listitem, self._repoItem);
       }
 
-      if (engines.length + items.length == 0) {
+      if (engines.length + items.length == 0)
         self.displaySectionMessage("local", strings.getString("addonsLocalNone.label"), null, true);
+
+      if (!anyUpdateable)
         document.getElementById("addons-update-all").disabled = true;
-      }
     });
   },
 
   enable: function ev_enable(aItem) {
     let opType;
     if (aItem.getAttribute("type") == "search") {
       aItem.setAttribute("isDisabled", false);
       aItem._engine.hidden = false;
@@ -594,37 +599,41 @@ var ExtensionsView = {
       this._list.selectedItem.focus();
   },
 
   observe: function ev_observe(aSubject, aTopic, aData) {
     if (!document)
       return;
 
     let json = aSubject.QueryInterface(Ci.nsISupportsString).data;
-    let addon = JSON.parse(json);
+    let update = JSON.parse(json);
 
     let strings = Elements.browserBundle;
-    let element = this.getElementForAddon(addon.id);
+    let element = this.getElementForAddon(update.id);
     if (!element)
       return;
 
+    let addon = element.addon;
+
     switch (aTopic) {
       case "addon-update-started":
         element.setAttribute("updateStatus", strings.getString("addonUpdate.checking"));
         break;
       case "addon-update-ended":
         let updateable = false;
         let statusMsg = null;
         switch (aData) {
           case "update":
-            statusMsg = strings.getFormattedString("addonUpdate.updating", [addon.version]);
+            statusMsg = strings.getFormattedString("addonUpdate.updating", [update.version]);
             updateable = true;
             break;
           case "compatibility":
             statusMsg = strings.getString("addonUpdate.compatibility");
+            if (addon.pendingOperations & AddonManager.PENDING_INSTALL || addon.pendingOperations & AddonManager.PENDING_UPGRADE)
+              updateable = true;
             break;
           case "error":
             statusMsg = strings.getString("addonUpdate.error");
             break;
           case "no-update":
             // Ignore if no updated was found. Just let the message go blank.
             //statusMsg = strings.getString("addonUpdate.noupdate");
             break;