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 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 PendingAction(ContentDecryptionModuleResult* result, DOMArrayBuffer* data) | 73 PendingAction(ContentDecryptionModuleResult* result, DOMArrayBuffer* 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 Member<DOMArrayBuffer> m_data; | 80 const Member<DOMArrayBuffer> m_data; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 // This class wraps the promise resolver used when setting the certificate | |
| 84 // and is passed to Chromium to fullfill the promise. This implementation of | |
| 85 // complete() will resolve the promise with true, while completeWithError() | |
| 86 // will reject the promise with an exception. completeWithSession() | |
| 87 // is not expected to be called, and will reject the promise. | |
| 88 class SetCertificateResultPromise : public ContentDecryptionModuleResultPromise { | |
| 89 public: | |
| 90 SetCertificateResultPromise(ScriptState* scriptState) | |
| 91 : ContentDecryptionModuleResultPromise(scriptState) | |
| 92 { | |
| 93 } | |
| 94 | |
| 95 ~SetCertificateResultPromise() override | |
| 96 { | |
| 97 } | |
| 98 | |
| 99 // ContentDecryptionModuleResult implementation. | |
| 100 void complete() override | |
| 101 { | |
| 102 // TODO(jrummell): The EME spec specifies that "If the Key System | |
| 103 // implementation does not support server certificates, return a | |
| 104 // promise resolved with false." Need to have chromium return a bool | |
| 105 // so that resolving with false is possible. http://crbug.com/618800. | |
| 106 resolve(true); | |
|
xhwang
2016/06/10 21:40:11
Can we translate completeWithError(NOT_SUPPORTED_E
jrummell
2016/06/10 23:01:15
Done. I checked all the calls for SetServerCertifi
| |
| 107 } | |
| 108 }; | |
| 109 | |
| 83 MediaKeys* MediaKeys::create(ExecutionContext* context, const WebVector<WebEncry ptedMediaSessionType>& supportedSessionTypes, PassOwnPtr<WebContentDecryptionMod ule> cdm) | 110 MediaKeys* MediaKeys::create(ExecutionContext* context, const WebVector<WebEncry ptedMediaSessionType>& supportedSessionTypes, PassOwnPtr<WebContentDecryptionMod ule> cdm) |
| 84 { | 111 { |
| 85 MediaKeys* mediaKeys = new MediaKeys(context, supportedSessionTypes, std::mo ve(cdm)); | 112 MediaKeys* mediaKeys = new MediaKeys(context, supportedSessionTypes, std::mo ve(cdm)); |
| 86 mediaKeys->suspendIfNeeded(); | 113 mediaKeys->suspendIfNeeded(); |
| 87 return mediaKeys; | 114 return mediaKeys; |
| 88 } | 115 } |
| 89 | 116 |
| 90 MediaKeys::MediaKeys(ExecutionContext* context, const WebVector<WebEncryptedMedi aSessionType>& supportedSessionTypes, PassOwnPtr<WebContentDecryptionModule> cdm ) | 117 MediaKeys::MediaKeys(ExecutionContext* context, const WebVector<WebEncryptedMedi aSessionType>& supportedSessionTypes, PassOwnPtr<WebContentDecryptionModule> cdm ) |
| 91 : ActiveScriptWrappable(this) | 118 : ActiveScriptWrappable(this) |
| 92 , ActiveDOMObject(context) | 119 , ActiveDOMObject(context) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 // 2. If the keySystem does not support server certificates, return a | 175 // 2. If the keySystem does not support server certificates, return a |
| 149 // promise rejected with a new DOMException whose name is | 176 // promise rejected with a new DOMException whose name is |
| 150 // "NotSupportedError". | 177 // "NotSupportedError". |
| 151 // (Let the CDM decide whether to support this or not.) | 178 // (Let the CDM decide whether to support this or not.) |
| 152 | 179 |
| 153 // 3. Let certificate be a copy of the contents of the serverCertificate | 180 // 3. Let certificate be a copy of the contents of the serverCertificate |
| 154 // parameter. | 181 // parameter. |
| 155 DOMArrayBuffer* serverCertificateBuffer = DOMArrayBuffer::create(serverCerti ficate.data(), serverCertificate.byteLength()); | 182 DOMArrayBuffer* serverCertificateBuffer = DOMArrayBuffer::create(serverCerti ficate.data(), serverCertificate.byteLength()); |
| 156 | 183 |
| 157 // 4. Let promise be a new promise. | 184 // 4. Let promise be a new promise. |
| 158 SimpleContentDecryptionModuleResultPromise* result = new SimpleContentDecryp tionModuleResultPromise(scriptState); | 185 SetCertificateResultPromise* result = new SetCertificateResultPromise(script State); |
| 159 ScriptPromise promise = result->promise(); | 186 ScriptPromise promise = result->promise(); |
| 160 | 187 |
| 161 // 5. Run the following steps asynchronously (documented in timerFired()). | 188 // 5. Run the following steps asynchronously (documented in timerFired()). |
| 162 m_pendingActions.append(PendingAction::CreatePendingSetServerCertificate(res ult, serverCertificateBuffer)); | 189 m_pendingActions.append(PendingAction::CreatePendingSetServerCertificate(res ult, serverCertificateBuffer)); |
| 163 if (!m_timer.isActive()) | 190 if (!m_timer.isActive()) |
| 164 m_timer.startOneShot(0, BLINK_FROM_HERE); | 191 m_timer.startOneShot(0, BLINK_FROM_HERE); |
| 165 | 192 |
| 166 // 6. Return promise. | 193 // 6. Return promise. |
| 167 return promise; | 194 return promise; |
| 168 } | 195 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 void MediaKeys::stop() | 291 void MediaKeys::stop() |
| 265 { | 292 { |
| 266 ActiveDOMObject::stop(); | 293 ActiveDOMObject::stop(); |
| 267 | 294 |
| 268 if (m_timer.isActive()) | 295 if (m_timer.isActive()) |
| 269 m_timer.stop(); | 296 m_timer.stop(); |
| 270 m_pendingActions.clear(); | 297 m_pendingActions.clear(); |
| 271 } | 298 } |
| 272 | 299 |
| 273 } // namespace blink | 300 } // namespace blink |
| OLD | NEW |