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 "webencryptedmediaclient_impl.h" | 5 #include "webencryptedmediaclient_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 NOTREACHED(); | 133 NOTREACHED(); |
134 return EME_FEATURE_NOT_ALLOWED; | 134 return EME_FEATURE_NOT_ALLOWED; |
135 } | 135 } |
136 | 136 |
137 static ConfigurationSupport GetSupportedConfiguration( | 137 static ConfigurationSupport GetSupportedConfiguration( |
138 const std::string& key_system, | 138 const std::string& key_system, |
139 const blink::WebMediaKeySystemConfiguration& candidate, | 139 const blink::WebMediaKeySystemConfiguration& candidate, |
140 blink::WebMediaKeySystemConfiguration* accumulated_configuration, | 140 blink::WebMediaKeySystemConfiguration* accumulated_configuration, |
141 bool was_permission_requested, | 141 bool was_permission_requested, |
142 bool is_permission_granted) { | 142 bool is_permission_granted) { |
| 143 DCHECK(was_permission_requested || !is_permission_granted); |
| 144 |
143 // It is possible to obtain user permission unless permission was already | 145 // It is possible to obtain user permission unless permission was already |
144 // requested and denied. | 146 // requested and denied. |
145 bool is_permission_possible = | 147 bool is_permission_possible = |
146 !was_permission_requested || is_permission_granted; | 148 !was_permission_requested || is_permission_granted; |
147 | 149 |
148 // From https://w3c.github.io/encrypted-media/#get-supported-configuration | 150 // From https://w3c.github.io/encrypted-media/#get-supported-configuration |
149 // 1. Let accumulated configuration be empty. (Done by caller.) | 151 // 1. Let accumulated configuration be empty. (Done by caller.) |
150 // 2. If candidate configuration's initDataTypes attribute is not empty, run | 152 // 2. If candidate configuration's initDataTypes attribute is not empty, run |
151 // the following steps: | 153 // the following steps: |
152 if (!candidate.initDataTypes.isEmpty()) { | 154 if (!candidate.initDataTypes.isEmpty()) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 297 } |
296 } | 298 } |
297 | 299 |
298 // 11. If implementation in the configuration specified by the combination of | 300 // 11. If implementation in the configuration specified by the combination of |
299 // the values in accumulated configuration is not supported or not allowed | 301 // the values in accumulated configuration is not supported or not allowed |
300 // in the origin, return null. | 302 // in the origin, return null. |
301 di_requirement = | 303 di_requirement = |
302 ConvertRequirement(accumulated_configuration->distinctiveIdentifier); | 304 ConvertRequirement(accumulated_configuration->distinctiveIdentifier); |
303 if (!IsDistinctiveIdentifierRequirementSupported(key_system, di_requirement, | 305 if (!IsDistinctiveIdentifierRequirementSupported(key_system, di_requirement, |
304 is_permission_granted)) { | 306 is_permission_granted)) { |
305 DCHECK(!was_permission_requested); // Should have failed at step 3. | 307 if (was_permission_requested) { |
306 return CONFIGURATION_REQUIRES_PERMISSION; | 308 // The optional permission was requested and denied. |
| 309 // TODO(sandersd): Avoid the need for this logic - crbug.com/460616. |
| 310 DCHECK(candidate.distinctiveIdentifier == |
| 311 blink::WebMediaKeySystemConfiguration::Requirement::Optional); |
| 312 DCHECK(di_requirement == EME_FEATURE_REQUIRED); |
| 313 DCHECK(!is_permission_granted); |
| 314 accumulated_configuration->distinctiveIdentifier = |
| 315 blink::WebMediaKeySystemConfiguration::Requirement::NotAllowed; |
| 316 } else { |
| 317 return CONFIGURATION_REQUIRES_PERMISSION; |
| 318 } |
307 } | 319 } |
308 | 320 |
309 ps_requirement = | 321 ps_requirement = |
310 ConvertRequirement(accumulated_configuration->persistentState); | 322 ConvertRequirement(accumulated_configuration->persistentState); |
311 if (!IsPersistentStateRequirementSupported(key_system, ps_requirement, | 323 if (!IsPersistentStateRequirementSupported(key_system, ps_requirement, |
312 is_permission_granted)) { | 324 is_permission_granted)) { |
313 DCHECK(!was_permission_requested); // Should have failed at step 5. | 325 DCHECK(!was_permission_requested); // Should have failed at step 5. |
314 return CONFIGURATION_REQUIRES_PERMISSION; | 326 return CONFIGURATION_REQUIRES_PERMISSION; |
315 } | 327 } |
316 | 328 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 return reporter; | 510 return reporter; |
499 | 511 |
500 // Reporter not found, so create one. | 512 // Reporter not found, so create one. |
501 auto result = | 513 auto result = |
502 reporters_.add(uma_name, make_scoped_ptr(new Reporter(uma_name))); | 514 reporters_.add(uma_name, make_scoped_ptr(new Reporter(uma_name))); |
503 DCHECK(result.second); | 515 DCHECK(result.second); |
504 return result.first->second; | 516 return result.first->second; |
505 } | 517 } |
506 | 518 |
507 } // namespace media | 519 } // namespace media |
OLD | NEW |