Closed Bug 1392683 Opened 2 years ago Closed 2 years ago

Use Services.wm instead of importing nsIWindowMediator


(SeaMonkey :: General, enhancement)

Not set


(seamonkey2.53 fixed, seamonkey2.54 fixed)

Tracking Status
seamonkey2.53 --- fixed
seamonkey2.54 --- fixed


(Reporter: frg, Assigned: frg)



(1 file)

+++ This bug was initially created as a clone of Bug #1391640 +++

See Bug 1391640 Comment 2

> There is also window-mediator but that can be another bug.

Most calls in suite import nsIWindowMediator via a variable. This can be simplified by just using Services.wm
Should be good but need to test it first. I didn't bother checking if services.jsm needs to be imported into the download manager tests. They are broken for sure anyway and need to be redone.
Comment on attachment 8899901 [details] [diff] [review]

Test with 2.53 successful.

[Approval Request Comment]
Regression caused by (bug #): --
User impact if declined: none just code cleanup
Testing completed (on m-c, etc.): c-b
Risk to taking this patch (and alternatives if risky): none 2.53 will not be released.
String changes made by this patch: --
Attachment #8899901 - Flags: review?
Attachment #8899901 - Flags: approval-comm-beta?
Comment on attachment 8899901 [details] [diff] [review]

>+++ b/suite/browser/nsBrowserContentHandler.js

> function getMostRecentWindow(aType)
> {
>+  return Services.wm.getMostRecentWindow(aType);
> }
You might as well just git rid of this function and change the callers to use Services.wm

>+++ b/suite/browser/nsBrowserContentListener.js

>-const mediatorContractId = ";1";
Hmmm, wonder when the code that used this existed...

>+++ b/suite/common/src/nsSuiteDownloadManagerUI.js

>   //////////////////////////////////////////////////////////////////////////////
>   //// nsISuiteDownloadManagerUI
>   get recentWindow() {
>-    var wm = Cc[";1"].
>-             getService(Ci.nsIWindowMediator);
>-    return wm.getMostRecentWindow("Download:Manager");
>+    return Services.wm.getMostRecentWindow("Download:Manager");
>   },
Worth removing and just have the callers use Services.wm instead?

There are probably other Services.* that can be spun off into new bugs e.g.
>   var obs = Components.classes[";1"]
>                       .getService(Components.interfaces.nsIObserverService);

r/a=me with those addressed
Attachment #8899901 - Flags: review?
Attachment #8899901 - Flags: review+
Attachment #8899901 - Flags: approval-comm-beta?
Attachment #8899901 - Flags: approval-comm-beta+
Pushed by
User Services.wm instead of importing nsIWindowMediator in SeaMonkey. r=IanN
Closed: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.