Bug 1255354 Create options to open the data manager and the addon manager in standalone windows instead of a browser tab. r=IanN
authorPhilip Chee <philip.chee@gmail.com>
Tue, 29 Mar 2016 02:18:18 +0800
changeset 24714 cb5924f366e5a79ec2457fdbce3e9d49e377f3eb
parent 24713 2738399062904a73b1de05fd351584286f849c76
child 24715 c418220f682f5d1ddb87dc42994b8813077f218b
push id1657
push userclokep@gmail.com
push dateMon, 06 Jun 2016 19:50:21 +0000
treeherdercomm-beta@9fac989284b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN
bugs1255354
Bug 1255354 Create options to open the data manager and the addon manager in standalone windows instead of a browser tab. r=IanN
suite/browser/browser-prefs.js
suite/common/dataman/dataman.js
suite/common/dataman/dataman.xul
suite/common/tasksOverlay.js
suite/mailnews/mailTasksOverlay.js
--- a/suite/browser/browser-prefs.js
+++ b/suite/browser/browser-prefs.js
@@ -316,16 +316,19 @@ pref("browser.zoom.siteSpecific", true);
 // once they come to the foreground (i.e. get activated).
 pref("browser.zoom.updateBackgroundTabs", true);
 
 // Zoom levels for View > Zoom and Ctrl +/- keyboard shortcuts
 pref("toolkit.zoomManager.zoomValues", "0.5,0.67,0.8,0.9,1,1.1,1.2,1.33,1.5,1.7,2,2.4");
 
 pref("javascript.options.showInConsole",    true);
 
+pref("suite.manager.addons.openAsDialog", false);
+pref("suite.manager.dataman.openAsDialog", true);
+
 pref("offline.startup_state",            0);
 pref("offline.send.unsent_messages",            0);
 pref("offline.download.download_messages",  0);
 
 // allow offline web apps to store data but ask for permission by default
 pref("offline-apps.allow_by_default", false);
 pref("browser.offline-apps.notify", true);
 
--- a/suite/common/dataman/dataman.js
+++ b/suite/common/dataman/dataman.js
@@ -62,16 +62,22 @@ var gDataman = {
     Services.obs.addObserver(this, "dom-storage-changed", false);
     Services.obs.addObserver(this, "dom-storage2-changed", false);
 
     this.timer = Components.classes["@mozilla.org/timer;1"]
                            .createInstance(Components.interfaces.nsITimer);
 
     gTabs.initialize();
     gDomains.initialize();
+
+    if ("arguments" in window &&
+        window.arguments.length >= 1 &&
+        window.arguments[0]) {
+      this.loadView(window.arguments[0])
+    }
   },
 
   shutdown: function dataman_shutdown() {
     Services.obs.removeObserver(this, "cookie-changed");
     Services.obs.removeObserver(this, "perm-changed");
     Services.obs.removeObserver(this, "passwordmgr-storage-changed");
     Services.contentPrefs.removeObserver(null, this);
     Services.obs.removeObserver(this, "satchel-storage-changed");
--- a/suite/common/dataman/dataman.xul
+++ b/suite/common/dataman/dataman.xul
@@ -12,19 +12,21 @@
 %brandDTD;
 <!ENTITY % datamanDTD SYSTEM "chrome://communicator/locale/dataman/dataman.dtd">
 %datamanDTD;
 ]>
 
 <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
       xmlns:xhtml="http://www.w3.org/1999/xhtml"
       id="dataman-page" title="&dataman.windowTitle;"
+      windowtype="data:manager"
       onload="gDataman.initialize();"
       onunload="gDataman.shutdown();"
-      onkeypress="gDataman.handleKeyPress(event);">
+      onkeypress="gDataman.handleKeyPress(event);"
+      persist="screenX screenY width height sizemode">
 
   <xhtml:link rel="shortcut icon"
               href="chrome://communicator/skin/dataman/datamanIcon-16.png"/>
 
   <script type="application/javascript"
           src="chrome://communicator/content/dataman/dataman.js"/>
 
   <stringbundleset id="datamanBundleSet">
--- a/suite/common/tasksOverlay.js
+++ b/suite/common/tasksOverlay.js
@@ -35,24 +35,45 @@ function toDownloadManager()
     dlUI.showManager(window);
   } else {
     dlUI.show(window);
   }
 }
 
 function toDataManager(aView)
 {
+  var useDlg = Services.prefs.getBoolPref("suite.manager.dataman.openAsDialog");
+
+  if (useDlg) {
+    var url = "chrome://communicator/content/dataman/dataman.xul";
+    var win = toOpenWindowByType("data:manager", url, "", aView);
+    if (win && aView)
+      win.gDataman.loadView(aView);
+    return;
+  }
+
   switchToTabHavingURI("about:data", true, function(browser) {
     if (aView)
       browser.contentWindow.wrappedJSObject.gDataman.loadView(aView);
   });
 }
 
 function toEM(aView)
 {
+  var useDlg = Services.prefs.getBoolPref("suite.manager.addons.openAsDialog");
+
+  if (useDlg) {
+    var view = aView ? { view: aView } : null;
+    var url = "chrome://mozapps/content/extensions/extensions.xul";
+    var win = toOpenWindowByType("Addons:Manager", url, "", view);
+    if (win && aView)
+      win.loadView(aView);
+    return;
+  }
+
   switchToTabHavingURI("about:addons", true, function(browser) {
     if (aView)
       browser.contentWindow.wrappedJSObject.loadView(aView);
   });
 }
 
 function toBookmarksManager()
 {
@@ -71,41 +92,47 @@ function toOpenWindow( aWindow )
     // Try to focus the previously focused window e.g. message compose body
     aWindow.document.commandDispatcher.focusedWindow.focus();
   } catch (e) {
     // e.g. full-page plugin or non-XUL document; just raise the top window
     aWindow.focus();
   }
 }
 
-function toOpenWindowByType( inType, uri, features )
+function toOpenWindowByType(inType, uri, features, args)
 {
   // don't do several loads in parallel
   if (uri in window)
     return;
 
   var topWindow = Services.wm.getMostRecentWindow(inType);
   if ( topWindow )
+  {
     toOpenWindow( topWindow );
+    return topWindow;
+  }
   else
   {
     // open the requested window, but block it until it's fully loaded
     function newWindowLoaded(event)
     {
       // make sure that this handler is called only once
       window.removeEventListener("unload", newWindowLoaded, false);
       window[uri].removeEventListener("load", newWindowLoaded, false);
       delete window[uri];
     }
     // remember the newly loading window until it's fully loaded
     // or until the current window passes away
-    window[uri] = openDialog(uri, "", features || "non-private,all,dialog=no");
+    window[uri] = openDialog(uri, "",
+                             features || "non-private,all,dialog=no",
+                             args || null);
     window[uri].addEventListener("load", newWindowLoaded, false);
     window.addEventListener("unload", newWindowLoaded, false);
   }
+  return;
 }
 
 function OpenBrowserWindow()
 {
   var win = Services.wm.getMostRecentWindow("navigator:browser");
   if (document.documentElement.getAttribute("windowtype") ==
       "navigator:browser" && window.content && window.content.document)
   {
--- a/suite/mailnews/mailTasksOverlay.js
+++ b/suite/mailnews/mailTasksOverlay.js
@@ -6,17 +6,17 @@
 const BIFF_TOPIC = "mail:biff-state-changed";
 
 // biff state constants used by themes
 const BIFF_STATE_MESSAGES   = "NewMail";
 const BIFF_STATE_NOMESSAGES = "NoMail";
 const BIFF_STATE_UNKNOWN    = "UnknownMail";
 
 
-// uses "toOpenWindowByType" function provided by utilityOverlay.js
+// uses "toOpenWindowByType" function provided by tasksOverlay.js
 // which is included by most clients. 
 function toMessengerWindow()
 {
   toOpenWindowByType("mail:3pane", "chrome://messenger/content/");
 }
 
 function toAddressBook() 
 {