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

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: 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..b20d377a8c7b8fe664bbf0aa7dbf69eff0e58874 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::WebMediaKeySystemConfiguration& configuration, PassOwnPtr<WebContentDecryptionModule> cdm)
: ContextLifecycleObserver(context)
, m_keySystem(keySystem)
+ , m_configuration(configuration)
, m_cdm(cdm)
, m_timer(this, &MediaKeys::timerFired)
{
@@ -102,26 +103,30 @@ 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.
ddorwin 2015/02/20 03:42:00 Something like: \n (Chromium ensures the returned
sandersd (OOO until July 31) 2015/02/20 03:47:17 Done.
+ // 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.
+ blink::WebString webSessionType = blink::WebString(sessionType);
+ bool valid = false;
ddorwin 2015/02/20 03:42:00 nit: Replace valid with supported (or even found).
sandersd (OOO until July 31) 2015/02/20 03:47:17 Done.
+ for (size_t i = 0; i < m_configuration.sessionTypes.size(); i++) {
+ if (m_configuration.sessionTypes[i] == webSessionType) {
ddorwin 2015/02/20 03:42:00 Can we just do blink::WebString(sessionType) inlin
sandersd (OOO until July 31) 2015/02/20 03:47:17 Done.
+ valid = true;
+ break;
+ }
}
+ if (!valid)
+ 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