[Pkg-mozext-commits] [requestpolicy] 201/257: [ref] rpService: factor out "getMostRecentBrowserWindow()"

David Prévot taffit at moszumanska.debian.org
Thu Jan 28 03:20:13 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository requestpolicy.

commit 4c8d72274384a4408170ef2350656fe22252b108
Author: Martin Kimmerle <dev at 256k.de>
Date:   Sun Dec 6 12:58:20 2015 +0100

    [ref] rpService: factor out "getMostRecentBrowserWindow()"
---
 src/content/lib/utils/windows.jsm          |  9 +++++++++
 src/content/main/requestpolicy-service.jsm | 14 +++++---------
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/content/lib/utils/windows.jsm b/src/content/lib/utils/windows.jsm
index 2daffb2..367fa79 100644
--- a/src/content/lib/utils/windows.jsm
+++ b/src/content/lib/utils/windows.jsm
@@ -38,6 +38,15 @@ let {rpPrefBranch} = importModule("lib/prefs");
 var WindowUtils = (function() {
   let self = {};
 
+  self.getMostRecentWindow = function(aWindowType = null) {
+    let wm = Cc["@mozilla.org/appshell/window-mediator;1"].
+        getService(Ci.nsIWindowMediator);
+    return wm.getMostRecentWindow(aWindowType);
+  };
+
+  self.getMostRecentBrowserWindow = self.getMostRecentWindow.
+                                    bind(self, "navigator:browser");
+
   self.getChromeWindow = function(aContentWindow) {
     return aContentWindow.top.QueryInterface(Ci.nsIInterfaceRequestor)
                              .getInterface(Ci.nsIWebNavigation)
diff --git a/src/content/main/requestpolicy-service.jsm b/src/content/main/requestpolicy-service.jsm
index 7f20048..321b21d 100644
--- a/src/content/main/requestpolicy-service.jsm
+++ b/src/content/main/requestpolicy-service.jsm
@@ -39,6 +39,7 @@ let {UserSubscriptions, SUBSCRIPTION_UPDATED_TOPIC, SUBSCRIPTION_ADDED_TOPIC,
      SUBSCRIPTION_REMOVED_TOPIC} = importModule("lib/subscription");
 let {C} = importModule("lib/utils/constants");
 let {Environment, ProcessEnvironment} = importModule("lib/environment");
+let {WindowUtils} = importModule("lib/utils/windows");
 
 //==============================================================================
 // rpService
@@ -98,19 +99,14 @@ var rpService = (function() {
     if (!rpPrefBranch.getBoolPref("welcomeWindowShown")) {
       var url = "about:requestpolicy?setup";
 
-      var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
-          getService(Ci.nsIWindowMediator);
-      var windowtype = "navigator:browser";
-      var mostRecentWindow = wm.getMostRecentWindow(windowtype);
+      let win = WindowUtils.getMostRecentBrowserWindow();
+      let tabbrowser = win.getBrowser();
 
-      // the gBrowser object of the firefox window
-      var _gBrowser = mostRecentWindow.getBrowser();
-
-      if (typeof _gBrowser.addTab !== "function") {
+      if (typeof tabbrowser.addTab !== "function") {
         return;
       }
 
-      _gBrowser.selectedTab = _gBrowser.addTab(url);
+      tabbrowser.selectedTab = tabbrowser.addTab(url);
 
       rpPrefBranch.setBoolPref("welcomeWindowShown", true);
       Services.prefs.savePrefFile(null);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git



More information about the Pkg-mozext-commits mailing list