Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" | 6 #include "modules/encryptedmedia/HTMLMediaElementEncryptedMedia.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | |
| 11 #include "bindings/core/v8/ScriptState.h" | |
| 12 #include "core/dom/DOMException.h" | |
| 9 #include "core/dom/ExceptionCode.h" | 13 #include "core/dom/ExceptionCode.h" |
| 10 #include "core/html/HTMLMediaElement.h" | 14 #include "core/html/HTMLMediaElement.h" |
| 11 #include "core/html/MediaKeyError.h" | 15 #include "core/html/MediaKeyError.h" |
| 12 #include "core/html/MediaKeyEvent.h" | 16 #include "core/html/MediaKeyEvent.h" |
| 13 #include "modules/encryptedmedia/MediaKeyNeededEvent.h" | 17 #include "modules/encryptedmedia/MediaKeyNeededEvent.h" |
| 14 #include "modules/encryptedmedia/MediaKeys.h" | 18 #include "modules/encryptedmedia/MediaKeys.h" |
| 19 #include "modules/encryptedmedia/SimpleContentDecryptionModuleResult.h" | |
| 20 #include "platform/ContentDecryptionModuleResult.h" | |
| 15 #include "platform/Logging.h" | 21 #include "platform/Logging.h" |
| 16 #include "platform/RuntimeEnabledFeatures.h" | 22 #include "platform/RuntimeEnabledFeatures.h" |
| 23 #include "wtf/Functional.h" | |
| 17 #include "wtf/Uint8Array.h" | 24 #include "wtf/Uint8Array.h" |
| 18 | 25 |
| 19 namespace blink { | 26 namespace blink { |
| 20 | 27 |
| 21 static void throwExceptionIfMediaKeyExceptionOccurred(const String& keySystem, c onst String& sessionId, blink::WebMediaPlayer::MediaKeyException exception, Exce ptionState& exceptionState) | 28 static void throwExceptionIfMediaKeyExceptionOccurred(const String& keySystem, c onst String& sessionId, blink::WebMediaPlayer::MediaKeyException exception, Exce ptionState& exceptionState) |
| 22 { | 29 { |
| 23 switch (exception) { | 30 switch (exception) { |
| 24 case blink::WebMediaPlayer::MediaKeyExceptionNoError: | 31 case blink::WebMediaPlayer::MediaKeyExceptionNoError: |
| 25 return; | 32 return; |
| 26 case blink::WebMediaPlayer::MediaKeyExceptionInvalidPlayerState: | 33 case blink::WebMediaPlayer::MediaKeyExceptionInvalidPlayerState: |
| 27 exceptionState.throwDOMException(InvalidStateError, "The player is in an invalid state."); | 34 exceptionState.throwDOMException(InvalidStateError, "The player is in an invalid state."); |
| 28 return; | 35 return; |
| 29 case blink::WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported: | 36 case blink::WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported: |
| 30 exceptionState.throwDOMException(NotSupportedError, "The key system prov ided ('" + keySystem +"') is not supported."); | 37 exceptionState.throwDOMException(NotSupportedError, "The key system prov ided ('" + keySystem +"') is not supported."); |
| 31 return; | 38 return; |
| 32 case blink::WebMediaPlayer::MediaKeyExceptionInvalidAccess: | 39 case blink::WebMediaPlayer::MediaKeyExceptionInvalidAccess: |
| 33 exceptionState.throwDOMException(InvalidAccessError, "The session ID pro vided ('" + sessionId + "') is invalid."); | 40 exceptionState.throwDOMException(InvalidAccessError, "The session ID pro vided ('" + sessionId + "') is invalid."); |
| 34 return; | 41 return; |
| 35 } | 42 } |
| 36 | 43 |
| 37 ASSERT_NOT_REACHED(); | 44 ASSERT_NOT_REACHED(); |
| 38 return; | 45 return; |
| 39 } | 46 } |
| 40 | 47 |
| 48 // This class allows MediaKeys to be set asynchronously. | |
| 49 class SetMediaKeysHandler : public ScriptPromiseResolver { | |
| 50 WTF_MAKE_NONCOPYABLE(SetMediaKeysHandler); | |
| 51 | |
| 52 public: | |
| 53 static ScriptPromise create(ScriptState*, HTMLMediaElement&, MediaKeys*); | |
| 54 virtual ~SetMediaKeysHandler(); | |
| 55 | |
| 56 private: | |
| 57 SetMediaKeysHandler(ScriptState*, HTMLMediaElement&, MediaKeys*); | |
| 58 void timerFired(Timer<SetMediaKeysHandler>*); | |
| 59 | |
| 60 void ClearExistingMediaKeys(); | |
| 61 void SetNewMediaKeys(); | |
| 62 void Finish(); | |
| 63 | |
| 64 void ReportClearFailed(ExceptionCode, const String& errorMessage); | |
| 65 void ReportSetFailed(ExceptionCode, const String& errorMessage); | |
| 66 | |
| 67 RawPtrWillBeMember<HTMLMediaElement> m_element; | |
| 68 Persistent<MediaKeys> m_newMediaKeys; | |
| 69 Timer<SetMediaKeysHandler> m_timer; | |
| 70 }; | |
| 71 | |
| 72 typedef Function<void()> SuccessCallback; | |
| 73 typedef Function<void(ExceptionCode, const String&)> FailureCallback; | |
| 74 | |
| 75 // Represents the result used when setContentDecryptionModule() is called. | |
| 76 // Calls |success| if result is resolved, |failure| is result is rejected. | |
| 77 class SetContentDecryptionModuleResult FINAL : public ContentDecryptionModuleRes ult { | |
| 78 public: | |
| 79 SetContentDecryptionModuleResult(SuccessCallback success, FailureCallback fa ilure) | |
| 80 : m_successCallback(success) | |
| 81 , m_failureCallback(failure) | |
| 82 { | |
| 83 } | |
| 84 | |
| 85 // ContentDecryptionModuleResult implementation. | |
| 86 virtual void complete() OVERRIDE | |
| 87 { | |
| 88 m_successCallback(); | |
| 89 } | |
| 90 | |
| 91 virtual void completeWithSession(blink::WebContentDecryptionModuleResult::Se ssionStatus status) OVERRIDE | |
| 92 { | |
| 93 ASSERT_NOT_REACHED(); | |
| 94 m_failureCallback(InvalidStateError, "Unexpected completion."); | |
| 95 } | |
| 96 | |
| 97 virtual void completeWithError(blink::WebContentDecryptionModuleException co de, unsigned long systemCode, const blink::WebString& message) OVERRIDE | |
| 98 { | |
| 99 m_failureCallback(WebCdmExceptionToExceptionCode(code), message); | |
| 100 } | |
| 101 | |
| 102 private: | |
| 103 SuccessCallback m_successCallback; | |
| 104 FailureCallback m_failureCallback; | |
| 105 }; | |
| 106 | |
| 107 ScriptPromise SetMediaKeysHandler::create(ScriptState* scriptState, HTMLMediaEle ment& element, MediaKeys* mediaKeys) | |
| 108 { | |
| 109 RefPtr<SetMediaKeysHandler> handler = adoptRef(new SetMediaKeysHandler(scrip tState, element, mediaKeys)); | |
| 110 handler->suspendIfNeeded(); | |
| 111 handler->keepAliveWhilePending(); | |
| 112 return handler->promise(); | |
| 113 } | |
| 114 | |
| 115 SetMediaKeysHandler::SetMediaKeysHandler(ScriptState* scriptState, HTMLMediaElem ent& element, MediaKeys* mediaKeys) | |
| 116 : ScriptPromiseResolver(scriptState) | |
| 117 , m_element(element) | |
| 118 , m_newMediaKeys(mediaKeys) | |
| 119 , m_timer(this, &SetMediaKeysHandler::timerFired) | |
| 120 { | |
| 121 WTF_LOG(Media, "SetMediaKeysHandler::SetMediaKeysHandler"); | |
| 122 | |
| 123 // 3. Run the remaining steps asynchronously. | |
| 124 m_timer.startOneShot(0, FROM_HERE); | |
| 125 } | |
| 126 | |
| 127 SetMediaKeysHandler::~SetMediaKeysHandler() | |
| 128 { | |
| 129 } | |
| 130 | |
| 131 void SetMediaKeysHandler::timerFired(Timer<SetMediaKeysHandler>*) | |
| 132 { | |
| 133 ClearExistingMediaKeys(); | |
| 134 } | |
| 135 | |
| 136 void SetMediaKeysHandler::ClearExistingMediaKeys() | |
| 137 { | |
| 138 WTF_LOG(Media, "SetMediaKeysHandler::ClearExistingMediaKeys"); | |
| 139 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(*m_element); | |
| 140 | |
| 141 // 3.1 If mediaKeys is not null, it is already in use by another media | |
| 142 // element, and the user agent is unable to use it with this element, | |
| 143 // reject promise with a new DOMException whose name is | |
| 144 // "QuotaExceededError". | |
| 145 // FIXME: Need to check whether mediaKeys is already in use by another | |
| 146 // media element. | |
| 147 // 3.2 If the mediaKeys attribute is not null, run the following steps: | |
| 148 if (thisElement.m_mediaKeys) { | |
| 149 // 3.2.1 If the user agent or CDM do not support removing the | |
| 150 // association, return a promise rejected with a new DOMException | |
| 151 // whose name is "NotSupportedError". | |
| 152 // 3.2.2 If the association cannot currently be removed (i.e. during | |
| 153 // playback), return a promise rejected with a new DOMException | |
| 154 // whose name is "InvalidStateError". | |
| 155 if (m_element->webMediaPlayer()) { | |
| 156 reject(DOMException::create(InvalidStateError, "The existing MediaKe ys object cannot be removed while a media resource is loaded.")); | |
| 157 return; | |
| 158 } | |
| 159 | |
| 160 // 3.2.3 Stop using the CDM instance represented by the mediaKeys | |
| 161 // attribute to decrypt media data and remove the association | |
| 162 // with the media element. | |
| 163 // 3.2.4 If the preceding step failed, ... | |
| 164 // (done in ReportClearFailed()). | |
| 165 if (m_element->webMediaPlayer()) { | |
|
acolwell GONE FROM CHROMIUM
2014/08/13 22:04:43
How can you get here? Doesn't the early return abo
jrummell
2014/08/14 01:14:19
Done. The test on 155 used to be more specific (Is
| |
| 166 SuccessCallback successCallback = bind(&SetMediaKeysHandler::SetNewM ediaKeys, this); | |
| 167 FailureCallback failureCallback = bind<ExceptionCode, const String&> (&SetMediaKeysHandler::ReportClearFailed, this); | |
| 168 ContentDecryptionModuleResult* result = new SetContentDecryptionModu leResult(successCallback, failureCallback); | |
| 169 m_element->webMediaPlayer()->setContentDecryptionModule(nullptr, res ult->result()); | |
| 170 | |
| 171 // Don't do anything more until |result| is resolved (or rejected). | |
| 172 return; | |
| 173 } | |
| 174 } | |
| 175 | |
| 176 // MediaKeys not currently set or no player connected, so continue on. | |
| 177 SetNewMediaKeys(); | |
| 178 } | |
| 179 | |
| 180 void SetMediaKeysHandler::SetNewMediaKeys() | |
| 181 { | |
| 182 WTF_LOG(Media, "SetMediaKeysHandler::SetNewMediaKeys"); | |
| 183 | |
| 184 // 3.3 If mediaKeys is not null, run the following steps: | |
| 185 if (m_newMediaKeys) { | |
| 186 // 3.3.1 Associate the CDM instance represented by mediaKeys with the | |
| 187 // media element for decrypting media data. | |
| 188 // 3.3.2 If the preceding step failed, run the following steps: | |
| 189 // (done in ReportSetFailed()). | |
| 190 // 3.3.3 Run the Attempt to Resume Playback If Necessary algorithm on | |
| 191 // the media element. The user agent may choose to skip this | |
| 192 // step if it knows resuming will fail (i.e. mediaKeys has no | |
| 193 // sessions). | |
| 194 // (Handled in Chromium). | |
| 195 if (m_element->webMediaPlayer()) { | |
| 196 SuccessCallback successCallback = bind(&SetMediaKeysHandler::Finish, this); | |
| 197 FailureCallback failureCallback = bind<ExceptionCode, const String&> (&SetMediaKeysHandler::ReportSetFailed, this); | |
| 198 ContentDecryptionModuleResult* result = new SetContentDecryptionModu leResult(successCallback, failureCallback); | |
| 199 m_element->webMediaPlayer()->setContentDecryptionModule(m_newMediaKe ys->contentDecryptionModule(), result->result()); | |
| 200 | |
| 201 // Don't do anything more until |result| is resolved (or rejected). | |
| 202 return; | |
| 203 } | |
| 204 } | |
| 205 | |
| 206 // MediaKeys doesn't need to be set on the player, so continue on. | |
| 207 Finish(); | |
| 208 } | |
| 209 | |
| 210 void SetMediaKeysHandler::Finish() | |
| 211 { | |
| 212 WTF_LOG(Media, "SetMediaKeysHandler::Finish"); | |
| 213 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(*m_element); | |
| 214 | |
| 215 // 3.4 Set the mediaKeys attribute to mediaKeys. | |
| 216 thisElement.m_mediaKeys = m_newMediaKeys; | |
| 217 | |
| 218 // 3.5 Resolve promise with undefined. | |
| 219 resolve(); | |
| 220 } | |
| 221 | |
| 222 void SetMediaKeysHandler::ReportClearFailed(ExceptionCode code, const String& er rorMessage) | |
| 223 { | |
| 224 WTF_LOG(Media, "SetMediaKeysHandler::ReportClearFailed"); | |
| 225 | |
| 226 // 3.2.4 If the preceding step failed, reject promise with a new | |
| 227 // DOMException whose name is the appropriate error name and | |
| 228 // that has an appropriate message. | |
| 229 reject(DOMException::create(code, errorMessage)); | |
| 230 } | |
| 231 | |
| 232 void SetMediaKeysHandler::ReportSetFailed(ExceptionCode code, const String& erro rMessage) | |
| 233 { | |
| 234 WTF_LOG(Media, "SetMediaKeysHandler::ReportSetFailed"); | |
| 235 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(*m_element); | |
| 236 | |
| 237 // 3.3.2 If the preceding step failed, run the following steps: | |
| 238 // 3.3.2.1 Set the mediaKeys attribute to null. | |
| 239 thisElement.m_mediaKeys.clear(); | |
| 240 | |
| 241 // 3.3.2.2 Reject promise with a new DOMException whose name is the | |
| 242 // appropriate error name and that has an appropriate message. | |
| 243 reject(DOMException::create(code, errorMessage)); | |
| 244 } | |
| 245 | |
| 41 HTMLMediaElementEncryptedMedia::HTMLMediaElementEncryptedMedia() | 246 HTMLMediaElementEncryptedMedia::HTMLMediaElementEncryptedMedia() |
| 42 : m_emeMode(EmeModeNotSelected) | 247 : m_emeMode(EmeModeNotSelected) |
| 43 { | 248 { |
| 44 } | 249 } |
| 45 | 250 |
| 46 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HTMLMediaElementEncryptedMedia) | 251 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HTMLMediaElementEncryptedMedia) |
| 47 | 252 |
| 48 const char* HTMLMediaElementEncryptedMedia::supplementName() | 253 const char* HTMLMediaElementEncryptedMedia::supplementName() |
| 49 { | 254 { |
| 50 return "HTMLMediaElementEncryptedMedia"; | 255 return "HTMLMediaElementEncryptedMedia"; |
| 51 } | 256 } |
| 52 | 257 |
| 53 HTMLMediaElementEncryptedMedia& HTMLMediaElementEncryptedMedia::from(HTMLMediaEl ement& element) | 258 HTMLMediaElementEncryptedMedia& HTMLMediaElementEncryptedMedia::from(HTMLMediaEl ement& element) |
| 54 { | 259 { |
| 55 HTMLMediaElementEncryptedMedia* supplement = static_cast<HTMLMediaElementEnc ryptedMedia*>(WillBeHeapSupplement<HTMLMediaElement>::from(element, supplementNa me())); | 260 HTMLMediaElementEncryptedMedia* supplement = static_cast<HTMLMediaElementEnc ryptedMedia*>(WillBeHeapSupplement<HTMLMediaElement>::from(element, supplementNa me())); |
| 56 if (!supplement) { | 261 if (!supplement) { |
| 57 supplement = new HTMLMediaElementEncryptedMedia(); | 262 supplement = new HTMLMediaElementEncryptedMedia(); |
| 58 provideTo(element, supplementName(), adoptPtrWillBeNoop(supplement)); | 263 provideTo(element, supplementName(), adoptPtrWillBeNoop(supplement)); |
| 59 } | 264 } |
| 60 return *supplement; | 265 return *supplement; |
| 61 } | 266 } |
| 62 | 267 |
| 63 bool HTMLMediaElementEncryptedMedia::setEmeMode(EmeMode emeMode, ExceptionState& exceptionState) | 268 bool HTMLMediaElementEncryptedMedia::setEmeMode(EmeMode emeMode) |
| 64 { | 269 { |
| 65 if (m_emeMode != EmeModeNotSelected && m_emeMode != emeMode) { | 270 if (m_emeMode != EmeModeNotSelected && m_emeMode != emeMode) |
| 66 exceptionState.throwDOMException(InvalidStateError, "Mixed use of EME pr efixed and unprefixed API not allowed."); | |
|
acolwell GONE FROM CHROMIUM
2014/08/13 22:04:43
Why was this change made? It seems like having thi
jrummell
2014/08/14 01:14:19
For promises there is no exception -- it becomes a
| |
| 67 return false; | 271 return false; |
| 68 } | 272 |
| 69 m_emeMode = emeMode; | 273 m_emeMode = emeMode; |
| 70 return true; | 274 return true; |
| 71 } | 275 } |
| 72 | 276 |
| 73 blink::WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryp tionModule() | 277 blink::WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryp tionModule() |
| 74 { | 278 { |
| 75 return m_mediaKeys ? m_mediaKeys->contentDecryptionModule() : 0; | 279 return m_mediaKeys ? m_mediaKeys->contentDecryptionModule() : 0; |
| 76 } | 280 } |
| 77 | 281 |
| 78 MediaKeys* HTMLMediaElementEncryptedMedia::mediaKeys(HTMLMediaElement& element) | 282 MediaKeys* HTMLMediaElementEncryptedMedia::mediaKeys(HTMLMediaElement& element) |
| 79 { | 283 { |
| 80 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); | 284 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); |
| 81 return thisElement.m_mediaKeys.get(); | 285 return thisElement.m_mediaKeys.get(); |
| 82 } | 286 } |
| 83 | 287 |
| 84 void HTMLMediaElementEncryptedMedia::setMediaKeysInternal(HTMLMediaElement& elem ent, MediaKeys* mediaKeys) | 288 ScriptPromise HTMLMediaElementEncryptedMedia::setMediaKeys(ScriptState* scriptSt ate, HTMLMediaElement& element, MediaKeys* mediaKeys) |
| 85 { | 289 { |
| 86 if (m_mediaKeys == mediaKeys) | 290 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); |
| 87 return; | 291 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::setMediaKeys current(%p), ne w(%p)", thisElement.m_mediaKeys.get(), mediaKeys); |
| 88 | 292 |
| 89 ASSERT(m_emeMode == EmeModeUnprefixed); | 293 if (!thisElement.setEmeMode(EmeModeUnprefixed)) |
| 90 m_mediaKeys = mediaKeys; | 294 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(InvalidStateError, "Mixed use of EME prefixed and unprefixed API not allo wed.")); |
| 91 | 295 |
| 92 // If a player is connected, tell it that the CDM has changed. | 296 // 1. If mediaKeys and the mediaKeys attribute are the same object, return |
| 93 if (element.webMediaPlayer()) | 297 // a promise resolved with undefined. |
| 94 element.webMediaPlayer()->setContentDecryptionModule(contentDecryptionMo dule()); | 298 if (thisElement.m_mediaKeys == mediaKeys) |
| 95 } | 299 return ScriptPromise::cast(scriptState, V8ValueTraits<V8UndefinedType>:: toV8Value(V8UndefinedType(), scriptState->context()->Global(), scriptState->isol ate())); |
| 96 | 300 |
| 97 void HTMLMediaElementEncryptedMedia::setMediaKeys(HTMLMediaElement& element, Med iaKeys* mediaKeys, ExceptionState& exceptionState) | 301 // 2. Let promise be a new promise. Remaining steps done in handler. |
| 98 { | 302 return SetMediaKeysHandler::create(scriptState, element, mediaKeys); |
| 99 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::setMediaKeys"); | |
| 100 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); | |
| 101 | |
| 102 if (!thisElement.setEmeMode(EmeModeUnprefixed, exceptionState)) | |
| 103 return; | |
| 104 | |
| 105 thisElement.setMediaKeysInternal(element, mediaKeys); | |
| 106 } | 303 } |
| 107 | 304 |
| 108 // Create a MediaKeyNeededEvent for WD EME. | 305 // Create a MediaKeyNeededEvent for WD EME. |
| 109 static PassRefPtrWillBeRawPtr<Event> createNeedKeyEvent(const String& contentTyp e, const unsigned char* initData, unsigned initDataLength) | 306 static PassRefPtrWillBeRawPtr<Event> createNeedKeyEvent(const String& contentTyp e, const unsigned char* initData, unsigned initDataLength) |
| 110 { | 307 { |
| 111 MediaKeyNeededEventInit initializer; | 308 MediaKeyNeededEventInit initializer; |
| 112 initializer.contentType = contentType; | 309 initializer.contentType = contentType; |
| 113 initializer.initData = Uint8Array::create(initData, initDataLength); | 310 initializer.initData = Uint8Array::create(initData, initDataLength); |
| 114 initializer.bubbles = false; | 311 initializer.bubbles = false; |
| 115 initializer.cancelable = false; | 312 initializer.cancelable = false; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 132 | 329 |
| 133 void HTMLMediaElementEncryptedMedia::webkitGenerateKeyRequest(HTMLMediaElement& element, const String& keySystem, PassRefPtr<Uint8Array> initData, ExceptionStat e& exceptionState) | 330 void HTMLMediaElementEncryptedMedia::webkitGenerateKeyRequest(HTMLMediaElement& element, const String& keySystem, PassRefPtr<Uint8Array> initData, ExceptionStat e& exceptionState) |
| 134 { | 331 { |
| 135 HTMLMediaElementEncryptedMedia::from(element).generateKeyRequest(element.web MediaPlayer(), keySystem, initData, exceptionState); | 332 HTMLMediaElementEncryptedMedia::from(element).generateKeyRequest(element.web MediaPlayer(), keySystem, initData, exceptionState); |
| 136 } | 333 } |
| 137 | 334 |
| 138 void HTMLMediaElementEncryptedMedia::generateKeyRequest(blink::WebMediaPlayer* w ebMediaPlayer, const String& keySystem, PassRefPtr<Uint8Array> initData, Excepti onState& exceptionState) | 335 void HTMLMediaElementEncryptedMedia::generateKeyRequest(blink::WebMediaPlayer* w ebMediaPlayer, const String& keySystem, PassRefPtr<Uint8Array> initData, Excepti onState& exceptionState) |
| 139 { | 336 { |
| 140 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitGenerateKeyRequest"); | 337 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitGenerateKeyRequest"); |
| 141 | 338 |
| 142 if (!setEmeMode(EmeModePrefixed, exceptionState)) | 339 if (!setEmeMode(EmeModePrefixed)) { |
| 340 exceptionState.throwDOMException(InvalidStateError, "Mixed use of EME pr efixed and unprefixed API not allowed."); | |
| 143 return; | 341 return; |
| 342 } | |
| 144 | 343 |
| 145 if (keySystem.isEmpty()) { | 344 if (keySystem.isEmpty()) { |
| 146 exceptionState.throwDOMException(SyntaxError, "The key system provided i s empty."); | 345 exceptionState.throwDOMException(SyntaxError, "The key system provided i s empty."); |
| 147 return; | 346 return; |
| 148 } | 347 } |
| 149 | 348 |
| 150 if (!webMediaPlayer) { | 349 if (!webMediaPlayer) { |
| 151 exceptionState.throwDOMException(InvalidStateError, "No media has been l oaded."); | 350 exceptionState.throwDOMException(InvalidStateError, "No media has been l oaded."); |
| 152 return; | 351 return; |
| 153 } | 352 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 170 | 369 |
| 171 void HTMLMediaElementEncryptedMedia::webkitAddKey(HTMLMediaElement& element, con st String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> initDat a, const String& sessionId, ExceptionState& exceptionState) | 370 void HTMLMediaElementEncryptedMedia::webkitAddKey(HTMLMediaElement& element, con st String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> initDat a, const String& sessionId, ExceptionState& exceptionState) |
| 172 { | 371 { |
| 173 HTMLMediaElementEncryptedMedia::from(element).addKey(element.webMediaPlayer( ), keySystem, key, initData, sessionId, exceptionState); | 372 HTMLMediaElementEncryptedMedia::from(element).addKey(element.webMediaPlayer( ), keySystem, key, initData, sessionId, exceptionState); |
| 174 } | 373 } |
| 175 | 374 |
| 176 void HTMLMediaElementEncryptedMedia::addKey(blink::WebMediaPlayer* webMediaPlaye r, const String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> i nitData, const String& sessionId, ExceptionState& exceptionState) | 375 void HTMLMediaElementEncryptedMedia::addKey(blink::WebMediaPlayer* webMediaPlaye r, const String& keySystem, PassRefPtr<Uint8Array> key, PassRefPtr<Uint8Array> i nitData, const String& sessionId, ExceptionState& exceptionState) |
| 177 { | 376 { |
| 178 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitAddKey"); | 377 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitAddKey"); |
| 179 | 378 |
| 180 if (!setEmeMode(EmeModePrefixed, exceptionState)) | 379 if (!setEmeMode(EmeModePrefixed)) { |
| 380 exceptionState.throwDOMException(InvalidStateError, "Mixed use of EME pr efixed and unprefixed API not allowed."); | |
| 181 return; | 381 return; |
| 382 } | |
| 182 | 383 |
| 183 if (keySystem.isEmpty()) { | 384 if (keySystem.isEmpty()) { |
| 184 exceptionState.throwDOMException(SyntaxError, "The key system provided i s empty."); | 385 exceptionState.throwDOMException(SyntaxError, "The key system provided i s empty."); |
| 185 return; | 386 return; |
| 186 } | 387 } |
| 187 | 388 |
| 188 if (!key) { | 389 if (!key) { |
| 189 exceptionState.throwDOMException(SyntaxError, "The key provided is inval id."); | 390 exceptionState.throwDOMException(SyntaxError, "The key provided is inval id."); |
| 190 return; | 391 return; |
| 191 } | 392 } |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 218 | 419 |
| 219 void HTMLMediaElementEncryptedMedia::webkitCancelKeyRequest(HTMLMediaElement& el ement, const String& keySystem, const String& sessionId, ExceptionState& excepti onState) | 420 void HTMLMediaElementEncryptedMedia::webkitCancelKeyRequest(HTMLMediaElement& el ement, const String& keySystem, const String& sessionId, ExceptionState& excepti onState) |
| 220 { | 421 { |
| 221 HTMLMediaElementEncryptedMedia::from(element).cancelKeyRequest(element.webMe diaPlayer(), keySystem, sessionId, exceptionState); | 422 HTMLMediaElementEncryptedMedia::from(element).cancelKeyRequest(element.webMe diaPlayer(), keySystem, sessionId, exceptionState); |
| 222 } | 423 } |
| 223 | 424 |
| 224 void HTMLMediaElementEncryptedMedia::cancelKeyRequest(blink::WebMediaPlayer* web MediaPlayer, const String& keySystem, const String& sessionId, ExceptionState& e xceptionState) | 425 void HTMLMediaElementEncryptedMedia::cancelKeyRequest(blink::WebMediaPlayer* web MediaPlayer, const String& keySystem, const String& sessionId, ExceptionState& e xceptionState) |
| 225 { | 426 { |
| 226 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitCancelKeyRequest"); | 427 WTF_LOG(Media, "HTMLMediaElementEncryptedMedia::webkitCancelKeyRequest"); |
| 227 | 428 |
| 228 if (!setEmeMode(EmeModePrefixed, exceptionState)) | 429 if (!setEmeMode(EmeModePrefixed)) { |
| 430 exceptionState.throwDOMException(InvalidStateError, "Mixed use of EME pr efixed and unprefixed API not allowed."); | |
| 229 return; | 431 return; |
| 432 } | |
| 230 | 433 |
| 231 if (keySystem.isEmpty()) { | 434 if (keySystem.isEmpty()) { |
| 232 exceptionState.throwDOMException(SyntaxError, "The key system provided i s empty."); | 435 exceptionState.throwDOMException(SyntaxError, "The key system provided i s empty."); |
| 233 return; | 436 return; |
| 234 } | 437 } |
| 235 | 438 |
| 236 if (!webMediaPlayer) { | 439 if (!webMediaPlayer) { |
| 237 exceptionState.throwDOMException(InvalidStateError, "No media has been l oaded."); | 440 exceptionState.throwDOMException(InvalidStateError, "No media has been l oaded."); |
| 238 return; | 441 return; |
| 239 } | 442 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 334 | 537 |
| 335 void HTMLMediaElementEncryptedMedia::playerDestroyed(HTMLMediaElement& element) | 538 void HTMLMediaElementEncryptedMedia::playerDestroyed(HTMLMediaElement& element) |
| 336 { | 539 { |
| 337 #if ENABLE(OILPAN) | 540 #if ENABLE(OILPAN) |
| 338 // FIXME: Oilpan: remove this once the media player is on the heap. crbug.co m/378229 | 541 // FIXME: Oilpan: remove this once the media player is on the heap. crbug.co m/378229 |
| 339 if (element.isFinalizing()) | 542 if (element.isFinalizing()) |
| 340 return; | 543 return; |
| 341 #endif | 544 #endif |
| 342 | 545 |
| 343 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); | 546 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); |
| 344 thisElement.setMediaKeysInternal(element, 0); | 547 if (!thisElement.m_mediaKeys) |
| 548 return; | |
| 549 | |
| 550 ASSERT(thisElement.m_emeMode == EmeModeUnprefixed); | |
| 551 thisElement.m_mediaKeys.clear(); | |
| 345 } | 552 } |
| 346 | 553 |
| 347 blink::WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryp tionModule(HTMLMediaElement& element) | 554 blink::WebContentDecryptionModule* HTMLMediaElementEncryptedMedia::contentDecryp tionModule(HTMLMediaElement& element) |
| 348 { | 555 { |
| 349 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); | 556 HTMLMediaElementEncryptedMedia& thisElement = HTMLMediaElementEncryptedMedia ::from(element); |
| 350 return thisElement.contentDecryptionModule(); | 557 return thisElement.contentDecryptionModule(); |
| 351 } | 558 } |
| 352 | 559 |
| 353 void HTMLMediaElementEncryptedMedia::trace(Visitor* visitor) | 560 void HTMLMediaElementEncryptedMedia::trace(Visitor* visitor) |
| 354 { | 561 { |
| 355 visitor->trace(m_mediaKeys); | 562 visitor->trace(m_mediaKeys); |
| 356 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); | 563 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); |
| 357 } | 564 } |
| 358 | 565 |
| 359 } // namespace blink | 566 } // namespace blink |
| OLD | NEW |