From f44f69e5030992700a24f13c8fd39e5fde5deb64 Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Tue, 31 May 2016 10:59:44 +1200 Subject: [PATCH] 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 | 10 +++++++ toolkit/modules/GMPUtils.jsm | 30 ++++++++++++++----- .../test/browser/browser_gmpProvider.js | 13 ++++---- .../test/xpcshell/test_gmpProvider.js | 4 ++- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index a375301328e6..ad272261cfe7 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1285,11 +1285,21 @@ pref("media.gmp.decoder.h264", 2); // 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 diff --git a/toolkit/modules/GMPUtils.jsm b/toolkit/modules/GMPUtils.jsm index 53356f34e391..b1d2b8e8d0a3 100644 --- a/toolkit/modules/GMPUtils.jsm +++ b/toolkit/modules/GMPUtils.jsm @@ -46,8 +46,8 @@ this.GMPUtils = { 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); @@ -70,6 +70,9 @@ this.GMPUtils = { * 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 @@ -92,13 +95,25 @@ this.GMPUtils = { }, /** - * 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); }, /** @@ -136,8 +151,9 @@ this.GMPPrefs = { 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", diff --git a/toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js b/toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js index 37825b0652a9..9b071f24f49f 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js +++ b/toolkit/mozapps/extensions/test/browser/browser_gmpProvider.js @@ -102,7 +102,8 @@ add_task(function* initializeState() { 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(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCE_SUPPORTED, addon.id)); } gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_LOGGING_DUMP); gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_LOGGING_LEVEL); @@ -125,8 +126,8 @@ add_task(function* initializeState() { 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), - true); + gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_VISIBLE, addon.id), true); + gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCE_SUPPORTED, addon.id), true); } yield GMPScope.GMPProvider.shutdown(); GMPScope.GMPProvider.startup(); @@ -370,7 +371,7 @@ add_task(function* testUpdateButton() { 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_FORCE_SUPPORTED, addon.id)); } yield GMPScope.GMPProvider.shutdown(); GMPScope.GMPProvider.startup(); @@ -400,8 +401,8 @@ add_task(function* testEmeSupport() { } for (let addon of gMockAddons) { - gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCEVISIBLE, addon.id), - true); + gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_VISIBLE, addon.id), true); + gPrefs.setBoolPref(getKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCE_SUPPORTED, addon.id), true); } yield GMPScope.GMPProvider.shutdown(); GMPScope.GMPProvider.startup(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js b/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js index 48d9c0557639..88140bd11af4 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js @@ -59,7 +59,9 @@ function run_test() { 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();