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

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

Issue 946503002: Filter supported session types in createSession(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@export
Patch Set: Remove persistent-license syntax tests. Created 5 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 a45f99ee656c89d0d0066c6e4a9d648c4a4e58c9..5617145c063c605f91006e7369f57f0bc4e75fe9 100644
--- a/Source/modules/encryptedmedia/MediaKeys.cpp
+++ b/Source/modules/encryptedmedia/MediaKeys.cpp
@@ -80,9 +80,10 @@ private:
const RefPtr<DOMArrayBuffer> m_data;
};
-MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, PassOwnPtr<WebContentDecryptionModule> cdm)
+MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, const blink::WebVector<blink::WebString>& supportedSessionTypes, PassOwnPtr<WebContentDecryptionModule> cdm)
: ContextLifecycleObserver(context)
, m_keySystem(keySystem)
+ , m_supportedSessionTypes(supportedSessionTypes)
, m_cdm(cdm)
, m_timer(this, &MediaKeys::timerFired)
{
@@ -102,26 +103,31 @@ MediaKeySession* MediaKeys::createSession(ScriptState* scriptState, const String
{
WTF_LOG(Media, "MediaKeys(%p)::createSession", this);
- // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html#dom-createsession>:
- // The createSession(sessionType) method returns a new MediaKeySession
- // object. It must run the following steps:
- // 1. If sessionType is not supported by the content decryption module
- // corresponding to the keySystem, throw a DOMException whose name is
- // "NotSupportedError".
- ASSERT(MediaKeySession::isValidSessionType(sessionType));
- // FIXME: Check whether sessionType is actually supported by the CDM.
- // (http://crbug.com/384152)
- // FIXME: Enable "persistent-release-message" session type once support
- // added to CDMs.
- if (sessionType == "persistent-release-message") {
- exceptionState.throwDOMException(NotSupportedError, "'persistent-release-message' is not supported.");
- return nullptr;
+ // From http://w3c.github.io/encrypted-media/#createSession
+
+ // When this method is invoked, the user agent must run the following steps:
+ // 1. If this object's persistent state allowed value is false and
+ // sessionType is not "temporary", throw a new DOMException whose name is
+ // NotSupportedError.
+ // (Chromium ensures that only session types supported by the
+ // configuration are listed in supportedSessionTypes.)
+ // 2. If the Key System implementation represented by this object's cdm
+ // implementation value does not support sessionType, throw a new
+ // DOMException whose name is NotSupportedError.
+ bool found = false;
+ for (size_t i = 0; i < m_supportedSessionTypes.size(); i++) {
+ if (m_supportedSessionTypes[i] == blink::WebString(sessionType)) {
+ found = true;
+ break;
+ }
}
+ if (!found)
+ exceptionState.throwDOMException(NotSupportedError, "Unsupported session type.");
- // 2. Let session be a new MediaKeySession object, and initialize it as
+ // 3. Let session be a new MediaKeySession object, and initialize it as
// follows:
// (Initialization is performed in the constructor.)
- // 3. Return session.
+ // 4. Return session.
return MediaKeySession::create(scriptState, this, sessionType);
}

Powered by Google App Engine
This is Rietveld 408576698