Bug 1146565 - Ensure proper CDM install state when the media.eme.enabled pref is toggled when Firefox isn't running. r=mossop
authorStephen Pohl <spohl.mozilla.bugs@gmail.com>
Tue, 24 Mar 2015 15:36:19 -0400
changeset 264276 068c46a5ad3fe4f601bec9a672dc58d2d0573ecb
parent 264275 79d8deba1d30fe9b8027a411dfd668a0c63d6ed1
child 264277 6dd5b23f5558daf996798b2a3983a7fd9d4359b6
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1146565
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1146565 - Ensure proper CDM install state when the media.eme.enabled pref is toggled when Firefox isn't running. r=mossop
toolkit/mozapps/extensions/internal/GMPProvider.jsm
--- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm
@@ -333,24 +333,17 @@ GMPWrapper.prototype = {
                                            "onEnabled" : "onDisabled",
                                            this);
   },
 
   onPrefEMEGlobalEnabledChanged: function() {
     AddonManagerPrivate.callAddonListeners("onPropertyChanged", this,
                                            ["appDisabled"]);
     if (this.appDisabled) {
-      AddonManagerPrivate.callAddonListeners("onUninstalling", this, false);
-      if (this._gmpPath) {
-        this._log.info("onPrefEMEGlobalEnabledChanged() - unregistering gmp " +
-                       "directory " + this._gmpPath);
-        gmpService.removeAndDeletePluginDirectory(this._gmpPath);
-      }
-      GMPPrefs.reset(GMPPrefs.KEY_PLUGIN_VERSION, this.id);
-      AddonManagerPrivate.callAddonListeners("onUninstalled", this);
+      this.uninstallPlugin();
     } else {
       AddonManagerPrivate.callInstallListeners("onExternalInstall", null, this,
                                                null, false);
       AddonManagerPrivate.callAddonListeners("onInstalling", this, false);
       AddonManagerPrivate.callAddonListeners("onInstalled", this);
       if (!this._isUpdateCheckPending) {
         this._isUpdateCheckPending = true;
         GMPPrefs.reset(GMPPrefs.KEY_UPDATE_LAST_CHECK, null);
@@ -400,16 +393,27 @@ GMPWrapper.prototype = {
     if (this._gmpPath && this.isActive) {
       this._log.info("onPrefVersionChanged() - registering gmp directory " +
                      this._gmpPath);
       gmpService.addPluginDirectory(this._gmpPath);
     }
     AddonManagerPrivate.callAddonListeners("onInstalled", this);
   },
 
+  uninstallPlugin: function() {
+    AddonManagerPrivate.callAddonListeners("onUninstalling", this, false);
+    if (this.gmpPath) {
+      this._log.info("uninstallPlugin() - unregistering gmp directory " +
+                     this.gmpPath);
+      gmpService.removeAndDeletePluginDirectory(this.gmpPath);
+    }
+    GMPPrefs.reset(GMPPrefs.KEY_PLUGIN_VERSION, this.id);
+    AddonManagerPrivate.callAddonListeners("onUninstalled", this);
+  },
+
   shutdown: function() {
     Preferences.ignore(GMPPrefs.getPrefKey(GMPPrefs.KEY_PLUGIN_ENABLED,
                                            this._plugin.id),
                        this.onPrefEnabledChanged, this);
     Preferences.ignore(GMPPrefs.getPrefKey(GMPPrefs.KEY_PLUGIN_VERSION,
                                            this._plugin.id),
                        this.onPrefVersionChanged, this);
     if (this._plugin.isEME) {
@@ -426,16 +430,17 @@ let GMPProvider = {
   _plugins: null,
 
   startup: function() {
     configureLogging();
     this._log = Log.repository.getLoggerWithMessagePrefix("Toolkit.GMP",
                                                           "GMPProvider.");
     let telemetry = {};
     this.buildPluginList();
+    this.ensureProperCDMInstallState();
 
     Preferences.observe(GMPPrefs.KEY_LOG_BASE, configureLogging);
 
     for (let [id, plugin] of this._plugins) {
       let wrapper = plugin.wrapper;
       let gmpPath = wrapper.gmpPath;
       let isEnabled = wrapper.isActive;
       this._log.trace("startup - enabled=" + isEnabled + ", gmpPath=" +
@@ -558,16 +563,27 @@ let GMPProvider = {
         wrapper: null,
         isEME: aPlugin.isEME,
       };
       plugin.fullDescription = this.generateFullDescription(aPlugin);
       plugin.wrapper = new GMPWrapper(plugin);
       this._plugins.set(plugin.id, plugin);
     }
   },
+
+  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();
+        }
+      }
+    }
+  },
 };
 
 AddonManagerPrivate.registerProvider(GMPProvider, [
   new AddonManagerPrivate.AddonType("plugin", URI_EXTENSION_STRINGS,
                                     STRING_TYPE_NAME,
                                     AddonManager.VIEW_TYPE_LIST, 6000,
                                     AddonManager.TYPE_SUPPORTS_ASK_TO_ACTIVATE)
 ]);