Bug 1368060 - Prefs and telemetry for hidden-plugin infobars. This patch does not change any defaults, but provides options which we'll test via A/B testing and telemetry to measure success. r=mconley data-r=rweiss
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 26 May 2017 13:09:42 -0400
changeset 361268 c3a2ed2ce9541b1d6684f6b6792fb78f7361f8ab
parent 361267 327ecc8de0295e4a7d64994dfd7add0128c50e2e
child 361269 39d5cc0fda5e16c49a59d29d4ca186a5534cc88b
child 361343 6f0b91f39cf7860d62ee534d6b615ca215b4a92c
push id31923
push userryanvm@gmail.com
push dateTue, 30 May 2017 16:39:52 +0000
treeherdermozilla-central@39d5cc0fda5e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1368060
milestone55.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 1368060 - Prefs and telemetry for hidden-plugin infobars. This patch does not change any defaults, but provides options which we'll test via A/B testing and telemetry to measure success. r=mconley data-r=rweiss MozReview-Commit-ID: 7QP1nsB2jtw
browser/app/profile/firefox.js
browser/base/content/browser-plugins.js
toolkit/components/telemetry/Histograms.json
toolkit/components/telemetry/TelemetryEnvironment.jsm
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -654,16 +654,22 @@ pref("accessibility.typeaheadfind.linkso
 pref("accessibility.typeaheadfind.flashBar", 1);
 
 // Tracks when accessibility is loaded into the previous session.
 pref("accessibility.loadedInLastSession", false);
 
 pref("plugins.click_to_play", true);
 pref("plugins.testmode", false);
 
+// Should plugins that are hidden show the infobar UI?
+pref("plugins.show_infobar", true);
+
+// Should dismissing the hidden plugin infobar suppress it permanently?
+pref("plugins.remember_infobar_dismissal", false);
+
 pref("plugin.default.state", 1);
 
 // Plugins bundled in XPIs are enabled by default.
 pref("plugin.defaultXpi.state", 2);
 
 // Java is Click-to-Activate by default on all channels.
 pref("plugin.state.java", 1);
 
--- a/browser/base/content/browser-plugins.js
+++ b/browser/base/content/browser-plugins.js
@@ -1,16 +1,19 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var gPluginHandler = {
   PREF_SESSION_PERSIST_MINUTES: "plugin.sessionPermissionNow.intervalInMinutes",
   PREF_PERSISTENT_DAYS: "plugin.persistentPermissionAlways.intervalInDays",
+  PREF_SHOW_INFOBAR: "plugins.show_infobar",
+  PREF_INFOBAR_DISMISSAL_PERMANENT: "plugins.remember_infobar_dismissal",
+
   MESSAGES: [
     "PluginContent:ShowClickToPlayNotification",
     "PluginContent:RemoveNotification",
     "PluginContent:UpdateHiddenPluginUI",
     "PluginContent:HideNotificationBar",
     "PluginContent:InstallSinglePlugin",
     "PluginContent:ShowPluginCrashedNotification",
     "PluginContent:SubmitReport",
@@ -340,16 +343,20 @@ var gPluginHandler = {
     // There are three different cases when showing an infobar:
     // 1.  A single type of plugin is hidden on the page. Show the UI for that
     //     plugin.
     // 2a. Multiple types of plugins are hidden on the page. Show the multi-UI
     //     with the vulnerable styling.
     // 2b. Multiple types of plugins are hidden on the page, but none are
     //     vulnerable. Show the nonvulnerable multi-UI.
     function showNotification() {
+      if (!Services.prefs.getBoolPref(gPluginHandler.PREF_SHOW_INFOBAR, true)) {
+        return;
+      }
+
       let n = notificationBox.getNotificationWithValue("plugin-hidden");
       if (n) {
         // If something is already shown, just keep it
         return;
       }
 
       Services.telemetry.getHistogramById("PLUGINS_INFOBAR_SHOWN").
         add(true);
@@ -409,19 +416,31 @@ var gPluginHandler = {
               PopupNotifications.getNotification("click-to-play-plugins",
                                                  browser);
             if (curNotification) {
               curNotification.reshow();
             }
           }
         }
       ];
+      function notificationCallback(type) {
+        if (type == "dismissed") {
+          Services.telemetry.getHistogramById("PLUGINS_INFOBAR_DISMISSED").
+            add(true);
+          if (Services.prefs.getBoolPref(gPluginHandler.PREF_INFOBAR_DISMISSAL_PERMANENT, false)) {
+            Services.perms.addFromPrincipal(principal,
+                                            "plugin-hidden-notification",
+                                            Services.perms.DENY_ACTION);
+          }
+        }
+      }
       n = notificationBox.
         appendNotification(message, "plugin-hidden", null,
-                           notificationBox.PRIORITY_INFO_HIGH, buttons);
+                           notificationBox.PRIORITY_INFO_HIGH, buttons,
+                           notificationCallback);
       if (haveInsecure) {
         n.classList.add("pluginVulnerable");
       }
     }
 
     if (actions.length == 0) {
       hideNotification();
     } else {
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -8122,42 +8122,51 @@
     "expires_in_version": "60",
     "kind": "enumerated",
     "n_values": 3,
     "description": "User actions taken in the plugin notification: 0: allownow 1: allowalways 2: block",
     "bug_numbers": [902075, 1345894],
     "alert_emails": ["bsmedberg@mozilla.com"]
   },
   "PLUGINS_INFOBAR_SHOWN": {
-    "record_in_processes": ["main", "content"],
+    "record_in_processes": ["main"],
     "releaseChannelCollection": "opt-out",
     "expires_in_version": "60",
     "kind": "boolean",
     "description": "Count of when the hidden-plugin infobar was displayed.",
     "bug_numbers": [902075, 1345894],
     "alert_emails": ["bsmedberg@mozilla.com"]
   },
   "PLUGINS_INFOBAR_BLOCK": {
-    "record_in_processes": ["main", "content"],
+    "record_in_processes": ["main"],
     "releaseChannelCollection": "opt-out",
     "expires_in_version": "60",
     "kind": "boolean",
     "description": "Count the number of times the user clicked 'block' on the hidden-plugin infobar.",
     "bug_numbers": [902075, 1345894],
     "alert_emails": ["bsmedberg@mozilla.com"]
   },
   "PLUGINS_INFOBAR_ALLOW": {
-    "record_in_processes": ["main", "content"],
+    "record_in_processes": ["main"],
     "releaseChannelCollection": "opt-out",
     "expires_in_version": "60",
     "kind": "boolean",
     "description": "Count the number of times the user clicked 'allow' on the hidden-plugin infobar.",
     "bug_numbers": [902075, 1345894],
     "alert_emails": ["bsmedberg@mozilla.com"]
   },
+  "PLUGINS_INFOBAR_DISMISSED": {
+    "record_in_processes": ["main"],
+    "releaseChannelCollection": "opt-out",
+    "expires_in_version": "60",
+    "kind": "boolean",
+    "description": "Count the number of times the user explicitly dismisses the hidden-plugin infobar without choosing allow or continue-blocking.",
+    "bug_numbers": [1368060],
+    "alert_emails": ["bsmedberg@mozilla.com"]
+  },
   "POPUP_NOTIFICATION_STATS": {
     "record_in_processes": ["main", "content"],
     "releaseChannelCollection": "opt-out",
     "alert_emails": ["firefox-dev@mozilla.org"],
     "bug_numbers": [1207089],
     "expires_in_version": "55",
     "kind": "enumerated",
     "keyed": true,
--- a/toolkit/components/telemetry/TelemetryEnvironment.jsm
+++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm
@@ -216,16 +216,18 @@ const DEFAULT_ENVIRONMENT_PREFS = new Ma
   ["layers.prefer-d3d9", {what: RECORD_PREF_VALUE}],
   ["layers.prefer-opengl", {what: RECORD_PREF_VALUE}],
   ["layout.css.devPixelsPerPx", {what: RECORD_PREF_VALUE}],
   ["network.proxy.autoconfig_url", {what: RECORD_PREF_STATE}],
   ["network.proxy.http", {what: RECORD_PREF_STATE}],
   ["network.proxy.ssl", {what: RECORD_PREF_STATE}],
   ["pdfjs.disabled", {what: RECORD_PREF_VALUE}],
   ["places.history.enabled", {what: RECORD_PREF_VALUE}],
+  ["plugins.remember_infobar_dismissal", {what: RECORD_PREF_VALUE}],
+  ["plugins.show_infobar", {what: RECORD_PREF_VALUE}],
   ["privacy.trackingprotection.enabled", {what: RECORD_PREF_VALUE}],
   ["privacy.donottrackheader.enabled", {what: RECORD_PREF_VALUE}],
   ["security.mixed_content.block_active_content", {what: RECORD_PREF_VALUE}],
   ["security.mixed_content.block_display_content", {what: RECORD_PREF_VALUE}],
   ["security.sandbox.content.level", {what: RECORD_PREF_VALUE}],
   ["xpinstall.signatures.required", {what: RECORD_PREF_VALUE}],
 ]);