| 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/ScriptPromise.h" | 7 #include "bindings/core/v8/ScriptPromise.h" |
| 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 "bindings/core/v8/V8ThrowException.h" | 10 #include "bindings/core/v8/V8ThrowException.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // |m_supportedConfigurations| contains any video capability with empty | 123 // |m_supportedConfigurations| contains any video capability with empty |
| 124 // robustness string. | 124 // robustness string. |
| 125 void checkVideoCapabilityRobustness() const; | 125 void checkVideoCapabilityRobustness() const; |
| 126 | 126 |
| 127 // Generate deprecation warning and log UseCounter if configuration | 127 // Generate deprecation warning and log UseCounter if configuration |
| 128 // contains only container-only contentType strings. | 128 // contains only container-only contentType strings. |
| 129 // TODO(jrummell): Remove once this is no longer allowed. | 129 // TODO(jrummell): Remove once this is no longer allowed. |
| 130 // See http://crbug.com/605661. | 130 // See http://crbug.com/605661. |
| 131 void checkEmptyCodecs(const WebMediaKeySystemConfiguration&); | 131 void checkEmptyCodecs(const WebMediaKeySystemConfiguration&); |
| 132 | 132 |
| 133 // Log UseCounter if selected configuration does not have at least one of | |
| 134 // 'audioCapabilities' and 'videoCapabilities' non-empty. | |
| 135 // TODO(jrummell): Switch to deprecation message once we have data. | |
| 136 // See http://crbug.com/616233. | |
| 137 void checkCapabilities(const WebMediaKeySystemConfiguration&); | |
| 138 | |
| 139 Member<ScriptPromiseResolver> m_resolver; | 133 Member<ScriptPromiseResolver> m_resolver; |
| 140 const String m_keySystem; | 134 const String m_keySystem; |
| 141 WebVector<WebMediaKeySystemConfiguration> m_supportedConfigurations; | 135 WebVector<WebMediaKeySystemConfiguration> m_supportedConfigurations; |
| 142 }; | 136 }; |
| 143 | 137 |
| 144 MediaKeySystemAccessInitializer::MediaKeySystemAccessInitializer( | 138 MediaKeySystemAccessInitializer::MediaKeySystemAccessInitializer( |
| 145 ScriptState* scriptState, | 139 ScriptState* scriptState, |
| 146 const String& keySystem, | 140 const String& keySystem, |
| 147 const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations) | 141 const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations) |
| 148 : m_resolver(ScriptPromiseResolver::create(scriptState)), | 142 : m_resolver(ScriptPromiseResolver::create(scriptState)), |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 189 |
| 196 SecurityOrigin* MediaKeySystemAccessInitializer::getSecurityOrigin() const { | 190 SecurityOrigin* MediaKeySystemAccessInitializer::getSecurityOrigin() const { |
| 197 return isExecutionContextValid() | 191 return isExecutionContextValid() |
| 198 ? m_resolver->getExecutionContext()->getSecurityOrigin() | 192 ? m_resolver->getExecutionContext()->getSecurityOrigin() |
| 199 : nullptr; | 193 : nullptr; |
| 200 } | 194 } |
| 201 | 195 |
| 202 void MediaKeySystemAccessInitializer::requestSucceeded( | 196 void MediaKeySystemAccessInitializer::requestSucceeded( |
| 203 WebContentDecryptionModuleAccess* access) { | 197 WebContentDecryptionModuleAccess* access) { |
| 204 checkEmptyCodecs(access->getConfiguration()); | 198 checkEmptyCodecs(access->getConfiguration()); |
| 205 checkCapabilities(access->getConfiguration()); | |
| 206 | 199 |
| 207 if (!isExecutionContextValid()) | 200 if (!isExecutionContextValid()) |
| 208 return; | 201 return; |
| 209 | 202 |
| 210 m_resolver->resolve( | 203 m_resolver->resolve( |
| 211 new MediaKeySystemAccess(m_keySystem, WTF::wrapUnique(access))); | 204 new MediaKeySystemAccess(m_keySystem, WTF::wrapUnique(access))); |
| 212 m_resolver.clear(); | 205 m_resolver.clear(); |
| 213 } | 206 } |
| 214 | 207 |
| 215 void MediaKeySystemAccessInitializer::requestNotSupported( | 208 void MediaKeySystemAccessInitializer::requestNotSupported( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 Deprecation::countDeprecation( | 288 Deprecation::countDeprecation( |
| 296 m_resolver->getExecutionContext(), | 289 m_resolver->getExecutionContext(), |
| 297 UseCounter::EncryptedMediaAllSelectedContentTypesMissingCodecs); | 290 UseCounter::EncryptedMediaAllSelectedContentTypesMissingCodecs); |
| 298 } else { | 291 } else { |
| 299 UseCounter::count( | 292 UseCounter::count( |
| 300 m_resolver->getExecutionContext(), | 293 m_resolver->getExecutionContext(), |
| 301 UseCounter::EncryptedMediaAllSelectedContentTypesHaveCodecs); | 294 UseCounter::EncryptedMediaAllSelectedContentTypesHaveCodecs); |
| 302 } | 295 } |
| 303 } | 296 } |
| 304 | 297 |
| 305 void MediaKeySystemAccessInitializer::checkCapabilities( | |
| 306 const WebMediaKeySystemConfiguration& config) { | |
| 307 // This is only checking that at least one capability is provided in the | |
| 308 // selected configuration, as apps may pass empty capabilities for | |
| 309 // compatibility with other implementations. | |
| 310 bool atLeastOneAudioCapability = config.audioCapabilities.size() > 0; | |
| 311 bool atLeastOneVideoCapability = config.videoCapabilities.size() > 0; | |
| 312 | |
| 313 if (atLeastOneAudioCapability || atLeastOneVideoCapability) { | |
| 314 UseCounter::count(m_resolver->getExecutionContext(), | |
| 315 UseCounter::EncryptedMediaCapabilityProvided); | |
| 316 } else { | |
| 317 Deprecation::countDeprecation( | |
| 318 m_resolver->getExecutionContext(), | |
| 319 UseCounter::EncryptedMediaCapabilityNotProvided); | |
| 320 } | |
| 321 } | |
| 322 | |
| 323 } // namespace | 298 } // namespace |
| 324 | 299 |
| 325 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess( | 300 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess( |
| 326 ScriptState* scriptState, | 301 ScriptState* scriptState, |
| 327 Navigator& navigator, | 302 Navigator& navigator, |
| 328 const String& keySystem, | 303 const String& keySystem, |
| 329 const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations) { | 304 const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations) { |
| 330 DVLOG(3) << __func__; | 305 DVLOG(3) << __func__; |
| 331 | 306 |
| 332 // From https://w3c.github.io/encrypted-media/#requestMediaKeySystemAccess | 307 // From https://w3c.github.io/encrypted-media/#requestMediaKeySystemAccess |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 WebEncryptedMediaClient* mediaClient = | 363 WebEncryptedMediaClient* mediaClient = |
| 389 controller->encryptedMediaClient(executionContext); | 364 controller->encryptedMediaClient(executionContext); |
| 390 mediaClient->requestMediaKeySystemAccess( | 365 mediaClient->requestMediaKeySystemAccess( |
| 391 WebEncryptedMediaRequest(initializer)); | 366 WebEncryptedMediaRequest(initializer)); |
| 392 | 367 |
| 393 // 7. Return promise. | 368 // 7. Return promise. |
| 394 return promise; | 369 return promise; |
| 395 } | 370 } |
| 396 | 371 |
| 397 } // namespace blink | 372 } // namespace blink |
| OLD | NEW |