Bug 1294649 - Don't show EME plugins in the plugin list that are disabled. r?spohl draft
authorChris Pearce <cpearce@mozilla.com>
Tue, 16 Aug 2016 16:15:45 +1200
changeset 401428 5797875e87a3d23248fdf42cfa16c8b7173f6b13
parent 401339 39fa0bf479f3632616ef6e79178348605404c575
child 528478 4d1319b5585fa99efa6c4a29e94d7c3a32afb3db
push id26448
push userbmo:cpearce@mozilla.com
push dateTue, 16 Aug 2016 23:42:20 +0000
reviewersspohl
bugs1294649
milestone51.0a1
Bug 1294649 - Don't show EME plugins in the plugin list that are disabled. r?spohl I noticed that on Linux is you have 'Play DRM content' unchecked, and then open about:addons > plugins, and then check 'Play DRM content', that the Adobe CDM then appears in the about:addons > plugins list. This is because in GMPWrapper.onPrefEMEGlobalEnabledChanged() we're taking the branch that calls AddonManagerPrivate addon listeners. We're doing that because we're only checking the GMPWrapper.appDisabled on that branch, and so if EME is enabled, we'll go down that path for the Adobe CDM on Linux, even though the CDM itself isn't visible/supported on Linux. So we should instead only go down that path if EME is enabled, *and* if the GMP is not hidden. We can uninstall the GMP if it's hidden or EME is disabled, as there's not much point in keeping the plugin around if its disabled. This means toggling the 'Play DRM Content' checkbox doesn't make the Adobe CDM appear in the plugins list, and also if the Widevine CDM is explicitly disabled, it still appears in the plugins list if 'Play DRM Content' is checked, but it appears in a disabled state. As you'd expect. MozReview-Commit-ID: Fq10vnhiaKO
toolkit/mozapps/extensions/internal/GMPProvider.jsm
--- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm
@@ -168,24 +168,24 @@ GMPWrapper.prototype = {
   get fullDescription() { return this._plugin.fullDescription; },
 
   get version() { return GMPPrefs.get(GMPPrefs.KEY_PLUGIN_VERSION, null,
                                       this._plugin.id); },
 
   get isActive() {
     return !this.appDisabled &&
            !this.userDisabled &&
-           !GMPUtils.isPluginHidden(this._plugin.id);
+           !GMPUtils.isPluginHidden(this._plugin);
   },
   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;
+    return false;
   },
 
   get userDisabled() {
     return !GMPPrefs.get(GMPPrefs.KEY_PLUGIN_ENABLED, true, this._plugin.id);
   },
   set userDisabled(aVal) { GMPPrefs.set(GMPPrefs.KEY_PLUGIN_ENABLED,
                                         aVal === false,
                                         this._plugin.id); },
@@ -333,16 +333,19 @@ GMPWrapper.prototype = {
     return [];
   },
 
   get isInstalled() {
     return this.version && this.version.length > 0;
   },
 
   _handleEnabledChanged: function() {
+    this._log.info("_handleEnabledChanged() id=" +
+      this._plugin.id + " isActive=" + this.isActive);
+
     AddonManagerPrivate.callAddonListeners(this.isActive ?
                                            "onEnabling" : "onDisabling",
                                            this, false);
     if (this._gmpPath) {
       if (this.isActive) {
         this._log.info("onPrefEnabledChanged() - adding gmp directory " +
                        this._gmpPath);
         gmpService.addPluginDirectory(this._gmpPath);
@@ -353,21 +356,27 @@ GMPWrapper.prototype = {
       }
     }
     AddonManagerPrivate.callAddonListeners(this.isActive ?
                                            "onEnabled" : "onDisabled",
                                            this);
   },
 
   onPrefEMEGlobalEnabledChanged: function() {
+    this._log.info("onPrefEMEGlobalEnabledChanged() id=" + this._plugin.id +
+      " appDisabled=" + this.appDisabled + " isActive=" + this.isActive +
+      " hidden=" + GMPUtils.isPluginHidden(this._plugin));
+
     AddonManagerPrivate.callAddonListeners("onPropertyChanged", this,
                                            ["appDisabled"]);
+    // If EME or the GMP itself are disabled, uninstall the GMP.
+    // Otherwise, check for updates, so we download and install the GMP.
     if (this.appDisabled) {
       this.uninstallPlugin();
-    } else {
+    } else if (!GMPUtils.isPluginHidden(this._plugin)) {
       AddonManagerPrivate.callInstallListeners("onExternalInstall", null, this,
                                                null, false);
       AddonManagerPrivate.callAddonListeners("onInstalling", this, false);
       AddonManagerPrivate.callAddonListeners("onInstalled", this);
       this.checkForUpdates(GMP_CHECK_DELAY);
     }
     if (!this.userDisabled) {
       this._handleEnabledChanged();