| 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" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 fail(QuotaExceededError, "The MediaKeys object is already in use by
another media element."); | 170 fail(QuotaExceededError, "The MediaKeys object is already in use by
another media element."); |
| 171 return; | 171 return; |
| 172 } | 172 } |
| 173 // Note that |m_newMediaKeys| is considered owned by |m_element|, so | 173 // Note that |m_newMediaKeys| is considered owned by |m_element|, so |
| 174 // it needs to be reset if any of these steps fail. | 174 // it needs to be reset if any of these steps fail. |
| 175 m_tookOwnership = true; | 175 m_tookOwnership = true; |
| 176 } | 176 } |
| 177 | 177 |
| 178 // 3.2 If the mediaKeys attribute is not null, run the following steps: | 178 // 3.2 If the mediaKeys attribute is not null, run the following steps: |
| 179 if (thisElement.m_mediaKeys) { | 179 if (thisElement.m_mediaKeys) { |
| 180 // 3.2.1 If the user agent or CDM do not support removing the | |
| 181 // association, return a promise rejected with a new DOMException | |
| 182 // whose name is "NotSupportedError". | |
| 183 // (supported by blink). | |
| 184 // 3.2.2 If the association cannot currently be removed (i.e. during | |
| 185 // playback), return a promise rejected with a new DOMException | |
| 186 // whose name is "InvalidStateError". | |
| 187 WebMediaPlayer* mediaPlayer = m_element->webMediaPlayer(); | 180 WebMediaPlayer* mediaPlayer = m_element->webMediaPlayer(); |
| 188 if (mediaPlayer) { | 181 if (mediaPlayer) { |
| 189 if (!mediaPlayer->paused()) { | 182 // 3.2.1 If the user agent or CDM do not support removing the |
| 190 fail(InvalidStateError, "The existing MediaKeys object cannot be
removed while a media resource is playing."); | 183 // association, return a promise rejected with a new |
| 191 return; | 184 // DOMException whose name is "NotSupportedError". |
| 192 } | 185 // 3.2.2 If the association cannot currently be removed (i.e. |
| 193 | 186 // during playback), return a promise rejected with a new |
| 187 // DOMException whose name is "InvalidStateError". |
| 194 // 3.2.3 Stop using the CDM instance represented by the mediaKeys | 188 // 3.2.3 Stop using the CDM instance represented by the mediaKeys |
| 195 // attribute to decrypt media data and remove the association | 189 // attribute to decrypt media data and remove the association |
| 196 // with the media element. | 190 // with the media element. |
| 191 // (All 3 steps handled as needed in Chromium.) |
| 197 OwnPtr<SuccessCallback> successCallback = bind(&SetMediaKeysHandler:
:setNewMediaKeys, this); | 192 OwnPtr<SuccessCallback> successCallback = bind(&SetMediaKeysHandler:
:setNewMediaKeys, this); |
| 198 OwnPtr<FailureCallback> failureCallback = bind<ExceptionCode, const
String&>(&SetMediaKeysHandler::clearFailed, this); | 193 OwnPtr<FailureCallback> failureCallback = bind<ExceptionCode, const
String&>(&SetMediaKeysHandler::clearFailed, this); |
| 199 ContentDecryptionModuleResult* result = new SetContentDecryptionModu
leResult(successCallback.release(), failureCallback.release()); | 194 ContentDecryptionModuleResult* result = new SetContentDecryptionModu
leResult(successCallback.release(), failureCallback.release()); |
| 200 mediaPlayer->setContentDecryptionModule(nullptr, result->result()); | 195 mediaPlayer->setContentDecryptionModule(nullptr, result->result()); |
| 201 | 196 |
| 202 // Don't do anything more until |result| is resolved (or rejected). | 197 // Don't do anything more until |result| is resolved (or rejected). |
| 203 return; | 198 return; |
| 204 } | 199 } |
| 205 } | 200 } |
| 206 | 201 |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 return thisElement.contentDecryptionModule(); | 632 return thisElement.contentDecryptionModule(); |
| 638 } | 633 } |
| 639 | 634 |
| 640 DEFINE_TRACE(HTMLMediaElementEncryptedMedia) | 635 DEFINE_TRACE(HTMLMediaElementEncryptedMedia) |
| 641 { | 636 { |
| 642 visitor->trace(m_mediaKeys); | 637 visitor->trace(m_mediaKeys); |
| 643 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); | 638 WillBeHeapSupplement<HTMLMediaElement>::trace(visitor); |
| 644 } | 639 } |
| 645 | 640 |
| 646 } // namespace blink | 641 } // namespace blink |
| OLD | NEW |