Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp

Issue 2397543002: EME: Check capabilities provided only on success (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // TODO(xhwang): Remove after we handle empty robustness correctly. 122 // TODO(xhwang): Remove after we handle empty robustness correctly.
123 // See http://crbug.com/482277 123 // See http://crbug.com/482277
124 void checkVideoCapabilityRobustness() const; 124 void checkVideoCapabilityRobustness() const;
125 125
126 // Generate deprecation warning and log UseCounter if configuration 126 // Generate deprecation warning and log UseCounter if configuration
127 // contains only container-only contentType strings. 127 // contains only container-only contentType strings.
128 // TODO(jrummell): Remove once this is no longer allowed. 128 // TODO(jrummell): Remove once this is no longer allowed.
129 // See http://crbug.com/605661. 129 // See http://crbug.com/605661.
130 void checkEmptyCodecs(const WebMediaKeySystemConfiguration&); 130 void checkEmptyCodecs(const WebMediaKeySystemConfiguration&);
131 131
132 // Log UseCounter if configuration does not have at least one of 132 // Log UseCounter if selected configuration does not have at least one of
133 // 'audioCapabilities' and 'videoCapabilities' non-empty. 133 // 'audioCapabilities' and 'videoCapabilities' non-empty.
134 // TODO(jrummell): Switch to deprecation message once we have data. 134 // TODO(jrummell): Switch to deprecation message once we have data.
135 // See http://crbug.com/616233. 135 // See http://crbug.com/616233.
136 void checkCapabilitiesProvided(const WebMediaKeySystemConfiguration&); 136 void checkCapabilitiesProvided(const WebMediaKeySystemConfiguration&);
137 137
138 Member<ScriptPromiseResolver> m_resolver; 138 Member<ScriptPromiseResolver> m_resolver;
139 const String m_keySystem; 139 const String m_keySystem;
140 WebVector<WebMediaKeySystemConfiguration> m_supportedConfigurations; 140 WebVector<WebMediaKeySystemConfiguration> m_supportedConfigurations;
141 }; 141 };
142 142
(...skipping 12 matching lines...) Expand all
155 webConfig.initDataTypes = convertInitDataTypes(config.initDataTypes()); 155 webConfig.initDataTypes = convertInitDataTypes(config.initDataTypes());
156 156
157 DCHECK(config.hasAudioCapabilities()); 157 DCHECK(config.hasAudioCapabilities());
158 webConfig.audioCapabilities = 158 webConfig.audioCapabilities =
159 convertCapabilities(config.audioCapabilities()); 159 convertCapabilities(config.audioCapabilities());
160 160
161 DCHECK(config.hasVideoCapabilities()); 161 DCHECK(config.hasVideoCapabilities());
162 webConfig.videoCapabilities = 162 webConfig.videoCapabilities =
163 convertCapabilities(config.videoCapabilities()); 163 convertCapabilities(config.videoCapabilities());
164 164
165 checkCapabilitiesProvided(webConfig);
166
167 DCHECK(config.hasDistinctiveIdentifier()); 165 DCHECK(config.hasDistinctiveIdentifier());
168 webConfig.distinctiveIdentifier = 166 webConfig.distinctiveIdentifier =
169 convertMediaKeysRequirement(config.distinctiveIdentifier()); 167 convertMediaKeysRequirement(config.distinctiveIdentifier());
170 168
171 DCHECK(config.hasPersistentState()); 169 DCHECK(config.hasPersistentState());
172 webConfig.persistentState = 170 webConfig.persistentState =
173 convertMediaKeysRequirement(config.persistentState()); 171 convertMediaKeysRequirement(config.persistentState());
174 172
175 if (config.hasSessionTypes()) { 173 if (config.hasSessionTypes()) {
176 webConfig.sessionTypes = convertSessionTypes(config.sessionTypes()); 174 webConfig.sessionTypes = convertSessionTypes(config.sessionTypes());
(...skipping 12 matching lines...) Expand all
189 webConfig.label = config.label(); 187 webConfig.label = config.label();
190 m_supportedConfigurations[i] = webConfig; 188 m_supportedConfigurations[i] = webConfig;
191 } 189 }
192 190
193 checkVideoCapabilityRobustness(); 191 checkVideoCapabilityRobustness();
194 } 192 }
195 193
196 void MediaKeySystemAccessInitializer::requestSucceeded( 194 void MediaKeySystemAccessInitializer::requestSucceeded(
197 WebContentDecryptionModuleAccess* access) { 195 WebContentDecryptionModuleAccess* access) {
198 checkEmptyCodecs(access->getConfiguration()); 196 checkEmptyCodecs(access->getConfiguration());
197 checkCapabilitiesProvided(access->getConfiguration());
199 198
200 m_resolver->resolve( 199 m_resolver->resolve(
201 new MediaKeySystemAccess(m_keySystem, wrapUnique(access))); 200 new MediaKeySystemAccess(m_keySystem, wrapUnique(access)));
202 m_resolver.clear(); 201 m_resolver.clear();
203 } 202 }
204 203
205 void MediaKeySystemAccessInitializer::requestNotSupported( 204 void MediaKeySystemAccessInitializer::requestNotSupported(
206 const WebString& errorMessage) { 205 const WebString& errorMessage) {
207 m_resolver->reject(DOMException::create(NotSupportedError, errorMessage)); 206 m_resolver->reject(DOMException::create(NotSupportedError, errorMessage));
208 m_resolver.clear(); 207 m_resolver.clear();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 Deprecation::countDeprecation( 274 Deprecation::countDeprecation(
276 m_resolver->getExecutionContext(), 275 m_resolver->getExecutionContext(),
277 UseCounter::EncryptedMediaAllSelectedContentTypesMissingCodecs); 276 UseCounter::EncryptedMediaAllSelectedContentTypesMissingCodecs);
278 } else { 277 } else {
279 UseCounter::count( 278 UseCounter::count(
280 m_resolver->getExecutionContext(), 279 m_resolver->getExecutionContext(),
281 UseCounter::EncryptedMediaAllSelectedContentTypesHaveCodecs); 280 UseCounter::EncryptedMediaAllSelectedContentTypesHaveCodecs);
282 } 281 }
283 } 282 }
284 283
285 void MediaKeySystemAccessInitializer::checkCapabilitiesProvided( 284 void MediaKeySystemAccessInitializer::checkCapabilitiesProvided(
xhwang 2016/10/06 17:01:05 "provided" is a bit ambiguous..
jrummell 2016/10/06 18:43:04 Removed "Provided".
286 const WebMediaKeySystemConfiguration& config) { 285 const WebMediaKeySystemConfiguration& config) {
286 // This is only checking that at least one capability is provided in the
287 // selected configuration, as apps may pass empty capabilities for
288 // compatibility with other implementations.
287 bool atLeastOneAudioCapability = config.audioCapabilities.size() > 0; 289 bool atLeastOneAudioCapability = config.audioCapabilities.size() > 0;
288 bool atLeastOneVideoCapability = config.videoCapabilities.size() > 0; 290 bool atLeastOneVideoCapability = config.videoCapabilities.size() > 0;
289 291
290 if (atLeastOneAudioCapability || atLeastOneVideoCapability) { 292 if (atLeastOneAudioCapability || atLeastOneVideoCapability) {
291 UseCounter::count(m_resolver->getExecutionContext(), 293 UseCounter::count(m_resolver->getExecutionContext(),
292 UseCounter::EncryptedMediaCapabilityProvided); 294 UseCounter::EncryptedMediaCapabilityProvided);
293 } else { 295 } else {
294 // TODO(jrummell): Switch to deprecation message once we understand 296 // TODO(jrummell): Switch to deprecation message once we understand
295 // current usage. http://crbug.com/616233. 297 // current usage. http://crbug.com/616233.
296 UseCounter::count(m_resolver->getExecutionContext(), 298 UseCounter::count(m_resolver->getExecutionContext(),
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 WebEncryptedMediaClient* mediaClient = 369 WebEncryptedMediaClient* mediaClient =
368 controller->encryptedMediaClient(executionContext); 370 controller->encryptedMediaClient(executionContext);
369 mediaClient->requestMediaKeySystemAccess( 371 mediaClient->requestMediaKeySystemAccess(
370 WebEncryptedMediaRequest(initializer)); 372 WebEncryptedMediaRequest(initializer));
371 373
372 // 7. Return promise. 374 // 7. Return promise.
373 return promise; 375 return promise;
374 } 376 }
375 377
376 } // namespace blink 378 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698