| OLD | NEW |
| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "modules/encryptedmedia/MediaKeys.h" | 26 #include "modules/encryptedmedia/MediaKeys.h" |
| 27 | 27 |
| 28 #include "bindings/core/v8/ScriptPromise.h" |
| 28 #include "bindings/core/v8/ScriptState.h" | 29 #include "bindings/core/v8/ScriptState.h" |
| 30 #include "bindings/core/v8/V8ThrowException.h" |
| 29 #include "core/dom/DOMArrayBuffer.h" | 31 #include "core/dom/DOMArrayBuffer.h" |
| 30 #include "core/dom/DOMException.h" | 32 #include "core/dom/DOMException.h" |
| 31 #include "core/dom/ExceptionCode.h" | 33 #include "core/dom/ExceptionCode.h" |
| 32 #include "core/dom/ExecutionContext.h" | 34 #include "core/dom/ExecutionContext.h" |
| 33 #include "core/html/HTMLMediaElement.h" | 35 #include "core/html/HTMLMediaElement.h" |
| 34 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h" | 36 #include "modules/encryptedmedia/ContentDecryptionModuleResultPromise.h" |
| 35 #include "modules/encryptedmedia/EncryptedMediaUtils.h" | 37 #include "modules/encryptedmedia/EncryptedMediaUtils.h" |
| 36 #include "modules/encryptedmedia/MediaKeySession.h" | 38 #include "modules/encryptedmedia/MediaKeySession.h" |
| 37 #include "platform/Timer.h" | 39 #include "platform/Timer.h" |
| 38 #include "public/platform/WebContentDecryptionModule.h" | 40 #include "public/platform/WebContentDecryptionModule.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 return MediaKeySession::create(scriptState, this, sessionType); | 185 return MediaKeySession::create(scriptState, this, sessionType); |
| 184 } | 186 } |
| 185 | 187 |
| 186 ScriptPromise MediaKeys::setServerCertificate( | 188 ScriptPromise MediaKeys::setServerCertificate( |
| 187 ScriptState* scriptState, | 189 ScriptState* scriptState, |
| 188 const DOMArrayPiece& serverCertificate) { | 190 const DOMArrayPiece& serverCertificate) { |
| 189 // From https://w3c.github.io/encrypted-media/#setServerCertificate | 191 // From https://w3c.github.io/encrypted-media/#setServerCertificate |
| 190 // The setServerCertificate(serverCertificate) method provides a server | 192 // The setServerCertificate(serverCertificate) method provides a server |
| 191 // certificate to be used to encrypt messages to the license server. | 193 // certificate to be used to encrypt messages to the license server. |
| 192 // It must run the following steps: | 194 // It must run the following steps: |
| 193 // 1. If serverCertificate is an empty array, return a promise rejected | 195 // 1. If the Key System implementation represented by this object's cdm |
| 194 // with a new DOMException whose name is "InvalidAccessError". | 196 // implementation value does not support server certificates, return |
| 197 // a promise resolved with false. |
| 198 // TODO(jrummell): Provide a way to determine if the CDM supports this. |
| 199 // http://crbug.com/647816. |
| 200 // |
| 201 // 2. If serverCertificate is an empty array, return a promise rejected |
| 202 // with a new a newly created TypeError. |
| 195 if (!serverCertificate.byteLength()) { | 203 if (!serverCertificate.byteLength()) { |
| 196 return ScriptPromise::rejectWithDOMException( | 204 return ScriptPromise::reject( |
| 197 scriptState, | 205 scriptState, V8ThrowException::createTypeError( |
| 198 DOMException::create(InvalidAccessError, | 206 scriptState->isolate(), |
| 199 "The serverCertificate parameter is empty.")); | 207 "The serverCertificate parameter is empty.")); |
| 200 } | 208 } |
| 201 | 209 |
| 202 // 2. If the keySystem does not support server certificates, return a | |
| 203 // promise rejected with a new DOMException whose name is | |
| 204 // "NotSupportedError". | |
| 205 // (Let the CDM decide whether to support this or not.) | |
| 206 | |
| 207 // 3. Let certificate be a copy of the contents of the serverCertificate | 210 // 3. Let certificate be a copy of the contents of the serverCertificate |
| 208 // parameter. | 211 // parameter. |
| 209 DOMArrayBuffer* serverCertificateBuffer = DOMArrayBuffer::create( | 212 DOMArrayBuffer* serverCertificateBuffer = DOMArrayBuffer::create( |
| 210 serverCertificate.data(), serverCertificate.byteLength()); | 213 serverCertificate.data(), serverCertificate.byteLength()); |
| 211 | 214 |
| 212 // 4. Let promise be a new promise. | 215 // 4. Let promise be a new promise. |
| 213 SetCertificateResultPromise* result = | 216 SetCertificateResultPromise* result = |
| 214 new SetCertificateResultPromise(scriptState, this); | 217 new SetCertificateResultPromise(scriptState, this); |
| 215 ScriptPromise promise = result->promise(); | 218 ScriptPromise promise = result->promise(); |
| 216 | 219 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 // Remain around if there are pending events. | 309 // Remain around if there are pending events. |
| 307 DVLOG(MEDIA_KEYS_LOG_LEVEL) | 310 DVLOG(MEDIA_KEYS_LOG_LEVEL) |
| 308 << __func__ << "(" << this << ")" | 311 << __func__ << "(" << this << ")" |
| 309 << (!m_pendingActions.isEmpty() ? " !m_pendingActions.isEmpty()" : "") | 312 << (!m_pendingActions.isEmpty() ? " !m_pendingActions.isEmpty()" : "") |
| 310 << (m_reservedForMediaElement ? " m_reservedForMediaElement" : ""); | 313 << (m_reservedForMediaElement ? " m_reservedForMediaElement" : ""); |
| 311 | 314 |
| 312 return !m_pendingActions.isEmpty() || m_reservedForMediaElement; | 315 return !m_pendingActions.isEmpty() || m_reservedForMediaElement; |
| 313 } | 316 } |
| 314 | 317 |
| 315 } // namespace blink | 318 } // namespace blink |
| OLD | NEW |