Bug 1189928 - Move Tracking Protection shield probe into browser-trackingprotection.js;r=MattN
authorBrian Grinstead <bgrinstead@mozilla.com>
Tue, 04 Aug 2015 07:41:19 -0700
changeset 287788 59ea22a660a5be6f8786b83b3334bcdddfcf5372
parent 287787 cf4a7df98beba52fcd26f4b129eb00a3e822efb9
child 287789 6a6088330911606c797adf308b4ff12819c261fb
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1189928
milestone42.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 1189928 - Move Tracking Protection shield probe into browser-trackingprotection.js;r=MattN
browser/base/content/browser-trackingprotection.js
browser/base/content/browser.js
toolkit/components/telemetry/Histograms.json
--- a/browser/base/content/browser-trackingprotection.js
+++ b/browser/base/content/browser-trackingprotection.js
@@ -58,16 +58,20 @@ let TrackingProtection = {
   get enabledHistogram() {
     return Services.telemetry.getHistogramById("TRACKING_PROTECTION_ENABLED");
   },
 
   get eventsHistogram() {
     return Services.telemetry.getHistogramById("TRACKING_PROTECTION_EVENTS");
   },
 
+  get shieldHistogram() {
+    return Services.telemetry.getHistogramById("TRACKING_PROTECTION_SHIELD");
+  },
+
   onSecurityChange(state, isSimulated) {
     if (!this.enabled) {
       return;
     }
 
     // Only animate the shield if the event was not fired directly from
     // the tabbrowser (due to a browser change).
     if (isSimulated) {
@@ -86,24 +90,31 @@ let TrackingProtection = {
 
       // Open the tracking protection introduction panel, if applicable.
       let introCount = gPrefService.getIntPref("privacy.trackingprotection.introCount");
       if (introCount < TrackingProtection.MAX_INTROS) {
         gPrefService.setIntPref("privacy.trackingprotection.introCount", ++introCount);
         gPrefService.savePrefFile(null);
         this.showIntroPanel();
       }
+
+      this.shieldHistogram.add(2);
     } else if (isAllowing) {
       this.icon.setAttribute("tooltiptext", this.disabledTooltipText);
       this.icon.setAttribute("state", "loaded-tracking-content");
       this.content.setAttribute("state", "loaded-tracking-content");
+
+      this.shieldHistogram.add(1);
     } else {
       this.icon.removeAttribute("tooltiptext");
       this.icon.removeAttribute("state");
       this.content.removeAttribute("state");
+
+      // We didn't show the shield
+      this.shieldHistogram.add(0);
     }
 
     // Telemetry for state change.
     this.eventsHistogram.add(0);
   },
 
   disableForCurrentPage() {
     // Convert document URI into the format used by
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6864,20 +6864,16 @@ var gIdentityHandler = {
     // - tracking content is blocked
     // - tracking content is not blocked
     if (state &
         (nsIWebProgressListener.STATE_BLOCKED_MIXED_ACTIVE_CONTENT |
          nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT  |
          nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT     |
          nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT)) {
       this.showBadContentDoorhanger(state);
-    } else if (TrackingProtection.enabled) {
-      // We didn't show the shield
-      Services.telemetry.getHistogramById("TRACKING_PROTECTION_SHIELD")
-        .add(0);
     }
   },
 
   showBadContentDoorhanger : function(state) {
     var currentNotification =
       PopupNotifications.getNotification("bad-content",
         gBrowser.selectedBrowser);
 
@@ -6889,29 +6885,16 @@ var gIdentityHandler = {
       /* keep doorhanger collapsed */
       dismissed: true,
       state: state
     };
 
     // default
     let iconState = "bad-content-blocked-notification-icon";
 
-    // Telemetry for whether the shield was due to tracking protection or not
-    let histogram = Services.telemetry.getHistogramById
-                      ("TRACKING_PROTECTION_SHIELD");
-    if (state & Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT) {
-      histogram.add(1);
-    } else if (state &
-               Ci.nsIWebProgressListener.STATE_BLOCKED_TRACKING_CONTENT) {
-      histogram.add(2);
-    } else if (gPrefService.getBoolPref("privacy.trackingprotection.enabled")) {
-      // Tracking protection is enabled but no tracking elements are loaded,
-      // the shield is due to mixed content.
-      histogram.add(3);
-    }
     if (state &
         (Ci.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT |
          Ci.nsIWebProgressListener.STATE_LOADED_TRACKING_CONTENT)) {
       iconState = "bad-content-unblocked-notification-icon";
     }
 
     PopupNotifications.show(gBrowser.selectedBrowser, "bad-content",
                             "", iconState, null, null, options);
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -7871,17 +7871,17 @@
     "expires_in_version": "never",
     "kind": "boolean",
     "description": "Whether or not a session has tracking protection enabled"
   },
   "TRACKING_PROTECTION_SHIELD": {
     "expires_in_version": "never",
     "kind": "enumerated",
     "n_values": 4,
-    "description": "Tracking protection shield (0 = not shown, 1 = loaded, 2 = blocked, 3 = due to mixed content"
+    "description": "Tracking protection shield (0 = not shown, 1 = loaded, 2 = blocked)"
   },
   "TRACKING_PROTECTION_EVENTS": {
     "expires_in_version": "never",
     "kind": "enumerated",
     "n_values": 3,
     "description": "Doorhanger shown = 0, Disable = 1, Enable = 2"
   },
   "SERVICE_WORKER_REGISTRATION_LOADING": {