[Pkg-mozext-commits] [requestpolicy] 179/280: respect private browsing settings on redirects

David Prévot taffit at moszumanska.debian.org
Sat May 2 20:30:21 UTC 2015


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

taffit pushed a commit to branch master
in repository requestpolicy.

commit ba1781cfb1b5307fd340c590ec3ef7bb244d7b8d
Author: Martin Kimmerle <dev at 256k.de>
Date:   Sun Jan 25 21:25:00 2015 +0100

    respect private browsing settings on redirects
    
    Now the redirection notification bar in private windows allows
    only to add temporary rules.
---
 src/content/lib/utils/windows.jsm | 14 +++++++++++++-
 src/content/ui/overlay.js         | 16 +++++++++++++---
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/content/lib/utils/windows.jsm b/src/content/lib/utils/windows.jsm
index 02f664f..00bd426 100644
--- a/src/content/lib/utils/windows.jsm
+++ b/src/content/lib/utils/windows.jsm
@@ -27,6 +27,8 @@ const Cu = Components.utils;
 
 let EXPORTED_SYMBOLS = ["WindowUtils"];
 
+Cu.import("chrome://requestpolicy/content/lib/script-loader.jsm");
+ScriptLoader.importModules(["lib/prefs"], this);
 
 
 
@@ -88,6 +90,16 @@ let WindowUtils = (function() {
     }
   }());
 
+  /**
+   * Should it be possible to add permanent rules in that window?
+   *
+   * @return {boolean}
+   */
+  self.mayPermanentRulesBeAdded = function(aWindow) {
+    return self.isWindowPrivate(aWindow) === false ||
+        rpPrefBranch.getBoolPref("privateBrowsingPermanentWhitelisting");
+  };
+
 
   //
   // Window & DOM utilities
@@ -97,7 +109,7 @@ let WindowUtils = (function() {
    * Wait for a window to be loaded and then add a list of Elements „by ID“ to
    * a scope. The scope is optional, but in any case will be returned.
    *
-   * @returns {Object} the scope of the elements
+   * @return {Object} the scope of the elements
    */
   self.getElementsByIdOnLoad = function(aWindow, aElementIDs, aScope,
                                         aCallback) {
diff --git a/src/content/ui/overlay.js b/src/content/ui/overlay.js
index dfc6ea2..bbfa39e 100644
--- a/src/content/ui/overlay.js
+++ b/src/content/ui/overlay.js
@@ -50,6 +50,7 @@ requestpolicy.overlay = (function() {
   let {DomainUtil} = iMod("lib/utils/domains");
   let {StringUtils} = iMod("lib/utils/strings");
   let {DOMUtils} = iMod("lib/utils/dom");
+  let {WindowUtils} = iMod("lib/utils/windows");
   let {C} = iMod("lib/utils/constants");
 
   let $id = document.getElementById.bind(document);
@@ -514,17 +515,26 @@ requestpolicy.overlay = (function() {
     var origin = m._addWildcard(DomainUtil.getBaseDomain(redirectOriginUri));
     var dest = m._addWildcard(DomainUtil.getBaseDomain(redirectTargetUri));
 
+
+    let mayPermRulesBeAdded = WindowUtils.mayPermanentRulesBeAdded(window);
+
     let cm = requestpolicy.classicmenu;
     cm.addMenuItemTemporarilyAllowDest(addRulePopup, dest);
-    cm.addMenuItemAllowDest(addRulePopup, dest);
+    if (mayPermRulesBeAdded) {
+      cm.addMenuItemAllowDest(addRulePopup, dest);
+    }
     cm.addMenuSeparator(addRulePopup);
 
     cm.addMenuItemTemporarilyAllowOrigin(addRulePopup, origin);
-    cm.addMenuItemAllowOrigin(addRulePopup, origin);
+    if (mayPermRulesBeAdded) {
+      cm.addMenuItemAllowOrigin(addRulePopup, origin);
+    }
     cm.addMenuSeparator(addRulePopup);
 
     cm.addMenuItemTemporarilyAllowOriginToDest(addRulePopup, origin, dest);
-    cm.addMenuItemAllowOriginToDest(addRulePopup, origin, dest);
+    if (mayPermRulesBeAdded) {
+      cm.addMenuItemAllowOriginToDest(addRulePopup, origin, dest);
+    }
 
 
 

-- 
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