From d0d6e8edf54d720e2858871e2c1e93e87db6622a Mon Sep 17 00:00:00 2001 From: Moonchild Date: Tue, 17 Oct 2023 16:24:41 +0200 Subject: Issue #2346 - Clean up EME code in toolkit extension manager (GMP) --- toolkit/mozapps/extensions/GMPInstallManager.jsm | 3 -- toolkit/mozapps/extensions/GMPUtils.jsm | 5 -- .../mozapps/extensions/internal/GMPProvider.jsm | 59 +++------------------- 3 files changed, 8 insertions(+), 59 deletions(-) diff --git a/toolkit/mozapps/extensions/GMPInstallManager.jsm b/toolkit/mozapps/extensions/GMPInstallManager.jsm index fe4e2de103..b7060e7908 100644 --- a/toolkit/mozapps/extensions/GMPInstallManager.jsm +++ b/toolkit/mozapps/extensions/GMPInstallManager.jsm @@ -302,9 +302,6 @@ GMPInstallManager.prototype = { } return now - lastCheck; }, - get _isEMEEnabled() { - return GMPPrefs.get(GMPPrefs.KEY_EME_ENABLED, true); - }, _isAddonUpdateEnabled: function(aAddon) { return GMPPrefs.get(GMPPrefs.KEY_PLUGIN_ENABLED, true, aAddon) && GMPPrefs.get(GMPPrefs.KEY_PLUGIN_AUTOUPDATE, true, aAddon); diff --git a/toolkit/mozapps/extensions/GMPUtils.jsm b/toolkit/mozapps/extensions/GMPUtils.jsm index 3c691610d5..f1c7e86c88 100644 --- a/toolkit/mozapps/extensions/GMPUtils.jsm +++ b/toolkit/mozapps/extensions/GMPUtils.jsm @@ -53,10 +53,6 @@ this.GMPUtils = { return true; } - if (!GMPPrefs.get(GMPPrefs.KEY_EME_ENABLED, true)) { - return true; - } - return false; }, @@ -118,7 +114,6 @@ 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", diff --git a/toolkit/mozapps/extensions/internal/GMPProvider.jsm b/toolkit/mozapps/extensions/internal/GMPProvider.jsm index c894271018..1ecd97aa97 100644 --- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm +++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm @@ -28,7 +28,7 @@ const URI_EXTENSION_STRINGS = "chrome://mozapps/locale/extensions/extensions.pr const STRING_TYPE_NAME = "type.%ID%.name"; const SEC_IN_A_DAY = 24 * 60 * 60; -// How long to wait after a user enabled EME before attempting to download CDMs. +// How long to wait before attempting to download GMPs. const GMP_CHECK_DELAY = 10 * 1000; // milliseconds const NS_GRE_DIR = "GreD"; @@ -48,16 +48,6 @@ const GMP_PLUGINS = [ licenseURL: "chrome://mozapps/content/extensions/OpenH264-license.txt", homepageURL: "http://www.openh264.org/", optionsURL: "chrome://mozapps/content/extensions/gmpPrefs.xul" - }, - { - id: WIDEVINE_ID, - name: "widevine_name", - // Describe the purpose of both CDMs in the same way. - description: "widevine_description2", - licenseURL: "https://www.google.com/policies/privacy/", - homepageURL: "https://www.widevine.com/", - optionsURL: "chrome://mozapps/content/extensions/gmpPrefs.xul", - isEME: true }]; XPCOMUtils.defineConstant(this, "GMP_PLUGINS", GMP_PLUGINS); @@ -109,11 +99,6 @@ function GMPWrapper(aPluginInfo) { Preferences.observe(GMPPrefs.getPrefKey(GMPPrefs.KEY_PLUGIN_VERSION, this._plugin.id), this.onPrefVersionChanged, this); - if (this._plugin.isEME) { - Preferences.observe(GMPPrefs.KEY_EME_ENABLED, - this.onPrefEMEGlobalEnabledChanged, this); - messageManager.addMessageListener("EMEVideo:ContentMediaKeysRequest", this); - } } GMPWrapper.prototype = { @@ -149,14 +134,7 @@ GMPWrapper.prototype = { get version() { return GMPPrefs.get(GMPPrefs.KEY_PLUGIN_VERSION, null, this._plugin.id); }, - get isActive() { return !this.appDisabled && !this.userDisabled; }, - get appDisabled() { - if (this._plugin.isEME && !GMPPrefs.get(GMPPrefs.KEY_EME_ENABLED, true)) { - // If "media.eme.enabled" is false, all EME plugins are disabled. - return true; - } - return false; - }, + get isActive() { return !this.userDisabled; }, get userDisabled() { return !GMPPrefs.get(GMPPrefs.KEY_PLUGIN_ENABLED, true, this._plugin.id); @@ -386,7 +364,7 @@ GMPWrapper.prototype = { }, onPrefEnabledChanged: function() { - if (!this._plugin.isEME || !this.appDisabled) { + if (!this._plugin.isEME) { this._handleEnabledChanged(); } }, @@ -436,11 +414,6 @@ GMPWrapper.prototype = { Preferences.ignore(GMPPrefs.getPrefKey(GMPPrefs.KEY_PLUGIN_VERSION, this._plugin.id), this.onPrefVersionChanged, this); - if (this._plugin.isEME) { - Preferences.ignore(GMPPrefs.KEY_EME_ENABLED, - this.onPrefEMEGlobalEnabledChanged, this); - messageManager.removeMessageListener("EMEVideo:ContentMediaKeysRequest", this); - } return this._updateTask; }, }; @@ -476,21 +449,6 @@ var GMPProvider = { } } } - - if (Preferences.get(GMPPrefs.KEY_EME_ENABLED, false)) { - try { - let greDir = Services.dirsvc.get(NS_GRE_DIR, - Ci.nsILocalFile); - let clearkeyPath = OS.Path.join(greDir.path, - CLEARKEY_PLUGIN_ID, - CLEARKEY_VERSION); - this._log.info("startup - adding clearkey CDM directory " + - clearkeyPath); - gmpService.addPluginDirectory(clearkeyPath); - } catch (e) { - this._log.warn("startup - adding clearkey CDM failed", e); - } - } }, shutdown: function() { @@ -586,12 +544,11 @@ var GMPProvider = { }, ensureProperCDMInstallState: function() { - if (!GMPPrefs.get(GMPPrefs.KEY_EME_ENABLED, true)) { - for (let [id, plugin] of this._plugins) { - if (plugin.isEME && plugin.wrapper.isInstalled) { - gmpService.addPluginDirectory(plugin.wrapper.gmpPath); - plugin.wrapper.uninstallPlugin(); - } + // This removes disabled EME CDM plugins + for (let [id, plugin] of this._plugins) { + if (plugin.isEME && plugin.wrapper.isInstalled) { + gmpService.addPluginDirectory(plugin.wrapper.gmpPath); + plugin.wrapper.uninstallPlugin(); } } }, -- cgit v1.2.3