Bug 612884 - Doesn't open Add-ons Manager tab when click [Manage Add-ons...]button in Options dialog; r=Standard8
authorJim <squibblyflabbetydoo@gmail.com>
Wed, 09 Mar 2011 09:25:47 +0000
changeset 7288 95afb3f1f6c98a114ff39567587267aa353b8100
parent 7287 0347b42406e647d88d4ebfe55444f2f3c334ddd3
child 7289 dec310aab8deb9a09c63627dfa4f586a2e3fbf2f
push idunknown
push userunknown
push dateunknown
reviewersStandard8
bugs612884
Bug 612884 - Doesn't open Add-ons Manager tab when click [Manage Add-ons...]button in Options dialog; r=Standard8
mail/base/content/mailCore.js
mail/base/content/utilityOverlay.js
mail/components/preferences/general.js
mail/components/preferences/general.xul
--- a/mail/base/content/mailCore.js
+++ b/mail/base/content/mailCore.js
@@ -412,17 +412,17 @@ function openAddonsMgr(aView)
       emWindow.loadView(aView);
       let tabmail = browserWindow.document.getElementById("tabmail");
       tabmail.switchToTab(tabmail.getBrowserForDocument(emWindow));
       emWindow.focus();
       return;
     }
   }
 
-  openContentTab("about:addons", "addons.mozilla.org");
+  openContentTab("about:addons", "tab", "addons.mozilla.org");
 
   if (aView) {
     // This must be a new load, else the ping/pong would have
     // found the window above.
     Services.obs.addObserver(function (aSubject, aTopic, aData) {
         Services.obs.removeObserver(arguments.callee, aTopic);
         aSubject.loadView(aView);
       }, "EM-loaded", false);
--- a/mail/base/content/utilityOverlay.js
+++ b/mail/base/content/utilityOverlay.js
@@ -313,41 +313,57 @@ function openWhatsNew()
   let startpage =
     Components.classes["@mozilla.org/toolkit/URLFormatterService;1"]
               .getService(Components.interfaces.nsIURLFormatter)
               .formatURLPref("mailnews.start_page.override_url");
 
   openContentTab(startpage);
 }
 
-function openContentTab(url, handlerRegExp)
+/**
+ * Open the specified URL as a content tab (or window)
+ *
+ * @param url the location to open
+ * @param where 'tab' to open in a new tab (default) or 'window' to open in a
+ *        new window
+ * @param handlerRegExp a regular expression (as a string) to use for the
+ *        siteClickHandler for determining whether a link should be opened in
+ *        Thunderbird or passed to the system
+ */
+function openContentTab(url, where, handlerRegExp)
 {
-  let tabmail = document.getElementById("tabmail");
-  if (!tabmail) {
-    // Try opening new tabs in an existing 3pane window
-    let mail3PaneWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"]
-                                    .getService(Components.interfaces.nsIWindowMediator)
-                                    .getMostRecentWindow("mail:3pane");
-    if (mail3PaneWindow) {
-      tabmail = mail3PaneWindow.document.getElementById("tabmail");
-      mail3PaneWindow.focus();
-    }
-  }
-
   let clickHandler = null;
   if (handlerRegExp)
     clickHandler = "specialTabs.siteClickHandler(event, new RegExp(\"" + handlerRegExp + "\"));";
 
-  if (tabmail)
-    tabmail.openTab("contentTab", {contentPage: url, clickHandler: clickHandler});
-  else
-    window.openDialog("chrome://messenger/content/", "_blank",
-                      "chrome,dialog=no,all", null,
-                      { tabType: "contentTab",
-                        tabParams: {contentPage: url, clickHandler: clickHandler} });
+  if (where != "window") {
+    let tabmail = document.getElementById("tabmail");
+    if (!tabmail) {
+      // Try opening new tabs in an existing 3pane window
+      let mail3PaneWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"]
+                                      .getService(Components.interfaces.nsIWindowMediator)
+                                      .getMostRecentWindow("mail:3pane");
+      if (mail3PaneWindow) {
+        tabmail = mail3PaneWindow.document.getElementById("tabmail");
+        mail3PaneWindow.focus();
+      }
+    }
+
+    if (tabmail) {
+      tabmail.openTab("contentTab", {contentPage: url, clickHandler: clickHandler});
+      return;
+    }
+  }
+
+  // Either we explicitly wanted to open in a new window, or we fell through to
+  // here because there's no 3pane.
+  window.openDialog("chrome://messenger/content/", "_blank",
+                    "chrome,dialog=no,all", null,
+                    { tabType: "contentTab",
+                      tabParams: {contentPage: url, clickHandler: clickHandler} });
 }
 
 /**
  * Open the Migration Assistant.
  *
  * @param aIsUpgrade whether this is being opened as a result of upgrading
  *     from an earlier version of Thunderbird.
  */
--- a/mail/components/preferences/general.js
+++ b/mail/components/preferences/general.js
@@ -172,23 +172,11 @@ var gGeneralPane = {
     document.getElementById('playSound').disabled = soundsDisabled || soundTypeEl.value != 1; 
   },
 
   /**
    * Displays the Add-ons Manager.
    */
   showAddonsMgr: function ()
   {
-    const EMTYPE = "Extension:Manager";
-    var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
-                       .getService(Components.interfaces.nsIWindowMediator);
-    var theEM = wm.getMostRecentWindow(EMTYPE);
-    if (theEM) {
-      theEM.focus();
-      theEM.showView("extensions");
-      return;
-    }
-
-    const EMURL = "chrome://mozapps/content/extensions/extensions.xul";
-    const EMFEATURES = "chrome,menubar,extra-chrome,toolbar,dialog=no,resizable";
-    window.openDialog(EMURL, "", EMFEATURES, "extensions");
+    openContentTab("about:addons", "window", "addons.mozilla.org");
   }
 };
--- a/mail/components/preferences/general.xul
+++ b/mail/components/preferences/general.xul
@@ -43,16 +43,17 @@
 <!ENTITY % generalDTD SYSTEM "chrome://messenger/locale/preferences/general.dtd" >
 %generalDTD;
 ]>
 
 <overlay id="GeneralPaneOverlay"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <prefpane id="paneGeneral" onpaneload="gGeneralPane.init();">
+    <script type="application/javascript" src="chrome://communicator/content/utilityOverlay.js"/>
     <script type="application/javascript" src="chrome://messenger/content/preferences/general.js"/>
 
     <preferences id="generalPreferences">
       <preference id="mail.pane_config.dynamic" name="mail.pane_config.dynamic" type="int"/>
       <preference id="mailnews.reuse_message_window" name="mailnews.reuse_message_window" type="bool"/>
       <preference id="mailnews.start_page.enabled" name="mailnews.start_page.enabled" type="bool"/>
       <preference id="mailnews.start_page.url" name="mailnews.start_page.url" type="string"/>
       <preference id="mail.biff.show_alert" name="mail.biff.show_alert" type="bool"/>