Bug 1145694 - Uninstall Adobe EME when media.eme.enabled is set to false. r=mossop, a=sledru

This commit is contained in:
Stephen Pohl
2015-03-22 23:12:16 -04:00
parent b6a35c1758
commit ec039600ad
4 changed files with 28 additions and 13 deletions

View File

@@ -88,7 +88,6 @@ this.GMPPrefs = {
KEY_BUILDID: "media.gmp-manager.buildID",
KEY_CERTS_BRANCH: "media.gmp-manager.certs.",
KEY_PROVIDER_ENABLED: "media.gmp-provider.enabled",
KEY_PROVIDER_LASTCHECK: "media.gmp-manager.lastCheck",
KEY_LOG_BASE: "media.gmp.log.",
KEY_LOGGING_LEVEL: this.KEY_LOG_BASE + "level",
KEY_LOGGING_DUMP: this.KEY_LOG_BASE + "dump",

View File

@@ -21,11 +21,15 @@ Cu.import("resource://gre/modules/GMPUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(
this, "GMPInstallManager", "resource://gre/modules/GMPInstallManager.jsm");
XPCOMUtils.defineLazyModuleGetter(
this, "setTimeout", "resource://gre/modules/Timer.jsm");
const URI_EXTENSION_STRINGS = "chrome://mozapps/locale/extensions/extensions.properties";
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.
const GMP_CHECK_DELAY = 10 * 1000; // milliseconds
const NS_GRE_DIR = "GreD";
const CLEARKEY_PLUGIN_ID = "gmp-clearkey";
@@ -110,6 +114,7 @@ GMPWrapper.prototype = {
// An active task that checks for plugin updates and installs them.
_updateTask: null,
_gmpPath: null,
_isUpdateCheckPending: false,
optionsType: AddonManager.OPTIONS_TYPE_INLINE,
get optionsURL() { return this._plugin.optionsURL; },
@@ -233,7 +238,7 @@ GMPWrapper.prototype = {
}
let secSinceLastCheck =
Date.now() / 1000 - Preferences.get(GMPPrefs.KEY_PROVIDER_LASTCHECK, 0);
Date.now() / 1000 - Preferences.get(GMPPrefs.KEY_UPDATE_LAST_CHECK, 0);
if (secSinceLastCheck <= SEC_IN_A_DAY) {
this._log.trace("findUpdates() - " + this._plugin.id +
" - last check was less then a day ago");
@@ -331,19 +336,30 @@ GMPWrapper.prototype = {
if (this._gmpPath) {
this._log.info("onPrefEMEGlobalEnabledChanged() - unregistering gmp " +
"directory " + this._gmpPath);
gmpService.removePluginDirectory(this._gmpPath);
gmpService.removeAndDeletePluginDirectory(this._gmpPath);
}
GMPPrefs.reset(GMPPrefs.KEY_PLUGIN_VERSION, this.id);
AddonManagerPrivate.callAddonListeners("onUninstalled", this);
} else {
AddonManagerPrivate.callInstallListeners("onExternalInstall", null, this,
null, false);
AddonManagerPrivate.callAddonListeners("onInstalling", this, false);
if (this._gmpPath && this.isActive) {
this._log.info("onPrefEMEGlobalEnabledChanged() - registering gmp " +
"directory " + this._gmpPath);
gmpService.addPluginDirectory(this._gmpPath);
}
AddonManagerPrivate.callAddonListeners("onInstalled", this);
if (!this._isUpdateCheckPending) {
this._isUpdateCheckPending = true;
GMPPrefs.reset(GMPPrefs.KEY_UPDATE_LAST_CHECK, null);
// Delay this in case the user changes his mind and doesn't want to
// enable EME after all.
setTimeout(() => {
if (!this.appDisabled) {
let gmpInstallManager = new GMPInstallManager();
// We don't really care about the results, if someone is interested
// they can check the log.
gmpInstallManager.simpleCheckAndInstall().then(null, () => {});
}
this._isUpdateCheckPending = false;
}, GMP_CHECK_DELAY);
}
}
if (!this.userDisabled) {
this._handleEnabledChanged();

View File

@@ -100,7 +100,7 @@ add_task(function* initializeState() {
}
gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_LOGGING_DUMP);
gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_LOGGING_LEVEL);
gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_PROVIDER_LASTCHECK);
gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_UPDATE_LAST_CHECK);
gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_EME_ENABLED);
yield GMPScope.GMPProvider.shutdown();
GMPScope.GMPProvider.startup();
@@ -324,7 +324,7 @@ add_task(function* testPreferencesButton() {
});
add_task(function* testUpdateButton() {
gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_PROVIDER_LASTCHECK);
gPrefs.clearUserPref(GMPScope.GMPPrefs.KEY_UPDATE_LAST_CHECK);
let originalInstallManager = GMPScope.GMPInstallManager;
Object.defineProperty(GMPScope, "GMPInstallManager", {

View File

@@ -308,18 +308,18 @@ add_task(function* test_periodicUpdate() {
gPrefs.clearUserPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_AUTOUPDATE, addon.id));
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_PROVIDER_LASTCHECK, 0);
gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_UPDATE_LAST_CHECK, 0);
let result =
yield addon.findUpdates({}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
Assert.strictEqual(result, false);
addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_ENABLE;
gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_PROVIDER_LASTCHECK, Date.now() / 1000 - 60);
gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_UPDATE_LAST_CHECK, Date.now() / 1000 - 60);
result =
yield addon.findUpdates({}, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
Assert.strictEqual(result, false);
gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_PROVIDER_LASTCHECK,
gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_UPDATE_LAST_CHECK,
Date.now() / 1000 - 2 * GMPScope.SEC_IN_A_DAY);
gInstalledAddonId = "";
result =