Bug 1276132 - Rename media.gmp-*.forcevisible to media.gmp-*.visible, and set it when keysystems are enabled. r?spohl draft
authorChris Pearce <cpearce@mozilla.com>
Tue, 31 May 2016 10:59:44 +1200
changeset 374271 6011d514262b561485bf0bb0231ba5fda2a166fc
parent 372484 2c7440e46d8786b2c82a1d2004e2b6d9d13f4046
child 374272 ba7a526411567db90791a55981d79a33b0e0d1bb
push id19972
push usercpearce@mozilla.com
push dateThu, 02 Jun 2016 04:16:40 +0000
reviewersspohl
bugs1276132
milestone49.0a1
Bug 1276132 - Rename media.gmp-*.forcevisible to media.gmp-*.visible, and set it when keysystems are enabled. r?spohl Repurpose the media.gmp-*.forcevisible pref to control whether the corresponding GMP is visible in the addons manager UI. The pref has to be true for the GMP to be usable. The pref is enabled and not hidden when the corresponding EME keysystem is enabled in the mozconfig. This means users can turn on EME without needing to recompile their build; they just need to create a hidden pref. This will be useful for CDM developers, and users on platforms where we've not enabled EME yet but users want to test it (Linux). We also need to change the GMPUtils.isPluginHidden() accessor so that plugins are considered hidden if the "visible" pref is false OR we're on an unsupported platform. This ensures that we must be on a supported OS and the visibility pref is true before GMPs appear in the addon list. A consequence of the isPluginHidden() change is that we also need to add a "force-supported" pref to override the checks that refuse to load the GMPs on various platform versions, so that the unit tests pass. MozReview-Commit-ID: h6CwLDkvFW
browser/app/profile/firefox.js
toolkit/modules/GMPUtils.jsm
toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js
toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1279,21 +1279,31 @@ pref("media.gmp.decoder.enabled", false)
 // installed.
 pref("media.gmp.decoder.aac", 2);
 pref("media.gmp.decoder.h264", 2);
 
 // Whether we should run a test-pattern through EME GMPs before assuming they'll
 // decode H.264.
 pref("media.gmp.trial-create.enabled", true);
 
+// Note: when media.gmp-*.visible is true, provided we're running on a
+// supported platform/OS version, the corresponding CDM appears in the
+// plugins list, Firefox will download the GMP/CDM if enabled, and our
+// UI to re-enable EME prompts the user to re-enable EME if it's disabled
+// and script requests EME. If *.visible is false, we won't show the UI
+// to enable the CDM if its disabled; it's as if the keysystem is completely
+// unsupported.
+
 #ifdef MOZ_ADOBE_EME
+pref("media.gmp-eme-adobe.visible", true);
 pref("media.gmp-eme-adobe.enabled", true);
 #endif
 
 #ifdef MOZ_WIDEVINE_EME
+pref("media.gmp-widevinecdm.visible", true);
 pref("media.gmp-widevinecdm.enabled", true);
 #endif
 
 // Play with different values of the decay time and get telemetry,
 // 0 means to randomize (and persist) the experiment value in users' profiles,
 // -1 means no experiment is run and we use the preferred value for frecency (6h)
 pref("browser.cache.frecency_experiment", 0);
 
--- a/toolkit/modules/GMPUtils.jsm
+++ b/toolkit/modules/GMPUtils.jsm
@@ -41,18 +41,18 @@ this.GMPUtils = {
    * @param   aPlugin
    *          The plugin to check.
    */
   isPluginHidden: function(aPlugin) {
     if (!aPlugin.isEME) {
       return false;
     }
 
-    if (!this._isPluginSupported(aPlugin) &&
-        !this._isPluginForcedVisible(aPlugin)) {
+    if (!this._isPluginSupported(aPlugin) ||
+        !this._isPluginVisible(aPlugin)) {
       this.maybeReportTelemetry(aPlugin.id,
                                 "VIDEO_EME_ADOBE_HIDDEN_REASON",
                                 GMPPluginHiddenReason.UNSUPPORTED);
       return true;
     }
 
     if (!GMPPrefs.get(GMPPrefs.KEY_EME_ENABLED, true)) {
       this.maybeReportTelemetry(aPlugin.id,
@@ -65,16 +65,19 @@ this.GMPUtils = {
   },
 
   /**
    * Checks whether or not a given plugin is supported by the current OS.
    * @param   aPlugin
    *          The plugin to check.
    */
   _isPluginSupported: function(aPlugin) {
+    if (this._isPluginForceSupported(aPlugin)) {
+      return true;
+    }
     if (aPlugin.id == EME_ADOBE_ID) {
       if (Services.appinfo.OS != "WINNT") {
         // Non-Windows OSes currently unsupported by Adobe EME
         this.maybeReportTelemetry(aPlugin.id,
                                   "VIDEO_EME_ADOBE_UNSUPPORTED_REASON",
                                   GMPPluginUnsupportedReason.NOT_WINDOWS);
         return false;
       }
@@ -87,23 +90,35 @@ this.GMPUtils = {
       }
       return false;
     }
 
     return true;
   },
 
   /**
-   * Checks whether or not a given plugin is forced visible. This can be used
-   * to test plugins that aren't yet supported by default on a particular OS.
+   * Checks whether or not a given plugin is visible in the addons manager
+   * UI and the "enable DRM" notification box. This can be used to test
+   * plugins that aren't yet turned on in the mozconfig.
    * @param   aPlugin
    *          The plugin to check.
    */
-  _isPluginForcedVisible: function(aPlugin) {
-    return GMPPrefs.get(GMPPrefs.KEY_PLUGIN_FORCEVISIBLE, false, aPlugin.id);
+  _isPluginVisible: function(aPlugin) {
+    return GMPPrefs.get(GMPPrefs.KEY_PLUGIN_VISIBLE, false, aPlugin.id);
+  },
+
+  /**
+   * Checks whether or not a given plugin is forced-supported. This is used
+   * in automated tests to override the checks that prevent GMPs running on an
+   * unsupported platform.
+   * @param   aPlugin
+   *          The plugin to check.
+   */
+  _isPluginForceSupported: function(aPlugin) {
+    return GMPPrefs.get(GMPPrefs.KEY_PLUGIN_FORCE_SUPPORTED, false, aPlugin.id);
   },
 
   /**
    * Report telemetry value, but only for Adobe CDM and only once per key
    * per session.
    */
   maybeReportTelemetry: function(aPluginId, key, value) {
     if (aPluginId != EME_ADOBE_ID) {
@@ -131,18 +146,19 @@ this.GMPUtils = {
  * Manages preferences for GMP addons
  */
 this.GMPPrefs = {
   KEY_EME_ENABLED:              "media.eme.enabled",
   KEY_PLUGIN_ENABLED:           "media.{0}.enabled",
   KEY_PLUGIN_LAST_UPDATE:       "media.{0}.lastUpdate",
   KEY_PLUGIN_VERSION:           "media.{0}.version",
   KEY_PLUGIN_AUTOUPDATE:        "media.{0}.autoupdate",
-  KEY_PLUGIN_FORCEVISIBLE:      "media.{0}.forcevisible",
+  KEY_PLUGIN_VISIBLE:           "media.{0}.visible",
   KEY_PLUGIN_ABI:               "media.{0}.abi",
+  KEY_PLUGIN_FORCE_SUPPORTED:   "media.{0}.forceSupported",
   KEY_URL:                      "media.gmp-manager.url",
   KEY_URL_OVERRIDE:             "media.gmp-manager.url.override",
   KEY_CERT_CHECKATTRS:          "media.gmp-manager.cert.checkAttributes",
   KEY_CERT_REQUIREBUILTIN:      "media.gmp-manager.cert.requireBuiltIn",
   KEY_UPDATE_LAST_CHECK:        "media.gmp-manager.lastCheck",
   KEY_SECONDS_BETWEEN_CHECKS:   "media.gmp-manager.secondsBetweenChecks",
   KEY_APP_DISTRIBUTION:         "distribution.id",
   KEY_APP_DISTRIBUTION_VERSION: "distribution.version",
--- a/toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js
@@ -97,17 +97,17 @@ add_task(function* initializeState() {
   registerCleanupFunction(Task.async(function*() {
     Services.obs.removeObserver(gOptionsObserver, AddonManager.OPTIONS_NOTIFICATION_DISPLAYED);
 
     for (let addon of gMockAddons) {
       gPrefs.clearUserPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, addon.id));
       gPrefs.clearUserPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_LAST_UPDATE, addon.id));
       gPrefs.clearUserPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_AUTOUPDATE, addon.id));
       gPrefs.clearUserPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id));
-      gPrefs.clearUserPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCEVISIBLE, addon.id));
+      gPrefs.clearUserPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_VISIBLE, addon.id));
     }
     gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_LOGGING_DUMP);
     gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_LOGGING_LEVEL);
     gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_UPDATE_LAST_CHECK);
     gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_EME_ENABLED);
     yield GMPScope.GMPProvider.shutdown();
     GMPScope.GMPProvider.startup();
   }));
@@ -120,17 +120,17 @@ add_task(function* initializeState() {
   // Start out with plugins not being installed, disabled and automatic updates
   // disabled.
   gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_EME_ENABLED, true);
   for (let addon of gMockAddons) {
     gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, addon.id), false);
     gPrefs.setIntPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_LAST_UPDATE, addon.id), 0);
     gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_AUTOUPDATE, addon.id), false);
     gPrefs.setCharPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id), "");
-    gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCEVISIBLE, addon.id),
+    gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_VISIBLE, addon.id),
                        true);
   }
   yield GMPScope.GMPProvider.shutdown();
   GMPScope.GMPProvider.startup();
 });
 
 add_task(function* testNotInstalledDisabled() {
   Assert.ok(gCategoryUtilities.isTypeVisible("plugin"), "Plugin tab visible.");
@@ -365,17 +365,17 @@ add_task(function* testUpdateButton() {
     writable: true,
     enumerable: true,
     configurable: true
   });
 });
 
 add_task(function* testEmeSupport() {
   for (let addon of gMockAddons) {
-    gPrefs.clearUserPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCEVISIBLE, addon.id));
+    gPrefs.clearUserPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_VISIBLE, addon.id));
   }
   yield GMPScope.GMPProvider.shutdown();
   GMPScope.GMPProvider.startup();
 
   for (let addon of gMockAddons) {
     yield gCategoryUtilities.openType("plugin");
     let doc = gManagerWindow.document;
     let item = get_addon_element(gManagerWindow, addon.id);
@@ -395,17 +395,17 @@ add_task(function* testEmeSupport() {
                   "Widevine not supported, couldn't find add-on element.");
       }
     } else {
       Assert.ok(item, "Found add-on element.");
     }
   }
 
   for (let addon of gMockAddons) {
-    gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCEVISIBLE, addon.id),
+    gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_VISIBLE, addon.id),
                        true);
   }
   yield GMPScope.GMPProvider.shutdown();
   GMPScope.GMPProvider.startup();
 
 });
 
 add_task(function* test_cleanup() {
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
@@ -54,17 +54,19 @@ MockGMPInstallManager.prototype = {
 function run_test() {
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
   startupManager();
 
   gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_LOGGING_DUMP, true);
   gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_LOGGING_LEVEL, 0);
   gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_EME_ENABLED, true);
   for (let addon of gMockAddons.values()) {
-    gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCEVISIBLE, addon.id),
+    gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VISIBLE, addon.id),
+                       true);
+    gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCE_SUPPORTED, addon.id),
                        true);
   }
   GMPScope.GMPProvider.shutdown();
   GMPScope.GMPProvider.startup();
 
   run_next_test();
 }