Bug 791163 - Add addon-options-displayed/addon-options-hidden as constants on AddonManager. r=Unfocused
authorJulian Muenster <jmuenster@gmail.com>
Thu, 27 Sep 2012 07:42:00 +1200
changeset 115097 cd72779323e1e34ecc4f246db72c3e5f4e1424aa
parent 114704 b5f873f18b9d190a97f126d7a26f5711ea091efa
child 115098 2f2fc4efee8905ea75382a7efcb0b50db3e5e87a
push id1708
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 21:10:21 +0000
treeherdermozilla-beta@27b14fe50103 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersUnfocused
bugs791163
milestone18.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 791163 - Add addon-options-displayed/addon-options-hidden as constants on AddonManager. r=Unfocused
mobile/android/chrome/content/aboutAddons.js
mobile/xul/chrome/content/bindings/extensions.xml
toolkit/mozapps/extensions/AddonManager.jsm
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/test/browser/browser_inlinesettings.js
--- a/mobile/android/chrome/content/aboutAddons.js
+++ b/mobile/android/chrome/content/aboutAddons.js
@@ -281,17 +281,19 @@ var Addons = {
         // Send an event so add-ons can prepopulate any non-preference based
         // settings
         let event = document.createEvent("Events");
         event.initEvent("AddonOptionsLoad", true, false);
         window.dispatchEvent(event);
 
         // Also send a notification to match the behavior of desktop Firefox
         let id = aListItem.getAttribute("addonID");
-        Services.obs.notifyObservers(document, "addon-options-displayed", id);
+        Services.obs.notifyObservers(document,
+                                     AddonManager.OPTIONS_NOTIFICATION_DISPLAYED,
+                                     id);
       }
     } catch (e) {
       Cu.reportError(e)
     }
 
     let list = document.querySelector("#addons-list");
     list.style.display = "none";
     let details = document.querySelector("#addons-details");
--- a/mobile/xul/chrome/content/bindings/extensions.xml
+++ b/mobile/xul/chrome/content/bindings/extensions.xml
@@ -150,17 +150,19 @@
             // Send an event so add-ons can prepopulate any non-preference based
             // settings
             let event = document.createEvent("Events");
             event.initEvent("AddonOptionsLoad", true, false);
             this.dispatchEvent(event);
 
             // Also send a notification to match the behavior of desktop Firefox
             let id = this.id.substring(17); // length of |urn:mozilla:item:|
-            Services.obs.notifyObservers(document, "addon-options-displayed", id);
+            Services.obs.notifyObservers(document,
+                                         AddonManager.OPTIONS_NOTIFICATION_DISPLAYED,
+                                         id);
           ]]>
         </body>
       </method>
     </implementation>
   </binding>
 
   <binding id="extension-searchplugin" extends="chrome://browser/content/bindings.xml#richlistitem">
     <content orient="vertical">
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -2247,16 +2247,22 @@ var AddonManager = {
   // Constants for how Addon options should be shown.
   // Options will be opened in a new window
   OPTIONS_TYPE_DIALOG: 1,
   // Options will be displayed within the AM detail view
   OPTIONS_TYPE_INLINE: 2,
   // Options will be displayed in a new tab, if possible
   OPTIONS_TYPE_TAB: 3,
 
+  // Constants for displayed or hidden options notifications
+  // Options notification will be displayed
+  OPTIONS_NOTIFICATION_DISPLAYED: "addon-options-displayed",
+  // Options notification will be hidden
+  OPTIONS_NOTIFICATION_HIDDEN: "addon-options-hidden",
+
   // Constants for getStartupChanges, addStartupChange and removeStartupChange
   // Add-ons that were detected as installed during startup. Doesn't include
   // add-ons that were pending installation the last time the application ran.
   STARTUP_CHANGE_INSTALLED: "installed",
   // Add-ons that were detected as changed during startup. This includes an
   // add-on moving to a different location, changing version or just having
   // been detected as possibly changed.
   STARTUP_CHANGE_CHANGED: "changed",
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -2724,17 +2724,17 @@ var gDetailView = {
   },
 
   hide: function gDetailView_hide() {
     AddonManager.removeManagerListener(this);
     this.clearLoading();
     if (this._addon) {
       if (this._addon.optionsType == AddonManager.OPTIONS_TYPE_INLINE) {
         Services.obs.notifyObservers(document,
-                                     "addon-options-hidden",
+                                     AddonManager.OPTIONS_NOTIFICATION_HIDDEN,
                                      this._addon.id);
       }
 
       gEventManager.unregisterAddonListener(this, this._addon.id);
       gEventManager.unregisterInstallListener(this);
       this._addon = null;
 
       // Flush the preferences to disk so they survive any crash
@@ -2902,24 +2902,28 @@ var gDetailView = {
 
         // Ensure the page has loaded and force the XBL bindings to be synchronously applied,
         // then notify observers.
         if (gViewController.viewPort.selectedPanel.hasAttribute("loading")) {
           gDetailView.node.addEventListener("ViewChanged", function viewChangedEventListener() {
             gDetailView.node.removeEventListener("ViewChanged", viewChangedEventListener, false);
             if (firstSetting)
               firstSetting.clientTop;
-            Services.obs.notifyObservers(document, "addon-options-displayed", gDetailView._addon.id);
+            Services.obs.notifyObservers(document,
+                                         AddonManager.OPTIONS_NOTIFICATION_DISPLAYED,
+                                         gDetailView._addon.id);
             if (aScrollToPreferences)
               gDetailView.scrollToPreferencesRows();
           }, false);
         } else {
           if (firstSetting)
             firstSetting.clientTop;
-          Services.obs.notifyObservers(document, "addon-options-displayed", this._addon.id);
+          Services.obs.notifyObservers(document,
+                                       AddonManager.OPTIONS_NOTIFICATION_DISPLAYED,
+                                       this._addon.id);
           if (aScrollToPreferences)
             gDetailView.scrollToPreferencesRows();
         }
         if (aCallback)
           aCallback();
       }).bind(this);
       xhr.onerror = function fillSettingsRows_onerror(aEvent) {
         Cu.reportError("Error " + aEvent.target.status +
@@ -2964,17 +2968,17 @@ var gDetailView = {
     this.fillSettingsRows();
   },
 
   onDisabling: function gDetailView_onDisabling(aNeedsRestart) {
     this.updateState();
     if (!aNeedsRestart &&
         this._addon.optionsType == AddonManager.OPTIONS_TYPE_INLINE) {
       Services.obs.notifyObservers(document,
-                                   "addon-options-hidden",
+                                   AddonManager.OPTIONS_NOTIFICATION_HIDDEN,
                                    this._addon.id);
     }
   },
 
   onDisabled: function gDetailView_onDisabled() {
     this.updateState();
     this.emptySettingsRows();
   },
--- a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_inlinesettings.js
@@ -27,33 +27,33 @@ var observer = {
   checkHidden: function(aExpected) {
     is(this.lastHidden, aExpected, "'addon-options-hidden' notification should have fired");
     this.lastHidden = null;
   },
   checkNotHidden: function() {
     is(this.lastHidden, null, "'addon-options-hidden' notification should not have fired");
   },
   observe: function(aSubject, aTopic, aData) {
-    if (aTopic == "addon-options-displayed") {
+    if (aTopic == AddonManager.OPTIONS_NOTIFICATION_DISPLAYED) {
       this.lastDisplayed = aData;
       // Test if the binding has applied before the observers are notified. We test the second setting here,
       // because the code operates on the first setting and we want to check it applies to all.
       var setting = aSubject.querySelector("rows > setting[first-row] ~ setting");
       var input = gManagerWindow.document.getAnonymousElementByAttribute(setting, "class", "preferences-title");
       isnot(input, null, "XBL binding should be applied");
 
       // Add some extra height to the scrolling pane to ensure that it needs to scroll when appropriate.
       gManagerWindow.document.getElementById("detail-controls").style.marginBottom = "1000px";
 
       if (this.callback) {
         var tempCallback = this.callback;
         this.callback = null;
         tempCallback();
       }
-    } else if (aTopic == "addon-options-hidden") {
+    } else if (aTopic == AddonManager.OPTIONS_NOTIFICATION_HIDDEN) {
       this.lastHidden = aData;
     }
   }
 };
 
 function installAddon(aCallback) {
   AddonManager.getInstallForURL(TESTROOT + "addons/browser_inlinesettings1.xpi",
                                 function(aInstall) {
@@ -103,26 +103,31 @@ function test() {
     optionsURL: CHROMEROOT + "addon_prefs.xul"
   }]);
 
   installAddon(function () {
     open_manager("addons://list/extension", function(aWindow) {
       gManagerWindow = aWindow;
       gCategoryUtilities = new CategoryUtilities(gManagerWindow);
 
-      Services.obs.addObserver(observer, "addon-options-displayed", false);
-      Services.obs.addObserver(observer, "addon-options-hidden", false);
+      Services.obs.addObserver(observer,
+                               AddonManager.OPTIONS_NOTIFICATION_DISPLAYED,
+                               false);
+      Services.obs.addObserver(observer,
+                               AddonManager.OPTIONS_NOTIFICATION_HIDDEN,
+                               false);
 
       run_next_test();
     });
   });
 }
 
 function end_test() {
-  Services.obs.removeObserver(observer, "addon-options-displayed");
+  Services.obs.removeObserver(observer,
+                              AddonManager.OPTIONS_NOTIFICATION_DISPLAYED);
 
   Services.prefs.clearUserPref("extensions.inlinesettings1.bool");
   Services.prefs.clearUserPref("extensions.inlinesettings1.boolint");
   Services.prefs.clearUserPref("extensions.inlinesettings1.integer");
   Services.prefs.clearUserPref("extensions.inlinesettings1.string");
   Services.prefs.clearUserPref("extensions.inlinesettings1.color");
   Services.prefs.clearUserPref("extensions.inlinesettings1.file");
   Services.prefs.clearUserPref("extensions.inlinesettings1.directory");
@@ -130,17 +135,18 @@ function end_test() {
   Services.prefs.clearUserPref("extensions.inlinesettings3.radioInt");
   Services.prefs.clearUserPref("extensions.inlinesettings3.radioString");
   Services.prefs.clearUserPref("extensions.inlinesettings3.menulist");
 
   MockFilePicker.cleanup();
 
   close_manager(gManagerWindow, function() {
     observer.checkHidden("inlinesettings2@tests.mozilla.org");
-    Services.obs.removeObserver(observer, "addon-options-hidden");
+    Services.obs.removeObserver(observer,
+                                AddonManager.OPTIONS_NOTIFICATION_HIDDEN);
 
     AddonManager.getAddonByID("inlinesettings1@tests.mozilla.org", function(aAddon) {
       aAddon.uninstall();
       finish();
     });
   });
 }