Bug 735874 - (2/2) Show/hide the options when an add-on is enabled/disabled [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Wed, 14 Mar 2012 15:31:21 -0700
changeset 89412 60c732729b692b24b3ac339c95296a8d64cd0ca1
parent 89411 4b9a25a297c99a13a5711a011bfaa6078be1f943
child 89413 495ed7337159db0d42eb631caf91f96bb3c68dba
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmfinkle
bugs735874
milestone14.0a1
Bug 735874 - (2/2) Show/hide the options when an add-on is enabled/disabled [r=mfinkle]
mobile/android/chrome/content/aboutAddons.js
mobile/android/themes/core/aboutAddons.css
--- a/mobile/android/chrome/content/aboutAddons.js
+++ b/mobile/android/chrome/content/aboutAddons.js
@@ -23,23 +23,25 @@ XPCOMUtils.defineLazyGetter(window, "gCh
 
 XPCOMUtils.defineLazyGetter(window, "SelectHelper", function() gChromeWin.SelectHelper);
 
 function init() {
   window.addEventListener("popstate", onPopState, false);
   Services.obs.addObserver(Addons, "browser-search-engine-modified", false);
 
   AddonManager.addInstallListener(Addons);
+  AddonManager.addAddonListener(Addons);
   Addons.getAddons();
   showList();
 }
 
 function uninit() {
   Services.obs.removeObserver(Addons, "browser-search-engine-modified");
   AddonManager.removeInstallListener(Addons);
+  AddonManager.removeAddonListener(Addons);
 }
 
 function openLink(aElement) {
   try {
     let formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].getService(Ci.nsIURLFormatter);
     let url = formatter.formatURLPref(aElement.getAttribute("pref"));
     let BrowserApp = gChromeWin.BrowserApp;
     BrowserApp.addTab(url, { selected: true, parentId: BrowserApp.selectedTab.id });
@@ -415,16 +417,28 @@ var Addons = {
   showRestart: function showRestart(aMode) {
     // TODO (bug 704406)
   },
 
   hideRestart: function hideRestart(aMode) {
     // TODO (bug 704406)
   },
 
+  onEnabled: function(aAddon) {
+    let listItem = this._getElementForAddon(aAddon.id);
+    if (!listItem)
+      return;
+
+    // Reload the details to pick up any options now that it's enabled.
+    listItem.setAttribute("optionsURL", aAddon.optionsURL || "");
+    let detailItem = document.querySelector("#addons-details > .addon-item");
+    if (aAddon == detailItem.addon)
+      this.showDetails(listItem);
+  },
+
   onInstallEnded: function(aInstall, aAddon) {
     let needsRestart = false;
     if (aInstall.existingAddon && (aInstall.existingAddon.pendingOperations & AddonManager.PENDING_UPGRADE))
       needsRestart = true;
     else if (aAddon.pendingOperations & AddonManager.PENDING_INSTALL)
       needsRestart = true;
 
     let list = document.getElementById("addons-list");
--- a/mobile/android/themes/core/aboutAddons.css
+++ b/mobile/android/themes/core/aboutAddons.css
@@ -174,18 +174,20 @@ body[dir="ltr"] .favicon {
   font-weight: bold;
   padding: 18px 24px;
 }
 
 .options-box {
   margin: 0 12px;
 }
 
+.addon-item[isDisabled="true"] .options-header,
 .addon-item:not([optionsURL]) .options-header,
 .addon-item[optionsURL=""] .options-header,
+.addon-item[isDisabled="true"] .options-box,
 .addon-item:not([optionsURL]) .options-box,
 .addon-item[optionsURL=""] .options-box {
   display: none;
 }
 
 setting {
   padding: 18px 12px;
   border-top: 2px solid;