Chromium Code Reviews| 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/V8Binding.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/EncryptedMediaUtils.h" | 36 #include "modules/encryptedmedia/EncryptedMediaUtils.h" |
| 35 #include "modules/encryptedmedia/MediaKeySession.h" | 37 #include "modules/encryptedmedia/MediaKeySession.h" |
| 36 #include "modules/encryptedmedia/SimpleContentDecryptionModuleResultPromise.h" | 38 #include "modules/encryptedmedia/SimpleContentDecryptionModuleResultPromise.h" |
| 37 #include "platform/Timer.h" | 39 #include "platform/Timer.h" |
| 38 #include "public/platform/WebContentDecryptionModule.h" | 40 #include "public/platform/WebContentDecryptionModule.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 // 4. Return session. | 169 // 4. Return session. |
| 168 return MediaKeySession::create(scriptState, this, sessionType); | 170 return MediaKeySession::create(scriptState, this, sessionType); |
| 169 } | 171 } |
| 170 | 172 |
| 171 ScriptPromise MediaKeys::setServerCertificate(ScriptState* scriptState, const DO MArrayPiece& serverCertificate) | 173 ScriptPromise MediaKeys::setServerCertificate(ScriptState* scriptState, const DO MArrayPiece& serverCertificate) |
| 172 { | 174 { |
| 173 // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-setservercertificate: | 175 // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-setservercertificate: |
| 174 // The setServerCertificate(serverCertificate) method provides a server | 176 // The setServerCertificate(serverCertificate) method provides a server |
| 175 // certificate to be used to encrypt messages to the license server. | 177 // certificate to be used to encrypt messages to the license server. |
| 176 // It must run the following steps: | 178 // It must run the following steps: |
| 177 // 1. If serverCertificate is an empty array, return a promise rejected | 179 // 1. If the Key System implementation represented by this object's cdm |
| 178 // with a new DOMException whose name is "InvalidAccessError". | 180 // implementation value does not support server certificates, return |
| 181 // a promise resolved with false. | |
| 182 // (Let the CDM decide whether to support this or not.) | |
|
ddorwin
2016/09/15 22:43:03
This is not spec compliant. The purpose of the spe
jrummell
2016/09/16 23:23:34
Replaced it with a TODO since it's currently not d
| |
| 183 // | |
| 184 // 2. If serverCertificate is an empty array, return a promise rejected | |
| 185 // with a new a newly created TypeError. | |
| 179 if (!serverCertificate.byteLength()) { | 186 if (!serverCertificate.byteLength()) { |
| 180 return ScriptPromise::rejectWithDOMException( | 187 return ScriptPromise::reject( |
| 181 scriptState, DOMException::create(InvalidAccessError, "The serverCer tificate parameter is empty.")); | 188 scriptState, v8::Exception::TypeError(v8String(scriptState->isolate( ), "The serverCertificate parameter is empty."))); |
| 182 } | 189 } |
| 183 | 190 |
| 184 // 2. If the keySystem does not support server certificates, return a | |
| 185 // promise rejected with a new DOMException whose name is | |
| 186 // "NotSupportedError". | |
| 187 // (Let the CDM decide whether to support this or not.) | |
| 188 | |
| 189 // 3. Let certificate be a copy of the contents of the serverCertificate | 191 // 3. Let certificate be a copy of the contents of the serverCertificate |
| 190 // parameter. | 192 // parameter. |
| 191 DOMArrayBuffer* serverCertificateBuffer = DOMArrayBuffer::create(serverCerti ficate.data(), serverCertificate.byteLength()); | 193 DOMArrayBuffer* serverCertificateBuffer = DOMArrayBuffer::create(serverCerti ficate.data(), serverCertificate.byteLength()); |
| 192 | 194 |
| 193 // 4. Let promise be a new promise. | 195 // 4. Let promise be a new promise. |
| 194 SetCertificateResultPromise* result = new SetCertificateResultPromise(script State); | 196 SetCertificateResultPromise* result = new SetCertificateResultPromise(script State); |
| 195 ScriptPromise promise = result->promise(); | 197 ScriptPromise promise = result->promise(); |
| 196 | 198 |
| 197 // 5. Run the following steps asynchronously (documented in timerFired()). | 199 // 5. Run the following steps asynchronously (documented in timerFired()). |
| 198 m_pendingActions.append(PendingAction::CreatePendingSetServerCertificate(res ult, serverCertificateBuffer)); | 200 m_pendingActions.append(PendingAction::CreatePendingSetServerCertificate(res ult, serverCertificateBuffer)); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 void MediaKeys::stop() | 302 void MediaKeys::stop() |
| 301 { | 303 { |
| 302 ActiveDOMObject::stop(); | 304 ActiveDOMObject::stop(); |
| 303 | 305 |
| 304 if (m_timer.isActive()) | 306 if (m_timer.isActive()) |
| 305 m_timer.stop(); | 307 m_timer.stop(); |
| 306 m_pendingActions.clear(); | 308 m_pendingActions.clear(); |
| 307 } | 309 } |
| 308 | 310 |
| 309 } // namespace blink | 311 } // namespace blink |
| OLD | NEW |