Bug 1136707 - [Part1] Make pref 'media.eme.enabled' only affect practical DRMs. r=cpearce
MozReview-Commit-ID: 5XeAelzLbIc
--- a/dom/media/eme/EMEUtils.cpp
+++ b/dom/media/eme/EMEUtils.cpp
@@ -143,9 +143,15 @@ KeySystemToGMPName(const nsAString& aKey
}
if (aKeySystem.EqualsLiteral("com.widevine.alpha")) {
return NS_LITERAL_STRING("gmp-widevinecdm");
}
MOZ_ASSERT(false, "We should only call this for known GMPs");
return EmptyString();
}
+bool
+IsClearkeyKeySystem(const nsAString& aKeySystem)
+{
+ return aKeySystem.EqualsLiteral("org.w3.clearkey");
+}
+
} // namespace mozilla
--- a/dom/media/eme/EMEUtils.h
+++ b/dom/media/eme/EMEUtils.h
@@ -97,11 +97,14 @@ struct ArrayData {
//
// Only call this on a properly initialized ArrayBufferViewOrArrayBuffer.
ArrayData
GetArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView);
nsString
KeySystemToGMPName(const nsAString& aKeySystem);
+bool
+IsClearkeyKeySystem(const nsAString& aKeySystem);
+
} // namespace mozilla
#endif // EME_LOG_H_
--- a/dom/media/eme/MediaKeySystemAccess.cpp
+++ b/dom/media/eme/MediaKeySystemAccess.cpp
@@ -263,29 +263,25 @@ EnsureMinCDMVersion(mozIGeckoMediaPlugin
/* static */
MediaKeySystemStatus
MediaKeySystemAccess::GetKeySystemStatus(const nsAString& aKeySystem,
int32_t aMinCdmVersion,
nsACString& aOutMessage,
nsACString& aOutCdmVersion)
{
- MOZ_ASSERT(MediaPrefs::EMEEnabled());
+ MOZ_ASSERT(MediaPrefs::EMEEnabled() || IsClearkeyKeySystem(aKeySystem));
nsCOMPtr<mozIGeckoMediaPluginService> mps =
do_GetService("@mozilla.org/gecko-media-plugin-service;1");
if (NS_WARN_IF(!mps)) {
aOutMessage = NS_LITERAL_CSTRING("Failed to get GMP service");
return MediaKeySystemStatus::Error;
}
if (aKeySystem.EqualsLiteral("org.w3.clearkey")) {
- if (!Preferences::GetBool("media.eme.clearkey.enabled", true)) {
- aOutMessage = NS_LITERAL_CSTRING("ClearKey was disabled");
- return MediaKeySystemStatus::Cdm_disabled;
- }
return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
}
if (Preferences::GetBool("media.gmp-eme-adobe.visible", false)) {
if (aKeySystem.EqualsLiteral("com.adobe.primetime")) {
if (!Preferences::GetBool("media.gmp-eme-adobe.enabled", false)) {
aOutMessage = NS_LITERAL_CSTRING("Adobe EME disabled");
return MediaKeySystemStatus::Cdm_disabled;
--- a/dom/media/eme/MediaKeySystemAccessManager.cpp
+++ b/dom/media/eme/MediaKeySystemAccessManager.cpp
@@ -107,18 +107,20 @@ MediaKeySystemAccessManager::Request(Det
aPromise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR,
NS_LITERAL_CSTRING("Key system string is invalid,"
" or key system is unsupported"));
diagnostics.StoreMediaKeySystemAccess(mWindow->GetExtantDoc(),
aKeySystem, false, __func__);
return;
}
- if (!MediaPrefs::EMEEnabled()) {
+ if (!MediaPrefs::EMEEnabled() && !IsClearkeyKeySystem(aKeySystem)) {
// EME disabled by user, send notification to chrome so UI can inform user.
+ // Clearkey is allowed even when EME is disabled because we want the pref
+ // "media.eme.enabled" only taking effect on proprietary DRMs.
MediaKeySystemAccess::NotifyObservers(mWindow,
aKeySystem,
MediaKeySystemStatus::Api_disabled);
aPromise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR,
NS_LITERAL_CSTRING("EME has been preffed off"));
diagnostics.StoreMediaKeySystemAccess(mWindow->GetExtantDoc(),
aKeySystem, false, __func__);
return;
--- a/dom/media/test/test_eme_request_notifications.html
+++ b/dom/media/test/test_eme_request_notifications.html
@@ -57,46 +57,39 @@ function Test(test) {
);
});
});
}
var tests = [
{
keySystem: CLEARKEY_KEYSYSTEM,
- shouldPass: false,
- expectedStatus: 'api-disabled',
- prefs: [["media.eme.enabled", false], ["media.eme.clearkey.enabled", true]]
+ shouldPass: true,
+ expectedStatus: 'cdm-created',
+ prefs: [["media.eme.enabled", false]]
},
{
- keySystem: CLEARKEY_KEYSYSTEM,
- shouldPass: false,
- expectedStatus: 'cdm-disabled',
- prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", false]]
- },
- {
- keySystem: CLEARKEY_KEYSYSTEM + '.10000' , // A stupendously high min CDM version, presumably not installed.
+ keySystem: CLEARKEY_KEYSYSTEM + '.10000', // A stupendously high min CDM version, presumably not installed.
shouldPass: false,
expectedStatus: 'cdm-insufficient-version',
- prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", true]]
+ prefs: [["media.eme.enabled", true]]
},
{
keySystem: CLEARKEY_KEYSYSTEM,
shouldPass: true,
expectedStatus: 'cdm-created',
- prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", true]]
+ prefs: [["media.eme.enabled", true]]
},
];
SetupEMEPref(function() {
tests.reduce(function(p,c,i,array) {
return p.then(function() { return Test(c); });
}, Promise.resolve()).then(SimpleTest.finish);
});
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>
-
--- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm
@@ -596,30 +596,27 @@ var GMPProvider = {
if (e.name != 'NS_ERROR_NOT_AVAILABLE')
throw e;
this._log.warn("startup - adding gmp directory failed with " +
e.name + " - sandboxing not available?", e);
}
}
}
- var emeEnabled = Preferences.get(GMPPrefs.KEY_EME_ENABLED, false);
- if (emeEnabled) {
- 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);
- }
+ 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);
}
},
shutdown: function() {
this._log.trace("shutdown");
Preferences.ignore(GMPPrefs.KEY_LOG_BASE, configureLogging);
let shutdownTask = Task.spawn(function*() {