Bug 1102518 - Actually disable tracking protection when user taps "disable" button. r=mfinkle
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Fri, 21 Nov 2014 08:03:17 -0800
changeset 241205 ded64417fabe99e1b4c781ca87be640a2226f4c5
parent 241204 b21965d27318315be240860396ffeb9f138ba5ae
child 241206 f4e09c6be90174c6a36061e88c26b8644676001a
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs1102518
milestone36.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 1102518 - Actually disable tracking protection when user taps "disable" button. r=mfinkle
mobile/android/base/toolbar/SiteIdentityPopup.java
mobile/android/chrome/content/browser.js
--- a/mobile/android/base/toolbar/SiteIdentityPopup.java
+++ b/mobile/android/base/toolbar/SiteIdentityPopup.java
@@ -282,18 +282,18 @@ public class SiteIdentityPopup extends A
         removeTrackingContentNotification();
     }
 
     private class PopupButtonListener implements OnButtonClickListener {
         @Override
         public void onButtonClick(DoorHanger dh, String tag) {
             try {
                 JSONObject data = new JSONObject();
-                String allowType = (dh == mMixedContentNotification ? "allowMixedContent" : "allowTrackingContent");
-                data.put(allowType, tag.equals("disable"));
+                data.put("allowContent", tag.equals("disable"));
+                data.put("contentType", (dh == mMixedContentNotification ? "mixed" : "tracking"));
 
                 GeckoEvent e = GeckoEvent.createBroadcastEvent("Session:Reload", data.toString());
                 GeckoAppShell.sendEventToGecko(e);
             } catch (JSONException e) {
                 Log.e(LOGTAG, "Exception creating message to enable/disable content blocking", e);
             }
 
             dismiss();
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1543,24 +1543,44 @@ var BrowserApp = {
           browser.gotoIndex(index);
           break;
 
       case "Session:Reload": {
         let flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
 
         // Check to see if this is a message to enable/disable mixed content blocking.
         if (aData) {
-          let allowMixedContent = JSON.parse(aData).allowMixedContent;
-          if (allowMixedContent) {
-            // Set a flag to disable mixed content blocking.
-            flags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_MIXED_CONTENT;
-          } else {
-            // Set mixedContentChannel to null to re-enable mixed content blocking.
-            let docShell = browser.webNavigation.QueryInterface(Ci.nsIDocShell);
-            docShell.mixedContentChannel = null;
+          let data = JSON.parse(aData);
+          if (data.contentType === "mixed") {
+            if (data.allowContent) {
+              // Set a flag to disable mixed content blocking.
+              flags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_MIXED_CONTENT;
+            } else {
+              // Set mixedContentChannel to null to re-enable mixed content blocking.
+              let docShell = browser.webNavigation.QueryInterface(Ci.nsIDocShell);
+              docShell.mixedContentChannel = null;
+            }
+          } else if (data.contentType === "tracking") {
+            if (data.allowContent) {
+              // Convert document URI into the format used by
+              // nsChannelClassifier::ShouldEnableTrackingProtection
+              // (any scheme turned into https is correct)
+              let normalizedUrl = Services.io.newURI("https://" + browser.currentURI.hostPort, null, null);
+              // Add the current host in the 'trackingprotection' consumer of
+              // the permission manager using a normalized URI. This effectively
+              // places this host on the tracking protection white list.
+              Services.perms.add(normalizedUrl, "trackingprotection", Services.perms.ALLOW_ACTION);
+              Telemetry.addData("TRACKING_PROTECTION_EVENTS", 1);
+            } else {
+              // Remove the current host from the 'trackingprotection' consumer
+              // of the permission manager. This effectively removes this host
+              // from the tracking protection white list (any list actually).
+              Services.perms.remove(browser.currentURI.host, "trackingprotection");
+              Telemetry.addData("TRACKING_PROTECTION_EVENTS", 2);
+            }
           }
         }
 
         // Try to use the session history to reload so that framesets are
         // handled properly. If the window has no session history, fall back
         // to using the web navigation's reload method.
         let webNav = browser.webNavigation;
         try {