summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/internal/GMPProvider.jsm
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/mozapps/extensions/internal/GMPProvider.jsm')
-rw-r--r--toolkit/mozapps/extensions/internal/GMPProvider.jsm199
1 files changed, 57 insertions, 142 deletions
diff --git a/toolkit/mozapps/extensions/internal/GMPProvider.jsm b/toolkit/mozapps/extensions/internal/GMPProvider.jsm
index 9bb34a7af..52affa9ba 100644
--- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm
@@ -12,17 +12,12 @@ this.EXPORTED_SYMBOLS = [];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/AddonManager.jsm");
-/* globals AddonManagerPrivate*/
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Preferences.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
-/* globals OS*/
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/GMPUtils.jsm");
-/* globals EME_ADOBE_ID, GMP_PLUGIN_IDS, GMPPrefs, GMPUtils, OPEN_H264_ID, WIDEVINE_ID */
-Cu.import("resource://gre/modules/AppConstants.jsm");
-Cu.import("resource://gre/modules/UpdateUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(
this, "GMPInstallManager", "resource://gre/modules/GMPInstallManager.jsm");
@@ -41,8 +36,6 @@ const CLEARKEY_PLUGIN_ID = "gmp-clearkey";
const CLEARKEY_VERSION = "0.1";
const GMP_LICENSE_INFO = "gmp_license_info";
-const GMP_PRIVACY_INFO = "gmp_privacy_info";
-const GMP_LEARN_MORE = "learn_more_label";
const GMP_PLUGINS = [
{
@@ -54,33 +47,17 @@ const GMP_PLUGINS = [
// localisation.
licenseURL: "chrome://mozapps/content/extensions/OpenH264-license.txt",
homepageURL: "http://www.openh264.org/",
- optionsURL: "chrome://mozapps/content/extensions/gmpPrefs.xul",
+ optionsURL: "chrome://mozapps/content/extensions/gmpPrefs.xul"
},
{
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
- // feature.
- get learnMoreURL() {
- return Services.urlFormatter.formatURLPref("app.support.baseURL") + "drm-content";
- },
licenseURL: "http://help.adobe.com/en_US/primetime/drm/HTML5_CDM_EULA/index.html",
homepageURL: "http://help.adobe.com/en_US/primetime/drm/HTML5_CDM",
optionsURL: "chrome://mozapps/content/extensions/gmpPrefs.xul",
- isEME: true,
- },
- {
- id: WIDEVINE_ID,
- name: "widevine_description",
- // Describe the purpose of both CDMs in the same way.
- description: "eme-adobe_description",
- 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);
XPCOMUtils.defineLazyGetter(this, "pluginsBundle",
() => Services.strings.createBundle("chrome://global/locale/plugins.properties"));
@@ -170,17 +147,13 @@ GMPWrapper.prototype = {
get version() { return GMPPrefs.get(GMPPrefs.KEY_PLUGIN_VERSION, null,
this._plugin.id); },
- get isActive() {
- return !this.appDisabled &&
- !this.userDisabled &&
- !GMPUtils.isPluginHidden(this._plugin);
- },
+ 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;
+ return false;
},
get userDisabled() {
@@ -210,7 +183,7 @@ GMPWrapper.prototype = {
get updateDate() {
let time = Number(GMPPrefs.get(GMPPrefs.KEY_PLUGIN_LAST_UPDATE, null,
this._plugin.id));
- if (!isNaN(time) && this.isInstalled) {
+ if (time !== NaN && this.isInstalled) {
return new Date(time * 1000)
}
return null;
@@ -287,12 +260,14 @@ GMPWrapper.prototype = {
return this._updateTask;
}
- this._updateTask = Task.spawn(function*() {
+ this._updateTask = Task.spawn(function* GMPProvider_updateTask() {
this._log.trace("findUpdates() - updateTask");
try {
let installManager = new GMPInstallManager();
- let res = yield installManager.checkForAddons();
- let update = res.gmpAddons.find(addon => addon.id === this._plugin.id);
+ let gmpAddons = yield installManager.checkForAddons();
+ let update = gmpAddons.find(function(aAddon) {
+ return aAddon.id === this._plugin.id;
+ }, this);
if (update && update.isValid && !update.isInstalled) {
this._log.trace("findUpdates() - found update for " +
this._plugin.id + ", installing");
@@ -338,9 +313,6 @@ GMPWrapper.prototype = {
},
_handleEnabledChanged: function() {
- this._log.info("_handleEnabledChanged() id=" +
- this._plugin.id + " isActive=" + this.isActive);
-
AddonManagerPrivate.callAddonListeners(this.isActive ?
"onEnabling" : "onDisabling",
this, false);
@@ -361,17 +333,11 @@ GMPWrapper.prototype = {
},
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 if (!GMPUtils.isPluginHidden(this._plugin)) {
+ } else {
AddonManagerPrivate.callInstallListeners("onExternalInstall", null, this,
null, false);
AddonManagerPrivate.callAddonListeners("onInstalling", this, false);
@@ -407,12 +373,12 @@ GMPWrapper.prototype = {
let parsedData;
try {
parsedData = JSON.parse(data);
- } catch (ex) {
+ } catch(ex) {
this._log.error("Malformed EME video message with data: " + data);
return;
}
let {status: status, keySystem: keySystem} = parsedData;
- if (status == "cdm-not-installed") {
+ if (status == "cdm-not-installed" || status == "cdm-insufficient-version") {
this.checkForUpdates(0);
}
},
@@ -458,8 +424,6 @@ GMPWrapper.prototype = {
gmpService.removeAndDeletePluginDirectory(this.gmpPath);
}
GMPPrefs.reset(GMPPrefs.KEY_PLUGIN_VERSION, this.id);
- GMPPrefs.reset(GMPPrefs.KEY_PLUGIN_ABI, this.id);
- GMPPrefs.reset(GMPPrefs.KEY_PLUGIN_LAST_UPDATE, this.id);
AddonManagerPrivate.callAddonListeners("onUninstalled", this);
},
@@ -477,56 +441,6 @@ GMPWrapper.prototype = {
}
return this._updateTask;
},
-
- _arePluginFilesOnDisk: function() {
- let fileExists = function(aGmpPath, aFileName) {
- let f = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
- let path = OS.Path.join(aGmpPath, aFileName);
- f.initWithPath(path);
- return f.exists();
- };
-
- let id = this._plugin.id.substring(4);
- let libName = AppConstants.DLL_PREFIX + id + AppConstants.DLL_SUFFIX;
- let infoName;
- if (this._plugin.id == WIDEVINE_ID) {
- infoName = "manifest.json";
- } else {
- infoName = id + ".info";
- }
-
- return fileExists(this.gmpPath, libName) &&
- fileExists(this.gmpPath, infoName) &&
- (this._plugin.id != EME_ADOBE_ID || fileExists(this.gmpPath, id + ".voucher"));
- },
-
- validate: function() {
- if (!this.isInstalled) {
- // Not installed -> Valid.
- return {
- installed: false,
- valid: true
- };
- }
-
- let abi = GMPPrefs.get(GMPPrefs.KEY_PLUGIN_ABI, UpdateUtils.ABI, this._plugin.id);
- if (abi != UpdateUtils.ABI) {
- // ABI doesn't match. Possibly this is a profile migrated across platforms
- // or from 32 -> 64 bit.
- return {
- installed: true,
- mismatchedABI: true,
- valid: false
- };
- }
-
- // Installed -> Check if files are missing.
- let filesOnDisk = this._arePluginFilesOnDisk();
- return {
- installed: true,
- valid: filesOnDisk
- };
- },
};
var GMPProvider = {
@@ -538,6 +452,7 @@ var GMPProvider = {
configureLogging();
this._log = Log.repository.getLoggerWithMessagePrefix("Toolkit.GMP",
"GMPProvider.");
+ let telemetry = {};
this.buildPluginList();
this.ensureProperCDMInstallState();
@@ -551,50 +466,47 @@ var GMPProvider = {
gmpPath);
if (gmpPath && isEnabled) {
- let validation = wrapper.validate();
- if (validation.mismatchedABI) {
- this._log.info("startup - gmp " + plugin.id +
- " mismatched ABI, uninstalling");
- wrapper.uninstallPlugin();
- continue;
- }
- if (!validation.valid) {
- this._log.info("startup - gmp " + plugin.id +
- " invalid, uninstalling");
- wrapper.uninstallPlugin();
- continue;
- }
this._log.info("startup - adding gmp directory " + gmpPath);
try {
gmpService.addPluginDirectory(gmpPath);
- } catch (e) {
- if (e.name != 'NS_ERROR_NOT_AVAILABLE')
- throw e;
+ } catch (e if e.name == 'NS_ERROR_NOT_AVAILABLE') {
this._log.warn("startup - adding gmp directory failed with " +
e.name + " - sandboxing not available?", e);
}
}
+
+ if (this.isEnabled) {
+ telemetry[id] = {
+ userDisabled: wrapper.userDisabled,
+ version: wrapper.version,
+ applyBackgroundUpdates: wrapper.applyBackgroundUpdates,
+ };
+ }
}
- 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);
+ 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);
+ }
}
+
+ AddonManagerPrivate.setTelemetryDetails("GMP", telemetry);
},
shutdown: function() {
this._log.trace("shutdown");
Preferences.ignore(GMPPrefs.KEY_LOG_BASE, configureLogging);
- let shutdownTask = Task.spawn(function*() {
+ let shutdownTask = Task.spawn(function* GMPProvider_shutdownTask() {
this._log.trace("shutdown - shutdownTask");
let shutdownSucceeded = true;
@@ -637,10 +549,16 @@ var GMPProvider = {
return;
}
- let results = Array.from(this._plugins.values())
- .filter(p => !GMPUtils.isPluginHidden(p))
- .map(p => p.wrapper);
-
+ // Tycho:
+ // let results = [p.wrapper for ([id, p] of this._plugins)
+ // if (!GMPUtils.isPluginHidden(p))];
+ let results = [];
+ for (let [id, p] of this._plugins) {
+ if (!GMPUtils.isPluginHidden(p)) {
+ results.push(p.wrapper);
+ }
+ }
+
aCallback(results);
},
@@ -648,20 +566,14 @@ var GMPProvider = {
return GMPPrefs.get(GMPPrefs.KEY_PROVIDER_ENABLED, false);
},
- generateFullDescription: function(aPlugin) {
- let rv = [];
- for (let [urlProp, labelId] of [["learnMoreURL", GMP_LEARN_MORE],
- ["licenseURL", aPlugin.id == WIDEVINE_ID ?
- GMP_PRIVACY_INFO : GMP_LICENSE_INFO]]) {
- if (aPlugin[urlProp]) {
- let label = pluginsBundle.GetStringFromName(labelId);
- rv.push(`<xhtml:a href="${aPlugin[urlProp]}" target="_blank">${label}</xhtml:a>.`);
- }
- }
- return rv.length ? rv.join("<xhtml:br /><xhtml:br />") : undefined;
+ generateFullDescription: function(aLicenseURL, aLicenseInfo) {
+ return "<xhtml:a href=\"" + aLicenseURL + "\" target=\"_blank\">" +
+ aLicenseInfo + "</xhtml:a>."
},
buildPluginList: function() {
+ let licenseInfo = pluginsBundle.GetStringFromName(GMP_LICENSE_INFO);
+
this._plugins = new Map();
for (let aPlugin of GMP_PLUGINS) {
let plugin = {
@@ -673,7 +585,10 @@ var GMPProvider = {
wrapper: null,
isEME: aPlugin.isEME,
};
- plugin.fullDescription = this.generateFullDescription(aPlugin);
+ if (aPlugin.licenseURL) {
+ plugin.fullDescription =
+ this.generateFullDescription(aPlugin.licenseURL, licenseInfo);
+ }
plugin.wrapper = new GMPWrapper(plugin);
this._plugins.set(plugin.id, plugin);
}