Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Unified Diff: Source/modules/encryptedmedia/MediaKeys.cpp

Issue 183943003: Verify MediaKeys parameter values consistently (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Helper methods Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/encryptedmedia/MediaKeys.cpp
diff --git a/Source/modules/encryptedmedia/MediaKeys.cpp b/Source/modules/encryptedmedia/MediaKeys.cpp
index d0e173a96c1859077feaaf9cfdbc00005c6e1bb6..3f1c4f2776d71daa0534bdfd95ba3599f317948b 100644
--- a/Source/modules/encryptedmedia/MediaKeys.cpp
+++ b/Source/modules/encryptedmedia/MediaKeys.cpp
@@ -53,7 +53,7 @@ PassRefPtrWillBeRawPtr<MediaKeys> MediaKeys::create(ExecutionContext* context, c
}
// 2. If keySystem is not one of the user agent's supported Key Systems, throw a NotSupportedError and abort these steps.
- if (!ContentDecryptionModule::supportsKeySystem(keySystem)) {
+ if (!isSupportedKeySystem(keySystem)) {
exceptionState.throwDOMException(NotSupportedError, "The '" + keySystem + "' key system is not supported.");
return nullptr;
}
@@ -108,7 +108,7 @@ PassRefPtrWillBeRawPtr<MediaKeySession> MediaKeys::createSession(ExecutionContex
// 1. If type contains a MIME type that is not supported or is not supported by the keySystem,
// throw a NOT_SUPPORTED_ERR exception and abort these steps.
- if (!m_cdm->supportsMIMEType(contentType)) {
+ if (!isSupportedContentType(m_keySystem, contentType)) {
exceptionState.throwDOMException(NotSupportedError, "The type provided ('" + contentType + "') is unsupported.");
return nullptr;
}
@@ -141,7 +141,7 @@ bool MediaKeys::isTypeSupported(const String& keySystem, const String& contentTy
// 2. If keySystem contains an unrecognized or unsupported Key System, return false and abort
// these steps. Key system string comparison is case-sensitive.
- if (!MIMETypeRegistry::isSupportedEncryptedMediaMIMEType(keySystem, "", ""))
+ if (!isSupportedKeySystem(keySystem))
return false;
// 3. If contentType is null or an empty string, return true and abort these steps.
@@ -150,9 +150,22 @@ bool MediaKeys::isTypeSupported(const String& keySystem, const String& contentTy
// 4. If the Key System specified by keySystem does not support decrypting the container and/or
// codec specified by contentType, return false and abort these steps.
+ return isSupportedContentType(keySystem, contentType);
+}
+
+bool MediaKeys::isSupportedKeySystem(const String& keySystem)
+{
+ ASSERT(!keySystem.isEmpty());
+ return MIMETypeRegistry::isSupportedEncryptedMediaMIMEType(keySystem, "", "");
+}
+
+bool MediaKeys::isSupportedContentType(const String& keySystem, const String& contentType)
xhwang 2014/02/27 23:19:51 nit: can we just have one helper function, e.g. is
ddorwin 2014/02/27 23:28:27 Yes, but they work nicely in the algorithms and hi
xhwang 2014/02/27 23:42:36 If we don't need to pass in "keySystem" into isSup
ddorwin 2014/02/28 00:14:09 Maybe. I considered that. Really, it is isKeySyste
jrummell 2014/02/28 00:25:32 Renamed function.
+{
+ ASSERT(!keySystem.isEmpty());
+ ASSERT(!contentType.isEmpty());
+
ContentType type(contentType);
String codecs = type.parameter("codecs");
-
return MIMETypeRegistry::isSupportedEncryptedMediaMIMEType(keySystem, type.type(), codecs);
}

Powered by Google App Engine
This is Rietveld 408576698