[Pkg-mozext-commits] [tabmixplus] 29/51: Add new exception list to loadURIWithFlags function, to allow us override our preference and load the url in the current tab when the caller is in the list. secureLogin extension expect to execute the login in the current page

David Prévot taffit at moszumanska.debian.org
Mon Feb 2 18:36:50 UTC 2015


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

taffit pushed a commit to branch master
in repository tabmixplus.

commit 78119ddc6b07d25e2da30d1e4fbb84ddbd4cfce1
Author: onemen <tabmix.onemen at gmail.com>
Date:   Tue Jan 6 15:51:34 2015 +0200

    Add new exception list to loadURIWithFlags function, to allow us override our preference and load the url in the current tab when the caller is in the list.
    secureLogin extension expect to execute the login in the current page
---
 chrome/content/minit/tablib.js | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/chrome/content/minit/tablib.js b/chrome/content/minit/tablib.js
index b813903..67c5593 100644
--- a/chrome/content/minit/tablib.js
+++ b/chrome/content/minit/tablib.js
@@ -52,7 +52,8 @@ var tablib = {
   },
 
   _loadURIWithFlags: function(browser, uri, flags, referrer, charset, postdata) {
-    var allowLoad = browser.tabmix_allowLoad !== false || uri.match(/^javascript:/);
+    var allowLoad = tablib.isException(browser.tabmix_allowLoad !== false ||
+                                       uri.match(/^javascript:/));
     if (!allowLoad) {
       try {
         let newURI = Services.io.newURI(uri, null, null);
@@ -83,6 +84,33 @@ var tablib = {
     return null;
   },
 
+  /**
+   * check if we need to override our preference and force to load the url in
+   * the current tab
+   *
+   * current code only check if the caller is in the exception list
+   */
+  isException: function(loadInCurrent) {
+    if (loadInCurrent)
+      return loadInCurrent;
+
+    let exceptionList = {
+      // secureLogin extension expect to execute the login in the current page
+      // https://addons.mozilla.org/en-us/firefox/addon/secure-login/?src=ss
+      secureLogin: "secureLogin.login"
+    };
+    let keys = Object.keys(exceptionList);
+    let isInstalled = keys.some(function(item) {
+      return typeof window[item] == "object";
+    });
+    if (!isInstalled)
+      return loadInCurrent;
+
+    let stack = Error().stack || Components.stack.caller.formattedStack || "";
+    var re = keys.map(function(key) exceptionList[key]);
+    return new RegExp(re.join("|")).test(stack);
+  },
+
   change_gBrowser: function change_gBrowser() {
     var obj, fnName;
     if (typeof Fd == "object" && typeof Fd.addTab == "function")

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



More information about the Pkg-mozext-commits mailing list