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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 PendingAction(ContentDecryptionModuleResult* result, PassRefPtr<DOMArrayBuff er> data) 73 PendingAction(ContentDecryptionModuleResult* result, PassRefPtr<DOMArrayBuff er> data)
74 : m_result(result) 74 : m_result(result)
75 , m_data(data) 75 , m_data(data)
76 { 76 {
77 } 77 }
78 78
79 const Member<ContentDecryptionModuleResult> m_result; 79 const Member<ContentDecryptionModuleResult> m_result;
80 const RefPtr<DOMArrayBuffer> m_data; 80 const RefPtr<DOMArrayBuffer> m_data;
81 }; 81 };
82 82
83 MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, PassOwn Ptr<WebContentDecryptionModule> cdm) 83 MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, const b link::WebVector<blink::WebString>& supportedSessionTypes, PassOwnPtr<WebContentD ecryptionModule> cdm)
84 : ContextLifecycleObserver(context) 84 : ContextLifecycleObserver(context)
85 , m_keySystem(keySystem) 85 , m_keySystem(keySystem)
86 , m_supportedSessionTypes(supportedSessionTypes)
86 , m_cdm(cdm) 87 , m_cdm(cdm)
87 , m_timer(this, &MediaKeys::timerFired) 88 , m_timer(this, &MediaKeys::timerFired)
88 { 89 {
89 WTF_LOG(Media, "MediaKeys(%p)::MediaKeys", this); 90 WTF_LOG(Media, "MediaKeys(%p)::MediaKeys", this);
90 91
91 // Step 4.4 of MediaKeys::create(): 92 // Step 4.4 of MediaKeys::create():
92 // 4.4.1 Set the keySystem attribute to keySystem. 93 // 4.4.1 Set the keySystem attribute to keySystem.
93 ASSERT(!m_keySystem.isEmpty()); 94 ASSERT(!m_keySystem.isEmpty());
94 } 95 }
95 96
96 MediaKeys::~MediaKeys() 97 MediaKeys::~MediaKeys()
97 { 98 {
98 WTF_LOG(Media, "MediaKeys(%p)::~MediaKeys", this); 99 WTF_LOG(Media, "MediaKeys(%p)::~MediaKeys", this);
99 } 100 }
100 101
101 MediaKeySession* MediaKeys::createSession(ScriptState* scriptState, const String & sessionType, ExceptionState& exceptionState) 102 MediaKeySession* MediaKeys::createSession(ScriptState* scriptState, const String & sessionType, ExceptionState& exceptionState)
102 { 103 {
103 WTF_LOG(Media, "MediaKeys(%p)::createSession", this); 104 WTF_LOG(Media, "MediaKeys(%p)::createSession", this);
104 105
105 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-createsession>: 106 // From http://w3c.github.io/encrypted-media/#createSession
106 // The createSession(sessionType) method returns a new MediaKeySession 107
107 // object. It must run the following steps: 108 // When this method is invoked, the user agent must run the following steps:
108 // 1. If sessionType is not supported by the content decryption module 109 // 1. If this object's persistent state allowed value is false and
109 // corresponding to the keySystem, throw a DOMException whose name is 110 // sessionType is not "temporary", throw a new DOMException whose name is
110 // "NotSupportedError". 111 // NotSupportedError.
111 ASSERT(MediaKeySession::isValidSessionType(sessionType)); 112 // (Chromium ensures that only session types supported by the
112 // FIXME: Check whether sessionType is actually supported by the CDM. 113 // configuration are listed in supportedSessionTypes.)
113 // (http://crbug.com/384152) 114 // 2. If the Key System implementation represented by this object's cdm
114 // FIXME: Enable "persistent-release-message" session type once support 115 // implementation value does not support sessionType, throw a new
115 // added to CDMs. 116 // DOMException whose name is NotSupportedError.
116 if (sessionType == "persistent-release-message") { 117 bool found = false;
117 exceptionState.throwDOMException(NotSupportedError, "'persistent-release -message' is not supported."); 118 for (size_t i = 0; i < m_supportedSessionTypes.size(); i++) {
118 return nullptr; 119 if (m_supportedSessionTypes[i] == blink::WebString(sessionType)) {
120 found = true;
121 break;
122 }
119 } 123 }
124 if (!found)
125 exceptionState.throwDOMException(NotSupportedError, "Unsupported session type.");
120 126
121 // 2. Let session be a new MediaKeySession object, and initialize it as 127 // 3. Let session be a new MediaKeySession object, and initialize it as
122 // follows: 128 // follows:
123 // (Initialization is performed in the constructor.) 129 // (Initialization is performed in the constructor.)
124 // 3. Return session. 130 // 4. Return session.
125 return MediaKeySession::create(scriptState, this, sessionType); 131 return MediaKeySession::create(scriptState, this, sessionType);
126 } 132 }
127 133
128 ScriptPromise MediaKeys::setServerCertificate(ScriptState* scriptState, const DO MArrayPiece& serverCertificate) 134 ScriptPromise MediaKeys::setServerCertificate(ScriptState* scriptState, const DO MArrayPiece& serverCertificate)
129 { 135 {
130 // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-setservercertificate: 136 // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-setservercertificate:
131 // The setServerCertificate(serverCertificate) method provides a server 137 // The setServerCertificate(serverCertificate) method provides a server
132 // certificate to be used to encrypt messages to the license server. 138 // certificate to be used to encrypt messages to the license server.
133 // It must run the following steps: 139 // It must run the following steps:
134 // 1. If serverCertificate is an empty array, return a promise rejected 140 // 1. If serverCertificate is an empty array, return a promise rejected
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 204
199 void MediaKeys::contextDestroyed() 205 void MediaKeys::contextDestroyed()
200 { 206 {
201 ContextLifecycleObserver::contextDestroyed(); 207 ContextLifecycleObserver::contextDestroyed();
202 208
203 // We don't need the CDM anymore. 209 // We don't need the CDM anymore.
204 m_cdm.clear(); 210 m_cdm.clear();
205 } 211 }
206 212
207 } // namespace blink 213 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698