Bug 1484876 - Part 4: Remove nsIPrivateBrowsingTrackingProtectionWhitelist.existsInAllowList(); r=johannh
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 21 Aug 2018 09:55:49 -0400
changeset 490635 5c3668fde5e5ac48647432402ce55f29f9f77cec
parent 490634 5ffff7652f8762a0fa411692b929316f8f36e756
child 490636 9b7ecee484b06102dbff8dbc4210dedc5430869c
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1484876
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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);