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 "modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.h" | 5 #include "modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 static WebMediaKeySystemConfiguration::Requirement convertMediaKeysRequirement(c
onst String& requirement) | 60 static WebMediaKeySystemConfiguration::Requirement convertMediaKeysRequirement(c
onst String& requirement) |
61 { | 61 { |
62 if (requirement == "required") | 62 if (requirement == "required") |
63 return WebMediaKeySystemConfiguration::Requirement::Required; | 63 return WebMediaKeySystemConfiguration::Requirement::Required; |
64 if (requirement == "optional") | 64 if (requirement == "optional") |
65 return WebMediaKeySystemConfiguration::Requirement::Optional; | 65 return WebMediaKeySystemConfiguration::Requirement::Optional; |
66 if (requirement == "not-allowed") | 66 if (requirement == "not-allowed") |
67 return WebMediaKeySystemConfiguration::Requirement::NotAllowed; | 67 return WebMediaKeySystemConfiguration::Requirement::NotAllowed; |
68 | 68 |
69 // Everything else gets the default value. | 69 // Everything else gets the default value. |
70 ASSERT_NOT_REACHED(); | 70 NOTREACHED(); |
71 return WebMediaKeySystemConfiguration::Requirement::Optional; | 71 return WebMediaKeySystemConfiguration::Requirement::Optional; |
72 } | 72 } |
73 | 73 |
74 static WebVector<WebEncryptedMediaSessionType> convertSessionTypes(const Vector<
String>& sessionTypes) | 74 static WebVector<WebEncryptedMediaSessionType> convertSessionTypes(const Vector<
String>& sessionTypes) |
75 { | 75 { |
76 WebVector<WebEncryptedMediaSessionType> result(sessionTypes.size()); | 76 WebVector<WebEncryptedMediaSessionType> result(sessionTypes.size()); |
77 for (size_t i = 0; i < sessionTypes.size(); ++i) | 77 for (size_t i = 0; i < sessionTypes.size(); ++i) |
78 result[i] = EncryptedMediaUtils::convertToSessionType(sessionTypes[i]); | 78 result[i] = EncryptedMediaUtils::convertToSessionType(sessionTypes[i]); |
79 return result; | 79 return result; |
80 } | 80 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 webConfig.initDataTypes = convertInitDataTypes(config.initDataTypes(
)); | 140 webConfig.initDataTypes = convertInitDataTypes(config.initDataTypes(
)); |
141 } | 141 } |
142 if (config.hasAudioCapabilities()) { | 142 if (config.hasAudioCapabilities()) { |
143 webConfig.hasAudioCapabilities = true; | 143 webConfig.hasAudioCapabilities = true; |
144 webConfig.audioCapabilities = convertCapabilities(config.audioCapabi
lities()); | 144 webConfig.audioCapabilities = convertCapabilities(config.audioCapabi
lities()); |
145 } | 145 } |
146 if (config.hasVideoCapabilities()) { | 146 if (config.hasVideoCapabilities()) { |
147 webConfig.hasVideoCapabilities = true; | 147 webConfig.hasVideoCapabilities = true; |
148 webConfig.videoCapabilities = convertCapabilities(config.videoCapabi
lities()); | 148 webConfig.videoCapabilities = convertCapabilities(config.videoCapabi
lities()); |
149 } | 149 } |
150 ASSERT(config.hasDistinctiveIdentifier()); | 150 DCHECK(config.hasDistinctiveIdentifier()); |
151 webConfig.distinctiveIdentifier = convertMediaKeysRequirement(config.dis
tinctiveIdentifier()); | 151 webConfig.distinctiveIdentifier = convertMediaKeysRequirement(config.dis
tinctiveIdentifier()); |
152 ASSERT(config.hasPersistentState()); | 152 DCHECK(config.hasPersistentState()); |
153 webConfig.persistentState = convertMediaKeysRequirement(config.persisten
tState()); | 153 webConfig.persistentState = convertMediaKeysRequirement(config.persisten
tState()); |
154 if (config.hasSessionTypes()) { | 154 if (config.hasSessionTypes()) { |
155 webConfig.hasSessionTypes = true; | 155 webConfig.hasSessionTypes = true; |
156 webConfig.sessionTypes = convertSessionTypes(config.sessionTypes()); | 156 webConfig.sessionTypes = convertSessionTypes(config.sessionTypes()); |
157 } | 157 } |
158 // If |label| is not present, it will be a null string. | 158 // If |label| is not present, it will be a null string. |
159 webConfig.label = config.label(); | 159 webConfig.label = config.label(); |
160 m_supportedConfigurations[i] = webConfig; | 160 m_supportedConfigurations[i] = webConfig; |
161 } | 161 } |
162 | 162 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 243 } |
244 | 244 |
245 } // namespace | 245 } // namespace |
246 | 246 |
247 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess( | 247 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess( |
248 ScriptState* scriptState, | 248 ScriptState* scriptState, |
249 Navigator& navigator, | 249 Navigator& navigator, |
250 const String& keySystem, | 250 const String& keySystem, |
251 const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations) | 251 const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations) |
252 { | 252 { |
253 WTF_LOG(Media, "NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemA
ccess()"); | 253 DVLOG(3) << "requestMediaKeySystemAccess()"; |
254 | 254 |
255 // From https://w3c.github.io/encrypted-media/#requestMediaKeySystemAccess | 255 // From https://w3c.github.io/encrypted-media/#requestMediaKeySystemAccess |
256 // When this method is invoked, the user agent must run the following steps: | 256 // When this method is invoked, the user agent must run the following steps: |
257 // 1. If keySystem is an empty string, return a promise rejected with a | 257 // 1. If keySystem is an empty string, return a promise rejected with a |
258 // new DOMException whose name is InvalidAccessError. | 258 // new DOMException whose name is InvalidAccessError. |
259 if (keySystem.isEmpty()) { | 259 if (keySystem.isEmpty()) { |
260 return ScriptPromise::rejectWithDOMException( | 260 return ScriptPromise::rejectWithDOMException( |
261 scriptState, DOMException::create(InvalidAccessError, "The keySystem
parameter is empty.")); | 261 scriptState, DOMException::create(InvalidAccessError, "The keySystem
parameter is empty.")); |
262 } | 262 } |
263 | 263 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 // initialize the MediaKeySystemAccess object. | 297 // initialize the MediaKeySystemAccess object. |
298 MediaKeysController* controller = MediaKeysController::from(document->page()
); | 298 MediaKeysController* controller = MediaKeysController::from(document->page()
); |
299 WebEncryptedMediaClient* mediaClient = controller->encryptedMediaClient(exec
utionContext); | 299 WebEncryptedMediaClient* mediaClient = controller->encryptedMediaClient(exec
utionContext); |
300 mediaClient->requestMediaKeySystemAccess(WebEncryptedMediaRequest(initialize
r)); | 300 mediaClient->requestMediaKeySystemAccess(WebEncryptedMediaRequest(initialize
r)); |
301 | 301 |
302 // 8. Return promise. | 302 // 8. Return promise. |
303 return promise; | 303 return promise; |
304 } | 304 } |
305 | 305 |
306 } // namespace blink | 306 } // namespace blink |
OLD | NEW |