Bug 1140263: Enable Adobe EME on Windows Vista+ and add a pref to force-enable it on other platforms. r=mossop

This commit is contained in:
Stephen Pohl 2015-03-19 22:59:38 -04:00
parent 1c6f9a76e6
commit a3d354c6dc
5 changed files with 251 additions and 221 deletions

View File

@ -4585,9 +4585,6 @@ pref("media.gmp-manager.certs.1.issuerName", "CN=DigiCert Secure Server CA,O=Dig
pref("media.gmp-manager.certs.1.commonName", "aus4.mozilla.org");
pref("media.gmp-manager.certs.2.issuerName", "CN=Thawte SSL CA,O=\"Thawte, Inc.\",C=US");
pref("media.gmp-manager.certs.2.commonName", "aus4.mozilla.org");
// Adobe EME is currently pref'd off by default and hidden in the addon manager.
pref("media.gmp-eme-adobe.hidden", true);
#endif
// Whether or not to perform reader mode article parsing on page load.

View File

@ -15,15 +15,6 @@ const DOWNLOAD_INTERVAL = 0;
// 1 day default
const DEFAULT_SECONDS_BETWEEN_CHECKS = 60 * 60 * 24;
// Global pref to enable/disable all EME plugins
const EME_ENABLED = "media.eme.enabled";
// GMP IDs
const OPEN_H264_ID = "gmp-gmpopenh264";
const EME_ADOBE_ID = "gmp-eme-adobe";
const GMP_ADDONS = [ OPEN_H264_ID, EME_ADOBE_ID ];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
@ -33,9 +24,10 @@ Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/ctypes.jsm");
Cu.import("resource://gre/modules/GMPUtils.jsm");
this.EXPORTED_SYMBOLS = ["GMPInstallManager", "GMPExtractor", "GMPDownloader",
"GMPAddon", "GMPPrefs", "OPEN_H264_ID"];
"GMPAddon"];
var gLocale = null;
@ -65,68 +57,6 @@ function getScopedLogger(prefix) {
return Log.repository.getLoggerWithMessagePrefix("Toolkit.GMP", prefix + " ");
}
/**
* Manages preferences for GMP addons
*/
let GMPPrefs = {
/**
* Obtains the specified preference in relation to the specified addon
* @param key The GMPPrefs key value to use
* @param defaultValue The default value if no preference exists
* @param addon The addon to scope the preference to
* @return The obtained preference value, or the defaultValue if none exists
*/
get: function(key, defaultValue, addon) {
if (key === GMPPrefs.KEY_APP_DISTRIBUTION ||
key === GMPPrefs.KEY_APP_DISTRIBUTION_VERSION) {
let prefValue = "default";
try {
prefValue = Services.prefs.getDefaultBranch(null).getCharPref(key);
} catch (e) {
// use default when pref not found
}
return prefValue;
}
return Preferences.get(this._getPrefKey(key, addon), defaultValue);
},
/**
* Sets the specified preference in relation to the specified addon
* @param key The GMPPrefs key value to use
* @param val The value to set
* @param addon The addon to scope the preference to
*/
set: function(key, val, addon) {
let log = getScopedLogger("GMPInstallManager.jsm GMPPrefs.set");
log.info("Setting pref: " + this._getPrefKey(key, addon) +
" to value: " + val);
return Preferences.set(this._getPrefKey(key, addon), val);
},
_getPrefKey: function(key, addon) {
return key.replace("{0}", addon || "");
},
/**
* List of keys which can be used in get and set
*/
KEY_ADDON_ENABLED: "media.{0}.enabled",
KEY_ADDON_LAST_UPDATE: "media.{0}.lastUpdate",
KEY_ADDON_VERSION: "media.{0}.version",
KEY_ADDON_AUTOUPDATE: "media.{0}.autoupdate",
KEY_ADDON_HIDDEN: "media.{0}.hidden",
KEY_URL: "media.gmp-manager.url",
KEY_URL_OVERRIDE: "media.gmp-manager.url.override",
KEY_CERT_CHECKATTRS: "media.gmp-manager.cert.checkAttributes",
KEY_CERT_REQUIREBUILTIN: "media.gmp-manager.cert.requireBuiltIn",
KEY_UPDATE_LAST_CHECK: "media.gmp-manager.lastCheck",
KEY_UPDATE_SECONDS_BETWEEN_CHECKS: "media.gmp-manager.secondsBetweenChecks",
KEY_APP_DISTRIBUTION: "distribution.id",
KEY_APP_DISTRIBUTION_VERSION: "distribution.version",
KEY_BUILDID: "media.gmp-manager.buildID",
CERTS_BRANCH: "media.gmp-manager.certs."
};
// This is copied directly from nsUpdateService.js
// It is used for calculating the URL string w/ var replacement.
// TODO: refactor this out somewhere else
@ -417,11 +347,11 @@ GMPInstallManager.prototype = {
return now - lastCheck;
},
get _isEMEEnabled() {
return Preferences.get(EME_ENABLED, true);
return GMPPrefs.get(GMPPrefs.KEY_EME_ENABLED, true);
},
_isAddonUpdateEnabled: function(aAddon) {
return GMPPrefs.get(GMPPrefs.KEY_ADDON_ENABLED, true, aAddon) &&
GMPPrefs.get(GMPPrefs.KEY_ADDON_AUTOUPDATE, true, aAddon);
return GMPPrefs.get(GMPPrefs.KEY_PLUGIN_ENABLED, true, aAddon) &&
GMPPrefs.get(GMPPrefs.KEY_PLUGIN_AUTOUPDATE, true, aAddon);
},
_updateLastCheck: function() {
let now = Math.round(Date.now() / 1000);
@ -452,7 +382,7 @@ GMPInstallManager.prototype = {
"new or updated GMPs.");
} else {
let secondsBetweenChecks =
GMPPrefs.get(GMPPrefs.KEY_UPDATE_SECONDS_BETWEEN_CHECKS,
GMPPrefs.get(GMPPrefs.KEY_SECONDS_BETWEEN_CHECKS,
DEFAULT_SECONDS_BETWEEN_CHECKS)
let secondsSinceLast = this._getTimeSinceLastCheck();
log.info("Last check was: " + secondsSinceLast +
@ -470,19 +400,14 @@ GMPInstallManager.prototype = {
let addonsToInstall = gmpAddons.filter(function(gmpAddon) {
log.info("Found addon: " + gmpAddon.toString());
if (gmpAddon.isHidden || !gmpAddon.isValid || gmpAddon.isInstalled) {
log.info("Addon hidden, invalid or already installed.");
return false;
}
// We're dealing with an EME GMP if the id starts with "gmp-eme-".
if (gmpAddon.id.indexOf("gmp-eme-") == 0 && !this._isEMEEnabled) {
log.info("Auto-update is off for all EME plugins, skipping check.");
if (!gmpAddon.isValid || GMPUtils.isPluginHidden(gmpAddon) ||
gmpAddon.isInstalled) {
log.info("Addon invalid, hidden or already installed.");
return false;
}
let addonUpdateEnabled = false;
if (GMP_ADDONS.indexOf(gmpAddon.id) >= 0) {
if (GMP_PLUGIN_IDS.indexOf(gmpAddon.id) >= 0) {
addonUpdateEnabled = this._isAddonUpdateEnabled(gmpAddon.id);
if (!addonUpdateEnabled) {
log.info("Auto-update is off for " + gmpAddon.id +
@ -564,7 +489,7 @@ GMPInstallManager.prototype = {
let certs = null;
if (!Services.prefs.prefHasUserValue(GMPPrefs.KEY_URL_OVERRIDE) &&
GMPPrefs.get(GMPPrefs.KEY_CERT_CHECKATTRS, true)) {
certs = gCertUtils.readCertPrefs(GMPPrefs.CERTS_BRANCH);
certs = gCertUtils.readCertPrefs(GMPPrefs.KEY_CERTS_BRANCH);
}
let allowNonBuiltIn = !GMPPrefs.get(GMPPrefs.KEY_CERT_REQUIREBUILTIN,
@ -751,11 +676,11 @@ GMPAddon.prototype = {
},
get isInstalled() {
return this.version &&
GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, "", this.id) === this.version;
GMPPrefs.get(GMPPrefs.KEY_PLUGIN_VERSION, "", this.id) === this.version;
},
get isEME() {
return this.id.indexOf("gmp-eme-") == 0;
},
get isHidden() {
return GMPPrefs.get(GMPPrefs.KEY_ADDON_HIDDEN, false, this.id);
}
};
/**
* Constructs a GMPExtractor object which is used to extract a GMP zip
@ -959,10 +884,10 @@ GMPDownloader.prototype = {
installPromise.then(extractedPaths => {
// Success, set the prefs
let now = Math.round(Date.now() / 1000);
GMPPrefs.set(GMPPrefs.KEY_ADDON_LAST_UPDATE, now, gmpAddon.id);
GMPPrefs.set(GMPPrefs.KEY_PLUGIN_LAST_UPDATE, now, gmpAddon.id);
// Setting the version pref signals installation completion to consumers,
// if you need to set other prefs etc. do it before this.
GMPPrefs.set(GMPPrefs.KEY_ADDON_VERSION, gmpAddon.version,
GMPPrefs.set(GMPPrefs.KEY_PLUGIN_VERSION, gmpAddon.version,
gmpAddon.id);
this._deferred.resolve(extractedPaths);
}, err => {

View File

@ -0,0 +1,157 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const {classes: Cc, interfaces: Ci, results: Cr, utils: Cu, manager: Cm} =
Components;
this.EXPORTED_SYMBOLS = [ "EME_ADOBE_ID",
"GMP_PLUGIN_IDS",
"GMPPrefs",
"GMPUtils",
"OPEN_H264_ID" ];
Cu.import("resource://gre/modules/Preferences.jsm");
Cu.import("resource://gre/modules/Services.jsm");
// GMP IDs
const OPEN_H264_ID = "gmp-gmpopenh264";
const EME_ADOBE_ID = "gmp-eme-adobe";
const GMP_PLUGIN_IDS = [ OPEN_H264_ID, EME_ADOBE_ID ];
this.GMPUtils = {
/**
* Checks whether or not a given plugin is hidden. Hidden plugins are neither
* downloaded nor displayed in the addons manager.
* @param aPlugin
* The plugin to check.
*/
isPluginHidden: function(aPlugin) {
if (aPlugin.isEME) {
if (this._isPluginSupported(aPlugin) ||
this._isPluginForcedVisible(aPlugin)) {
return !GMPPrefs.get(GMPPrefs.KEY_EME_ENABLED, true);
} else {
return true;
}
}
return false;
},
/**
* Checks whether or not a given plugin is supported by the current OS.
* @param aPlugin
* The plugin to check.
*/
_isPluginSupported: function(aPlugin) {
if (aPlugin.id == EME_ADOBE_ID) {
if (Services.appinfo.OS == "WINNT") {
return Services.sysinfo.getPropertyAsInt32("version") >= 6;
} else {
return false;
}
}
return true;
},
/**
* 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.
* @param aPlugin
* The plugin to check.
*/
_isPluginForcedVisible: function(aPlugin) {
return GMPPrefs.get(GMPPrefs.KEY_PLUGIN_FORCEVISIBLE, false, aPlugin.id);
},
};
/**
* 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",
KEY_PLUGIN_AUTOUPDATE: "media.{0}.autoupdate",
KEY_PLUGIN_FORCEVISIBLE: "media.{0}.forcevisible",
KEY_URL: "media.gmp-manager.url",
KEY_URL_OVERRIDE: "media.gmp-manager.url.override",
KEY_CERT_CHECKATTRS: "media.gmp-manager.cert.checkAttributes",
KEY_CERT_REQUIREBUILTIN: "media.gmp-manager.cert.requireBuiltIn",
KEY_UPDATE_LAST_CHECK: "media.gmp-manager.lastCheck",
KEY_SECONDS_BETWEEN_CHECKS: "media.gmp-manager.secondsBetweenChecks",
KEY_APP_DISTRIBUTION: "distribution.id",
KEY_APP_DISTRIBUTION_VERSION: "distribution.version",
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",
/**
* Obtains the specified preference in relation to the specified plugin.
* @param aKey The preference key value to use.
* @param aDefaultValue The default value if no preference exists.
* @param aPlugin The plugin to scope the preference to.
* @return The obtained preference value, or the defaultValue if none exists.
*/
get: function(aKey, aDefaultValue, aPlugin) {
if (aKey === this.KEY_APP_DISTRIBUTION ||
aKey === this.KEY_APP_DISTRIBUTION_VERSION) {
let prefValue = "default";
try {
prefValue = Services.prefs.getDefaultBranch(null).getCharPref(aKey);
} catch (e) {
// use default when pref not found
}
return prefValue;
}
return Preferences.get(this.getPrefKey(aKey, aPlugin), aDefaultValue);
},
/**
* Sets the specified preference in relation to the specified plugin.
* @param aKey The preference key value to use.
* @param aVal The value to set.
* @param aPlugin The plugin to scope the preference to.
*/
set: function(aKey, aVal, aPlugin) {
Preferences.set(this.getPrefKey(aKey, aPlugin), aVal);
},
/**
* Checks whether or not the specified preference is set in relation to the
* specified plugin.
* @param aKey The preference key value to use.
* @param aPlugin The plugin to scope the preference to.
* @return true if the preference is set, false otherwise.
*/
isSet: function(aKey, aPlugin) {
return Preferences.isSet(this.getPrefKey(aKey, aPlugin));
},
/**
* Resets the specified preference in relation to the specified plugin to its
* default.
* @param aKey The preference key value to use.
* @param aPlugin The plugin to scope the preference to.
*/
reset: function(aKey, aPlugin) {
Preferences.reset(this.getPrefKey(aKey, aPlugin));
},
/**
* Scopes the specified preference key to the specified plugin.
* @param aKey The preference key value to use.
* @param aPlugin The plugin to scope the preference to.
* @return A preference key scoped to the specified plugin.
*/
getPrefKey: function(aKey, aPlugin) {
return aKey.replace("{0}", aPlugin || "");
},
};

View File

@ -67,6 +67,7 @@ EXTRA_JS_MODULES += [
EXTRA_PP_JS_MODULES += [
'CertUtils.jsm',
'GMPInstallManager.jsm',
'GMPUtils.jsm',
'ResetProfile.jsm',
'secondscreen/RokuApp.jsm',
'Services.jsm',

View File

@ -17,6 +17,7 @@ Cu.import("resource://gre/modules/Preferences.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/GMPUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(
this, "GMPInstallManager", "resource://gre/modules/GMPInstallManager.jsm");
@ -30,27 +31,12 @@ const NS_GRE_DIR = "GreD";
const CLEARKEY_PLUGIN_ID = "gmp-clearkey";
const CLEARKEY_VERSION = "0.1";
/**
* Keys which can be used via GMPPrefs.
*/
const KEY_PROVIDER_ENABLED = "media.gmp-provider.enabled";
const KEY_PROVIDER_LASTCHECK = "media.gmp-manager.lastCheck";
const KEY_LOG_BASE = "media.gmp.log.";
const KEY_LOGGING_LEVEL = KEY_LOG_BASE + "level";
const KEY_LOGGING_DUMP = KEY_LOG_BASE + "dump";
const KEY_EME_ENABLED = "media.eme.enabled"; // Global pref to enable/disable all EME plugins
const KEY_PLUGIN_ENABLED = "media.{0}.enabled";
const KEY_PLUGIN_LAST_UPDATE = "media.{0}.lastUpdate";
const KEY_PLUGIN_VERSION = "media.{0}.version";
const KEY_PLUGIN_AUTOUPDATE = "media.{0}.autoupdate";
const KEY_PLUGIN_HIDDEN = "media.{0}.hidden";
const GMP_LICENSE_INFO = "gmp_license_info";
const GMP_LEARN_MORE = "learn_more_label";
const GMP_PLUGINS = [
{
id: "gmp-gmpopenh264",
id: OPEN_H264_ID,
name: "openH264_name",
description: "openH264_description2",
// The following licenseURL is part of an awful hack to include the OpenH264
@ -61,7 +47,7 @@ const GMP_PLUGINS = [
optionsURL: "chrome://mozapps/content/extensions/gmpPrefs.xul"
},
{
id: "gmp-eme-adobe",
id: EME_ADOBE_ID,
name: "eme-adobe_name",
description: "eme-adobe_description",
// The following learnMoreURL is another hack to be able to support a SUMO page for this
@ -88,9 +74,9 @@ function configureLogging() {
gLogger = Log.repository.getLogger("Toolkit.GMP");
gLogger.addAppender(new Log.ConsoleAppender(new Log.BasicFormatter()));
}
gLogger.level = GMPPrefs.get(KEY_LOGGING_LEVEL, Log.Level.Warn);
gLogger.level = GMPPrefs.get(GMPPrefs.KEY_LOGGING_LEVEL, Log.Level.Warn);
let logDumping = GMPPrefs.get(KEY_LOGGING_DUMP, false);
let logDumping = GMPPrefs.get(GMPPrefs.KEY_LOGGING_DUMP, false);
if (logDumping != !!gLogAppenderDump) {
if (logDumping) {
gLogAppenderDump = new Log.DumpAppender(new Log.BasicFormatter());
@ -102,64 +88,7 @@ function configureLogging() {
}
}
/**
* Manages preferences for GMP addons
*/
let GMPPrefs = {
/**
* Obtains the specified preference in relation to the specified plugin.
* @param aKey The preference key value to use.
* @param aDefaultValue The default value if no preference exists.
* @param aPlugin The plugin to scope the preference to.
* @return The obtained preference value, or the defaultValue if none exists.
*/
get: function(aKey, aDefaultValue, aPlugin) {
return Preferences.get(this.getPrefKey(aKey, aPlugin), aDefaultValue);
},
/**
* Sets the specified preference in relation to the specified plugin.
* @param aKey The preference key value to use.
* @param aVal The value to set.
* @param aPlugin The plugin to scope the preference to.
*/
set: function(aKey, aVal, aPlugin) {
let log =
Log.repository.getLoggerWithMessagePrefix("Toolkit.GMP",
"GMPProvider.jsm " +
"GMPPrefs.set ");
log.trace("Setting pref: " + this.getPrefKey(aKey, aPlugin) +
" to value: " + aVal);
Preferences.set(this.getPrefKey(aKey, aPlugin), aVal);
},
/**
* Checks whether or not the specified preference is set in relation to the
* specified plugin.
* @param aKey The preference key value to use.
* @param aPlugin The plugin to scope the preference to.
* @return true if the preference is set, false otherwise.
*/
isSet: function(aKey, aPlugin) {
return Preferences.isSet(GMPPrefs.getPrefKey(aKey, aPlugin));
},
/**
* Resets the specified preference in relation to the specified plugin to its
* default.
* @param aKey The preference key value to use.
* @param aPlugin The plugin to scope the preference to.
*/
reset: function(aKey, aPlugin) {
Preferences.reset(this.getPrefKey(aKey, aPlugin));
},
/**
* Scopes the specified preference key to the specified plugin.
* @param aKey The preference key value to use.
* @param aPlugin The plugin to scope the preference to.
* @return A preference key scoped to the specified plugin.
*/
getPrefKey: function(aKey, aPlugin) {
return aKey.replace("{0}", aPlugin || "");
},
};
/**
* The GMPWrapper provides the info for the various GMP plugins to public
@ -171,13 +100,15 @@ function GMPWrapper(aPluginInfo) {
Log.repository.getLoggerWithMessagePrefix("Toolkit.GMP",
"GMPWrapper(" +
this._plugin.id + ") ");
Preferences.observe(GMPPrefs.getPrefKey(KEY_PLUGIN_ENABLED, this._plugin.id),
Preferences.observe(GMPPrefs.getPrefKey(GMPPrefs.KEY_PLUGIN_ENABLED,
this._plugin.id),
this.onPrefEnabledChanged, this);
Preferences.observe(GMPPrefs.getPrefKey(KEY_PLUGIN_VERSION, this._plugin.id),
Preferences.observe(GMPPrefs.getPrefKey(GMPPrefs.KEY_PLUGIN_VERSION,
this._plugin.id),
this.onPrefVersionChanged, this);
if (this._plugin.isEME) {
Preferences.observe(KEY_EME_ENABLED, this.onPrefEMEGlobalEnabledChanged,
this);
Preferences.observe(GMPPrefs.KEY_EME_ENABLED,
this.onPrefEMEGlobalEnabledChanged, this);
}
}
@ -194,8 +125,8 @@ GMPWrapper.prototype = {
if (!this._gmpPath && this.isInstalled) {
this._gmpPath = OS.Path.join(OS.Constants.Path.profileDir,
this._plugin.id,
GMPPrefs.get(KEY_PLUGIN_VERSION, null,
this._plugin.id));
GMPPrefs.get(GMPPrefs.KEY_PLUGIN_VERSION,
null, this._plugin.id));
}
return this._gmpPath;
},
@ -210,12 +141,12 @@ GMPWrapper.prototype = {
get description() { return this._plugin.description; },
get fullDescription() { return this._plugin.fullDescription; },
get version() { return GMPPrefs.get(KEY_PLUGIN_VERSION, null,
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(KEY_EME_ENABLED, true)) {
if (this._plugin.isEME && !GMPPrefs.get(GMPPrefs.KEY_EME_ENABLED, true)) {
// If "media.eme.enabled" is false, all EME plugins are disabled.
return true;
}
@ -223,9 +154,10 @@ GMPWrapper.prototype = {
},
get userDisabled() {
return !GMPPrefs.get(KEY_PLUGIN_ENABLED, true, this._plugin.id);
return !GMPPrefs.get(GMPPrefs.KEY_PLUGIN_ENABLED, true, this._plugin.id);
},
set userDisabled(aVal) { GMPPrefs.set(KEY_PLUGIN_ENABLED, aVal === false,
set userDisabled(aVal) { GMPPrefs.set(GMPPrefs.KEY_PLUGIN_ENABLED,
aVal === false,
this._plugin.id); },
get blocklistState() { return Ci.nsIBlocklistService.STATE_NOT_BLOCKED; },
@ -246,7 +178,7 @@ GMPWrapper.prototype = {
},
get updateDate() {
let time = Number(GMPPrefs.get(KEY_PLUGIN_LAST_UPDATE, null,
let time = Number(GMPPrefs.get(GMPPrefs.KEY_PLUGIN_LAST_UPDATE, null,
this._plugin.id));
if (time !== NaN && this.isInstalled) {
return new Date(time * 1000)
@ -275,21 +207,21 @@ GMPWrapper.prototype = {
},
get applyBackgroundUpdates() {
if (!GMPPrefs.isSet(KEY_PLUGIN_AUTOUPDATE, this._plugin.id)) {
if (!GMPPrefs.isSet(GMPPrefs.KEY_PLUGIN_AUTOUPDATE, this._plugin.id)) {
return AddonManager.AUTOUPDATE_DEFAULT;
}
return GMPPrefs.get(KEY_PLUGIN_AUTOUPDATE, true, this._plugin.id) ?
return GMPPrefs.get(GMPPrefs.KEY_PLUGIN_AUTOUPDATE, true, this._plugin.id) ?
AddonManager.AUTOUPDATE_ENABLE : AddonManager.AUTOUPDATE_DISABLE;
},
set applyBackgroundUpdates(aVal) {
if (aVal == AddonManager.AUTOUPDATE_DEFAULT) {
GMPPrefs.reset(KEY_PLUGIN_AUTOUPDATE, this._plugin.id);
GMPPrefs.reset(GMPPrefs.KEY_PLUGIN_AUTOUPDATE, this._plugin.id);
} else if (aVal == AddonManager.AUTOUPDATE_ENABLE) {
GMPPrefs.set(KEY_PLUGIN_AUTOUPDATE, true, this._plugin.id);
GMPPrefs.set(GMPPrefs.KEY_PLUGIN_AUTOUPDATE, true, this._plugin.id);
} else if (aVal == AddonManager.AUTOUPDATE_DISABLE) {
GMPPrefs.set(KEY_PLUGIN_AUTOUPDATE, false, this._plugin.id);
GMPPrefs.set(GMPPrefs.KEY_PLUGIN_AUTOUPDATE, false, this._plugin.id);
}
},
@ -307,7 +239,7 @@ GMPWrapper.prototype = {
}
let secSinceLastCheck =
Date.now() / 1000 - Preferences.get(KEY_PROVIDER_LASTCHECK, 0);
Date.now() / 1000 - Preferences.get(GMPPrefs.KEY_PROVIDER_LASTCHECK, 0);
if (secSinceLastCheck <= SEC_IN_A_DAY) {
this._log.trace("findUpdates() - " + this._plugin.id +
" - last check was less then a day ago");
@ -400,6 +332,25 @@ GMPWrapper.prototype = {
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.removePluginDirectory(this._gmpPath);
}
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.userDisabled) {
this._handleEnabledChanged();
}
@ -422,12 +373,13 @@ GMPWrapper.prototype = {
AddonManagerPrivate.callInstallListeners("onExternalInstall", null, this,
null, false);
AddonManagerPrivate.callAddonListeners("onInstalling", this, false);
this._gmpPath = null;
if (this.isInstalled) {
this._gmpPath = OS.Path.join(OS.Constants.Path.profileDir,
this._plugin.id,
GMPPrefs.get(KEY_PLUGIN_VERSION, null,
this._plugin.id));
GMPPrefs.get(GMPPrefs.KEY_PLUGIN_VERSION,
null, this._plugin.id));
}
if (this._gmpPath && this.isActive) {
this._log.info("onPrefVersionChanged() - registering gmp directory " +
@ -438,13 +390,15 @@ GMPWrapper.prototype = {
},
shutdown: function() {
Preferences.ignore(GMPPrefs.getPrefKey(KEY_PLUGIN_ENABLED, this._plugin.id),
Preferences.ignore(GMPPrefs.getPrefKey(GMPPrefs.KEY_PLUGIN_ENABLED,
this._plugin.id),
this.onPrefEnabledChanged, this);
Preferences.ignore(GMPPrefs.getPrefKey(KEY_PLUGIN_VERSION, this._plugin.id),
Preferences.ignore(GMPPrefs.getPrefKey(GMPPrefs.KEY_PLUGIN_VERSION,
this._plugin.id),
this.onPrefVersionChanged, this);
if (this._plugin.isEME) {
Preferences.ignore(KEY_EME_ENABLED, this.onPrefEMEGlobalEnabledChanged,
this);
Preferences.ignore(GMPPrefs.KEY_EME_ENABLED,
this.onPrefEMEGlobalEnabledChanged, this);
}
return this._updateTask;
},
@ -462,7 +416,7 @@ let GMPProvider = {
let telemetry = {};
this.buildPluginList();
Preferences.observe(KEY_LOG_BASE, configureLogging);
Preferences.observe(GMPPrefs.KEY_LOG_BASE, configureLogging);
for (let [id, plugin] of this._plugins) {
let wrapper = plugin.wrapper;
@ -490,7 +444,7 @@ let GMPProvider = {
}
}
if (Preferences.get(KEY_EME_ENABLED, false)) {
if (Preferences.get(GMPPrefs.KEY_EME_ENABLED, false)) {
try {
let greDir = Services.dirsvc.get(NS_GRE_DIR,
Ci.nsILocalFile);
@ -510,7 +464,7 @@ let GMPProvider = {
shutdown: function() {
this._log.trace("shutdown");
Preferences.ignore(KEY_LOG_BASE, configureLogging);
Preferences.ignore(GMPPrefs.KEY_LOG_BASE, configureLogging);
let shutdownTask = Task.spawn(function* GMPProvider_shutdownTask() {
this._log.trace("shutdown - shutdownTask");
@ -541,7 +495,7 @@ let GMPProvider = {
}
let plugin = this._plugins.get(aId);
if (plugin) {
if (plugin && !GMPUtils.isPluginHidden(plugin)) {
aCallback(plugin.wrapper);
} else {
aCallback(null);
@ -555,12 +509,13 @@ let GMPProvider = {
return;
}
let results = [p.wrapper for ([id, p] of this._plugins)];
let results = [p.wrapper for ([id, p] of this._plugins)
if (!GMPUtils.isPluginHidden(p))];
aCallback(results);
},
get isEnabled() {
return GMPPrefs.get(KEY_PROVIDER_ENABLED, false);
return GMPPrefs.get(GMPPrefs.KEY_PROVIDER_ENABLED, false);
},
generateFullDescription: function(aPlugin) {
@ -576,26 +531,21 @@ let GMPProvider = {
},
buildPluginList: function() {
let map = new Map();
GMP_PLUGINS.forEach(aPlugin => {
// Only show GMPs in addon manager that aren't hidden.
if (!GMPPrefs.get(KEY_PLUGIN_HIDDEN, false, aPlugin.id)) {
let plugin = {
id: aPlugin.id,
name: pluginsBundle.GetStringFromName(aPlugin.name),
description: pluginsBundle.GetStringFromName(aPlugin.description),
homepageURL: aPlugin.homepageURL,
optionsURL: aPlugin.optionsURL,
wrapper: null,
isEME: aPlugin.isEME
};
plugin.fullDescription = this.generateFullDescription(aPlugin);
plugin.wrapper = new GMPWrapper(plugin);
map.set(plugin.id, plugin);
}
}, this);
this._plugins = map;
this._plugins = new Map();
for (let aPlugin of GMP_PLUGINS) {
let plugin = {
id: aPlugin.id,
name: pluginsBundle.GetStringFromName(aPlugin.name),
description: pluginsBundle.GetStringFromName(aPlugin.description),
homepageURL: aPlugin.homepageURL,
optionsURL: aPlugin.optionsURL,
wrapper: null,
isEME: aPlugin.isEME,
};
plugin.fullDescription = this.generateFullDescription(aPlugin);
plugin.wrapper = new GMPWrapper(plugin);
this._plugins.set(plugin.id, plugin);
}
},
};