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?francois draft
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 26 May 2017 13:09:42 -0400
changeset 585198 2bbab8c5308e78c05649e5e773b68cd72af9c8ab
parent 578063 c63d8286d4548cd385947dc8c4895800b1e793f2
child 630666 f82348e20cad94fb233b01160739afe1bd661527
push id61048
push userbsmedberg@mozilla.com
push dateFri, 26 May 2017 17:10:03 +0000
reviewersmconley
bugs1368060
milestone55.0a1
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?francois 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
@@ -664,16 +664,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);
 
 // Flash is enabled by default, and Java is click-to-activate by default on
 // all channels.
 pref("plugin.state.flash", 2);
--- 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
@@ -8058,42 +8058,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 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}],
 ]);