| 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/MediaKeySystemAccess.h" | 6 #include "modules/encryptedmedia/MediaKeySystemAccess.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // This class wraps the promise resolver used when creating MediaKeys | 28 // This class wraps the promise resolver used when creating MediaKeys |
| 29 // and is passed to Chromium to fullfill the promise. This implementation of | 29 // and is passed to Chromium to fullfill the promise. This implementation of |
| 30 // completeWithCdm() will resolve the promise with a new MediaKeys object, | 30 // completeWithCdm() will resolve the promise with a new MediaKeys object, |
| 31 // while completeWithError() will reject the promise with an exception. | 31 // while completeWithError() will reject the promise with an exception. |
| 32 // All other complete methods are not expected to be called, and will | 32 // All other complete methods are not expected to be called, and will |
| 33 // reject the promise. | 33 // reject the promise. |
| 34 class NewCdmResultPromise : public ContentDecryptionModuleResultPromise { | 34 class NewCdmResultPromise : public ContentDecryptionModuleResultPromise { |
| 35 WTF_MAKE_NONCOPYABLE(NewCdmResultPromise); | 35 WTF_MAKE_NONCOPYABLE(NewCdmResultPromise); |
| 36 | 36 |
| 37 public: | 37 public: |
| 38 NewCdmResultPromise(ScriptState* scriptState, const String& keySystem, const
blink::WebVector<blink::WebEncryptedMediaSessionType>& supportedSessionTypes) | 38 NewCdmResultPromise(ScriptState* scriptState, const String& keySystem, const
WebVector<WebEncryptedMediaSessionType>& supportedSessionTypes) |
| 39 : ContentDecryptionModuleResultPromise(scriptState) | 39 : ContentDecryptionModuleResultPromise(scriptState) |
| 40 , m_keySystem(keySystem) | 40 , m_keySystem(keySystem) |
| 41 , m_supportedSessionTypes(supportedSessionTypes) | 41 , m_supportedSessionTypes(supportedSessionTypes) |
| 42 { | 42 { |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual ~NewCdmResultPromise() | 45 virtual ~NewCdmResultPromise() |
| 46 { | 46 { |
| 47 } | 47 } |
| 48 | 48 |
| 49 // ContentDecryptionModuleResult implementation. | 49 // ContentDecryptionModuleResult implementation. |
| 50 virtual void completeWithContentDecryptionModule(WebContentDecryptionModule*
cdm) override | 50 virtual void completeWithContentDecryptionModule(WebContentDecryptionModule*
cdm) override |
| 51 { | 51 { |
| 52 // NOTE: Continued from step 2.8 of createMediaKeys(). | 52 // NOTE: Continued from step 2.8 of createMediaKeys(). |
| 53 // 2.9. Let media keys be a new MediaKeys object. | 53 // 2.9. Let media keys be a new MediaKeys object. |
| 54 MediaKeys* mediaKeys = new MediaKeys(executionContext(), m_keySystem, m_
supportedSessionTypes, adoptPtr(cdm)); | 54 MediaKeys* mediaKeys = new MediaKeys(executionContext(), m_keySystem, m_
supportedSessionTypes, adoptPtr(cdm)); |
| 55 | 55 |
| 56 // 2.10. Resolve promise with media keys. | 56 // 2.10. Resolve promise with media keys. |
| 57 resolve(mediaKeys); | 57 resolve(mediaKeys); |
| 58 } | 58 } |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 const String m_keySystem; | 61 const String m_keySystem; |
| 62 blink::WebVector<blink::WebEncryptedMediaSessionType> m_supportedSessionType
s; | 62 WebVector<WebEncryptedMediaSessionType> m_supportedSessionTypes; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // These methods are the inverses of those with the same names in | 65 // These methods are the inverses of those with the same names in |
| 66 // NavigatorRequestMediaKeySystemAccess. | 66 // NavigatorRequestMediaKeySystemAccess. |
| 67 static Vector<String> convertInitDataTypes(const WebVector<WebEncryptedMediaInit
DataType>& initDataTypes) | 67 static Vector<String> convertInitDataTypes(const WebVector<WebEncryptedMediaInit
DataType>& initDataTypes) |
| 68 { | 68 { |
| 69 Vector<String> result; | 69 Vector<String> result; |
| 70 result.reserveCapacity(initDataTypes.size()); | 70 result.reserveCapacity(initDataTypes.size()); |
| 71 for (size_t i = 0; i < initDataTypes.size(); i++) | 71 for (size_t i = 0; i < initDataTypes.size(); i++) |
| 72 result.append(EncryptedMediaUtils::convertFromInitDataType(initDataTypes
[i])); | 72 result.append(EncryptedMediaUtils::convertFromInitDataType(initDataTypes
[i])); |
| 73 return result; | 73 return result; |
| 74 } | 74 } |
| 75 | 75 |
| 76 static Vector<MediaKeySystemMediaCapability> convertCapabilities(const WebVector
<WebMediaKeySystemMediaCapability>& capabilities) | 76 static Vector<MediaKeySystemMediaCapability> convertCapabilities(const WebVector
<WebMediaKeySystemMediaCapability>& capabilities) |
| 77 { | 77 { |
| 78 Vector<MediaKeySystemMediaCapability> result; | 78 Vector<MediaKeySystemMediaCapability> result; |
| 79 result.reserveCapacity(capabilities.size()); | 79 result.reserveCapacity(capabilities.size()); |
| 80 for (size_t i = 0; i < capabilities.size(); i++) { | 80 for (size_t i = 0; i < capabilities.size(); i++) { |
| 81 MediaKeySystemMediaCapability capability; | 81 MediaKeySystemMediaCapability capability; |
| 82 capability.setContentType(capabilities[i].contentType); | 82 capability.setContentType(capabilities[i].contentType); |
| 83 capability.setRobustness(capabilities[i].robustness); | 83 capability.setRobustness(capabilities[i].robustness); |
| 84 result.append(capability); | 84 result.append(capability); |
| 85 } | 85 } |
| 86 return result; | 86 return result; |
| 87 } | 87 } |
| 88 | 88 |
| 89 static String convertMediaKeysRequirement(WebMediaKeySystemConfiguration::Requir
ement requirement) | 89 static String convertMediaKeysRequirement(WebMediaKeySystemConfiguration::Requir
ement requirement) |
| 90 { | 90 { |
| 91 switch (requirement) { | 91 switch (requirement) { |
| 92 case blink::WebMediaKeySystemConfiguration::Requirement::Required: | 92 case WebMediaKeySystemConfiguration::Requirement::Required: |
| 93 return "required"; | 93 return "required"; |
| 94 case blink::WebMediaKeySystemConfiguration::Requirement::Optional: | 94 case WebMediaKeySystemConfiguration::Requirement::Optional: |
| 95 return "optional"; | 95 return "optional"; |
| 96 case blink::WebMediaKeySystemConfiguration::Requirement::NotAllowed: | 96 case WebMediaKeySystemConfiguration::Requirement::NotAllowed: |
| 97 return "not-allowed"; | 97 return "not-allowed"; |
| 98 } | 98 } |
| 99 | 99 |
| 100 ASSERT_NOT_REACHED(); | 100 ASSERT_NOT_REACHED(); |
| 101 return "not-allowed"; | 101 return "not-allowed"; |
| 102 } | 102 } |
| 103 | 103 |
| 104 static Vector<String> convertSessionTypes(const WebVector<WebEncryptedMediaSessi
onType>& sessionTypes) | 104 static Vector<String> convertSessionTypes(const WebVector<WebEncryptedMediaSessi
onType>& sessionTypes) |
| 105 { | 105 { |
| 106 Vector<String> result; | 106 Vector<String> result; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 // 3. Return promise. | 169 // 3. Return promise. |
| 170 return promise; | 170 return promise; |
| 171 } | 171 } |
| 172 | 172 |
| 173 DEFINE_TRACE(MediaKeySystemAccess) | 173 DEFINE_TRACE(MediaKeySystemAccess) |
| 174 { | 174 { |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace blink | 177 } // namespace blink |
| OLD | NEW |