Bug 1391640 - User Services.ww instead of importing nsIWindowWatcher in SeaMonkey. r=IanN a=IanN
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Tue, 22 Aug 2017 16:43:58 +0200
changeset 28573 3ff41a9307b174cfd180c05fbe5efea749b96018
parent 28570 9fa8a268697b96ce2ce2d07d4b90f2b869b87659
child 28574 cae4a03560b330f4a7b20e0e838b9a1e58735944
push idunknown
push userunknown
push dateunknown
reviewersIanN, IanN
bugs1391640
Bug 1391640 - User Services.ww instead of importing nsIWindowWatcher in SeaMonkey. r=IanN a=IanN
suite/browser/nsBrowserContentHandler.js
suite/browser/nsTypeAheadFind.js
suite/common/bindings/prefwindow.xml
suite/common/console/jsconsole-clhandler.js
suite/common/helpviewer/contextHelp.js
suite/common/src/nsSuiteDownloadManagerUI.js
suite/mailnews/modules/MailUtils.js
suite/modules/Sanitizer.jsm
--- a/suite/browser/nsBrowserContentHandler.js
+++ b/suite/browser/nsBrowserContentHandler.js
@@ -21,17 +21,16 @@ const nsIHttpProtocolHandler  = Componen
 const nsINetUtil              = Components.interfaces.nsINetUtil;
 const nsIIOService            = Components.interfaces.nsIIOService;
 const nsIPrefService          = Components.interfaces.nsIPrefService;
 const nsIPrefBranch           = Components.interfaces.nsIPrefBranch;
 const nsIPrefLocalizedString  = Components.interfaces.nsIPrefLocalizedString;
 const nsISupportsString       = Components.interfaces.nsISupportsString;
 const nsIURIFixup             = Components.interfaces.nsIURIFixup;
 const nsIWindowMediator       = Components.interfaces.nsIWindowMediator;
-const nsIWindowWatcher        = Components.interfaces.nsIWindowWatcher;
 const nsIWebNavigationInfo    = Components.interfaces.nsIWebNavigationInfo;
 
 const NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001;
 
 const URI_INHERITS_SECURITY_CONTEXT = nsIHttpProtocolHandler
                                         .URI_INHERITS_SECURITY_CONTEXT;
 
 const NS_GENERAL_STARTUP_PREFIX = "@mozilla.org/commandlinehandler/general-startup;1?type=";
@@ -158,22 +157,20 @@ function getURLToLoad()
   } catch (e) {
   }
 
   return "about:blank";
 }
 
 function openWindow(parent, url, features, arg)
 {
-  var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
-                         .getService(nsIWindowWatcher);
   var argstring = Components.classes["@mozilla.org/supports-string;1"]
                             .createInstance(nsISupportsString);
   argstring.data = arg;
-  return wwatch.openWindow(parent, url, "", features, argstring);
+  return Services.ww.openWindow(parent, url, "", features, argstring);
 }
 
 function openPreferences()
 {
   var win = getMostRecentWindow("mozilla:preferences");
   if (win)
     win.focus();
   else
@@ -226,20 +223,18 @@ function doSearch(aSearchTerm, aFeatures
 
   sa.appendElement(uristring, false);
   sa.appendElement(null, false);
   sa.appendElement(null, false);
   sa.appendElement(submission.postData, false);
 
   // XXXbsmedberg: use handURIToExistingBrowser to obey tabbed-browsing
   // preferences, but need nsIBrowserDOMWindow extensions
-  var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
-                         .getService(nsIWindowWatcher);
-
-  return wwatch.openWindow(null, getBrowserURL(), "_blank", aFeatures, sa);
+  return Services.ww.openWindow(null, getBrowserURL(), "_blank", aFeatures,
+                                sa);
 }
 
 var nsBrowserContentHandler = {
   get wrappedJSObject() {
     return this;
   },
 
   /* nsISupports */
--- a/suite/browser/nsTypeAheadFind.js
+++ b/suite/browser/nsTypeAheadFind.js
@@ -74,19 +74,17 @@ typeAheadFind.prototype = {
       Components.interfaces.nsISelectionListener]),
 
   /* nsIObserver */
   observe: function(aSubject, aTopic, aData) {
     if (aTopic == "app-startup") {
       // It's now safe to get our pref branch.
       this.mPrefs = Services.prefs.getBranch("accessibility.typeaheadfind.");
       // We need to add our event listeners to all windows.
-      Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
-                .getService(Components.interfaces.nsIWindowWatcher)
-                .registerNotification(this);
+      Services.ww.registerNotification(this);
       // We also need to listen for find again commands
       Components.classes["@mozilla.org/observer-service;1"]
                 .getService(Components.interfaces.nsIObserverService)
                 .addObserver(this, "nsWebBrowserFind_FindAgain", true);
     }
     if (aTopic == "domwindowopened") {
       // Add our listeners. They get automatically removed on window teardown.
       aSubject.controllers.appendController(new findTypeController(this, aSubject));
--- a/suite/common/bindings/prefwindow.xml
+++ b/suite/common/bindings/prefwindow.xml
@@ -113,16 +113,18 @@
       <xul:hbox>
         <children/>
       </xul:hbox>
     </content>
 
     <implementation>
       <constructor>
         <![CDATA[
+          Components.utils.import("resource://gre/modules/Services.jsm");
+
           // grab the first child tree and try to tie it to the prefpanes
           var tree = this.getElementsByTagName('tree')[0];
           this.initNavigationTree(tree);
           // hide the toolkit pref strip if we have a tree
           if (this._navigationTree)
             this._selector.hidden = true;
         ]]>
       </constructor>
@@ -434,19 +436,21 @@
           else
           {
             // Open topic in new window.
             const params = Components.classes["@mozilla.org/embedcomp/dialogparam;1"]
                                      .createInstance(Components.interfaces.nsIDialogParamBlock);
             params.SetNumberStrings(2);
             params.SetString(0, helpFileURI);
             params.SetString(1, topic);
-            const ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
-                                 .getService(Components.interfaces.nsIWindowWatcher);
-            ww.openWindow(null, "chrome://help/content/help.xul", "_blank", "chrome,all,alwaysRaised,dialog=no", params);
+            Services.ww.openWindow(null,
+                                   "chrome://help/content/help.xul",
+                                   "_blank", 
+                                   "chrome,all,alwaysRaised,dialog=no",
+                                   params);
           }
         ]]>
         </body>
       </method>
     </implementation>
 
     <handlers>
       <handler event="dialoghelp">
--- a/suite/common/console/jsconsole-clhandler.js
+++ b/suite/common/console/jsconsole-clhandler.js
@@ -1,31 +1,31 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/Services.jsm");
 
 function jsConsoleHandler() {}
 jsConsoleHandler.prototype = {
   handle: function clh_handle(cmdLine) {
     if (!cmdLine.handleFlag("suiteconsole", false))
       return;
 
     var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
              getService(Ci.nsIWindowMediator);
     var console = wm.getMostRecentWindow("suite:console");
     if (!console) {
-      var wwatch = Cc["@mozilla.org/embedcomp/window-watcher;1"].
-                   getService(Ci.nsIWindowWatcher);
-      wwatch.openWindow(null, "chrome://communicator/content/console/console.xul", 
-                        "_blank", "chrome,dialog=no,all", cmdLine);
+      Services.ww.openWindow(null,
+        "chrome://communicator/content/console/console.xul", 
+        "_blank", "chrome,dialog=no,all", cmdLine);
     } else {
       console.focus(); // the Error console was already open
     }
 
     if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO)
       cmdLine.preventDefault = true;
   },
 
--- a/suite/common/helpviewer/contextHelp.js
+++ b/suite/common/helpviewer/contextHelp.js
@@ -1,12 +1,14 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
+Components.utils.import("resource://gre/modules/Services.jsm");
+
 # Set the default content pack to the Mozilla content pack. Use the
 # setHelpFileURI function to set this value.
 var helpFileURI;
 
 # openHelp - Opens up the Mozilla Help Viewer with the specified
 #    topic and content pack.
 # see http://www.mozilla.org/projects/help-viewer/content_packs.html
 function openHelp(topic, contentPack)
@@ -24,25 +26,25 @@ function openHelp(topic, contentPack)
     topWindow.displayTopic(topic);
   } else {
 # Open topic in new window.
     const params = Components.classes["@mozilla.org/embedcomp/dialogparam;1"]
                              .createInstance(Components.interfaces.nsIDialogParamBlock);
     params.SetNumberStrings(2);
     params.SetString(0, helpFileURI);
     params.SetString(1, topic);
-    const ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
-                         .getService(Components.interfaces.nsIWindowWatcher);
 #ifdef XP_WIN
 #define HELP_ALWAYS_RAISED_TOGGLE
 #endif
 #ifdef HELP_ALWAYS_RAISED_TOGGLE
-    ww.openWindow(null, "chrome://help/content/help.xul", "_blank", "chrome,all,alwaysRaised,dialog=no", params);
+    Services.ww.openWindow(null, "chrome://help/content/help.xul", "_blank",
+                           "chrome,all,alwaysRaised,dialog=no", params);
 #else
-    ww.openWindow(null, "chrome://help/content/help.xul", "_blank", "chrome,all,dialog=no", params);
+    Services.ww.openWindow(null, "chrome://help/content/help.xul", "_blank",
+                           "chrome,all,dialog=no", params);
 #endif
   }
 }
 
 # setHelpFileURI - Sets the default content pack to use in the Help Viewer
 function setHelpFileURI(rdfURI)
 {
   helpFileURI = rdfURI;
--- a/suite/common/src/nsSuiteDownloadManagerUI.js
+++ b/suite/common/src/nsSuiteDownloadManagerUI.js
@@ -115,23 +115,21 @@ nsDownloadManagerUI.prototype = {
     params.appendElement(reason, false);
 
     var manager = DOWNLOAD_MANAGER_URL;
     try {
       if (Services.prefs.getBoolPref(PREF_FORCE_TOOLKIT_UI))
         manager = TOOLKIT_MANAGER_URL;
     } catch(ex) {}
 
-    var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
-             getService(Ci.nsIWindowWatcher);
-    ww.openWindow(parent,
-                  manager,
-                  null,
-                  "all,dialog=no",
-                  params);
+    Services.ww.openWindow(parent,
+                           manager,
+                           null,
+                           "all,dialog=no",
+                           params);
   },
 
   showProgress: function showProgress(aWindowContext, aDownload, aReason)
   {
     // Fail if our passed in download is invalid
     if (!aDownload)
       return;
 
@@ -148,23 +146,21 @@ nsDownloadManagerUI.prototype = {
     params.appendElement(aDownload, false);
 
     // Pass in the reason as well
     let reason = Cc["@mozilla.org/supports-PRInt16;1"].
                  createInstance(Ci.nsISupportsPRInt16);
     reason.data = aReason;
     params.appendElement(reason, false);
 
-    var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
-             getService(Ci.nsIWindowWatcher);
-    ww.openWindow(parent,
-                  "chrome://communicator/content/downloads/progressDialog.xul",
-                  null,
-                  "chrome,titlebar,centerscreen,minimizable=yes,dialog=no",
-                  params);
+    Services.ww.openWindow(parent,
+      "chrome://communicator/content/downloads/progressDialog.xul",
+      null,
+      "chrome,titlebar,centerscreen,minimizable=yes,dialog=no",
+      params);
   },
   //////////////////////////////////////////////////////////////////////////////
   //// nsISupports
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIDownloadManagerUI,
                                          Ci.nsISuiteDownloadManagerUI])
 };
 
--- a/suite/mailnews/modules/MailUtils.js
+++ b/suite/mailnews/modules/MailUtils.js
@@ -3,16 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var EXPORTED_SYMBOLS = ["MailUtils"];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 Components.utils.import("resource:///modules/iteratorUtils.jsm");
+Components.utils.import("resource://gre/modules/Services.jsm");
 
 /**
  * This module has several utility functions for use by both core and
  * third-party code. Some functions are aimed at code that doesn't have a
  * window context, while others can be used anywhere.
  */
 var MailUtils =
 {
@@ -79,15 +80,15 @@ var MailUtils =
    */
   openMessageInNewWindow: function MailUtils_openMessageInNewWindow(aMsgHdr)
   {
     // Pass in the message URI as messageWindow.js doesn't handle message headers
     let messageURI = Cc["@mozilla.org/supports-string;1"]
                        .createInstance(Ci.nsISupportsString);
     messageURI.data = aMsgHdr.folder.getUriForMsg(aMsgHdr);
 
-    let windowWatcher = Cc["@mozilla.org/embedcomp/window-watcher;1"]
-                          .getService(Ci.nsIWindowWatcher);
-    windowWatcher.openWindow(null,
-        "chrome://messenger/content/messageWindow.xul", "_blank",
-        "all,chrome,dialog=no,status,toolbar", messageURI);
+    Services.ww.openWindow(null,
+                           "chrome://messenger/content/messageWindow.xul",
+                           "_blank",
+                           "all,chrome,dialog=no,status,toolbar",
+                           messageURI);
   }
 };
--- a/suite/modules/Sanitizer.jsm
+++ b/suite/modules/Sanitizer.jsm
@@ -36,24 +36,24 @@ var Sanitizer = {
   readSettings: function(aParentWindow) {
     var itemPrefs = Services.prefs.getBranch("privacy.item.");
     for (var itemName in this.items) {
       var item = this.items[itemName];
       if ("clear" in item)
         item.willClear = itemPrefs.getBoolPref(itemName);
     }
     if (this._prefs.getBoolPref("promptOnSanitize")) {
-      var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
-                         .getService(Components.interfaces.nsIWindowWatcher);
       // make this an app-modal window on Mac.
       var win = "nsILocalFileMac" in Components.interfaces ? null
                                                            : aParentWindow;
-      ww.openWindow(win,
-                    "chrome://communicator/content/sanitize.xul", "Sanitize",
-                    "chrome,titlebar,centerscreen,dialog,modal", null);
+      Services.ww.openWindow(win,
+                             "chrome://communicator/content/sanitize.xul",
+                             "Sanitize",
+                             "chrome,titlebar,centerscreen,dialog,modal",
+                             null);
     }
   },
 
   doPendingSanitize: function() {
     // do the actual sanitizing
     var errors = null;
     for (var itemName in this.items) {
       var item = this.items[itemName];