Closed Bug 1392683 Opened 2 years ago Closed 2 years ago

Use Services.wm instead of importing nsIWindowMediator

Categories

(SeaMonkey :: General, enhancement)

enhancement
Not set

Tracking

(seamonkey2.53 fixed, seamonkey2.54 fixed)

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

People

(Reporter: frg, Assigned: frg)

Details

Attachments

(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]
1392683-nsIWindowMediator.patch

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]
1392683-nsIWindowMediator.patch

>+++ 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 = "@mozilla.org/appshell/window-mediator;1";
Hmmm, wonder when the code that used this existed...

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

>   //////////////////////////////////////////////////////////////////////////////
>   //// nsISuiteDownloadManagerUI
> 
>   get recentWindow() {
>-    var wm = Cc["@mozilla.org/appshell/window-mediator;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["@mozilla.org/observer-service;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 frgrahl@gmx.net:
https://hg.mozilla.org/comm-central/rev/b5d2c9e0f64f
User Services.wm instead of importing nsIWindowMediator in SeaMonkey. r=IanN
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.