Bug 1484876 - Part 4: Remove nsIPrivateBrowsingTrackingProtectionWhitelist.existsInAllowList(); r=johannh
☠☠ backed out by 41ebcb085bb0 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 21 Aug 2018 09:55:49 -0400
changeset 481129 cd2ced68989568aaadd21e09d7d68664cf43e91d
parent 481128 d31e39a477046ed8a574e43dc6bbd4192829680d
child 481130 b1cb63d8c8bb98823dab57773d150178f19e694b
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersjohannh
bugs1484876
milestone63.0a1
Bug 1484876 - Part 4: Remove nsIPrivateBrowsingTrackingProtectionWhitelist.existsInAllowList(); r=johannh
browser/base/content/browser-contentblocking.js
toolkit/components/privatebrowsing/PrivateBrowsingTrackingProtectionWhitelist.js
toolkit/components/privatebrowsing/nsIPrivateBrowsingTrackingProtectionWhitelist.idl
toolkit/modules/PrivateBrowsingUtils.jsm
--- a/browser/base/content/browser-contentblocking.js
+++ b/browser/base/content/browser-contentblocking.js
@@ -407,23 +407,21 @@ var ContentBlocking = {
     // This state will be overriden later if there's an exception set for this site.
     let active = this.enabled && detected;
 
     for (let blocker of this.blockers) {
       blocker.categoryItem.classList.toggle("blocked", this.enabled && blocker.enabled);
     }
 
     // Check whether the user has added an exception for this site.
-    let hasException = false;
-    if (PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser)) {
-      hasException = PrivateBrowsingUtils.existsInTrackingAllowlist(baseURI);
-    } else {
-      hasException = Services.perms.testExactPermission(baseURI,
-        "trackingprotection") == Services.perms.ALLOW_ACTION;
-    }
+    let type = PrivateBrowsingUtils.isBrowserPrivate(gBrowser.selectedBrowser) ?
+                 "trackingprotection-pb" :
+                 "trackingprotection";
+    let hasException = Services.perms.testExactPermission(baseURI, type) ==
+      Services.perms.ALLOW_ACTION;
 
     this.content.toggleAttribute("detected", detected);
     this.content.toggleAttribute("hasException", hasException);
 
     this.iconBox.toggleAttribute("active", active);
     this.iconBox.toggleAttribute("hasException", this.enabled && hasException);
 
     if (isSimulated) {
--- a/toolkit/components/privatebrowsing/PrivateBrowsingTrackingProtectionWhitelist.js
+++ b/toolkit/components/privatebrowsing/PrivateBrowsingTrackingProtectionWhitelist.js
@@ -30,27 +30,16 @@ PrivateBrowsingTrackingProtectionWhiteli
    *
    * @param uri nsIURI
    *        The URI to add to the list.
    */
   removeFromAllowList(uri) {
     Services.perms.remove(uri, "trackingprotection-pb");
   },
 
-  /**
-   * Check if the provided URI exists in the list of allowed tracking sites.
-   *
-   * @param uri nsIURI
-   *        The URI to add to the list.
-   */
-  existsInAllowList(uri) {
-    return Services.perms.testPermission(uri, "trackingprotection-pb") ==
-           Ci.nsIPermissionManager.ALLOW_ACTION;
-  },
-
   observe(subject, topic, data) {
     if (topic == "last-pb-context-exited") {
       Services.perms.removeByType("trackingprotection-pb");
     }
   }
 };
 
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PrivateBrowsingTrackingProtectionWhitelist]);
--- a/toolkit/components/privatebrowsing/nsIPrivateBrowsingTrackingProtectionWhitelist.idl
+++ b/toolkit/components/privatebrowsing/nsIPrivateBrowsingTrackingProtectionWhitelist.idl
@@ -26,21 +26,13 @@ interface nsIPrivateBrowsingTrackingProt
   /**
    * Remove a URI from the list of allowed tracking sites in Private Browsing
    * mode (the tracking whitelist). If the URI is not already in the list,
    * then the operation is essentially a no-op.
    *
    * @param uri         the uri to remove from the list
    */
   void removeFromAllowList(in nsIURI uri);
-
-  /**
-   * Check if a URI exists in the list of allowed tracking sites in Private
-   * Browsing mode (the tracking whitelist).
-   *
-   * @param uri         the uri to look for in the list
-   */
-  bool existsInAllowList(in nsIURI uri);
 };
 
 %{ C++
 #define NS_PBTRACKINGPROTECTIONWHITELIST_CONTRACTID "@mozilla.org/pbm-tp-whitelist;1"
 %}
--- a/toolkit/modules/PrivateBrowsingUtils.jsm
+++ b/toolkit/modules/PrivateBrowsingUtils.jsm
@@ -55,20 +55,16 @@ var PrivateBrowsingUtils = {
   privacyContextFromWindow: function pbu_privacyContextFromWindow(aWindow) {
     return aWindow.docShell.QueryInterface(Ci.nsILoadContext);
   },
 
   addToTrackingAllowlist(aURI) {
     gPBMTPWhitelist.addToAllowList(aURI);
   },
 
-  existsInTrackingAllowlist(aURI) {
-    return gPBMTPWhitelist.existsInAllowList(aURI);
-  },
-
   removeFromTrackingAllowlist(aURI) {
     gPBMTPWhitelist.removeFromAllowList(aURI);
   },
 
   get permanentPrivateBrowsing() {
     try {
       return gTemporaryAutoStartMode ||
              Services.prefs.getBoolPref(kAutoStartPref);