| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/base/key_systems.h" | 5 #include "media/base/key_systems.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 const std::vector<KeySystemInfo>& concrete_key_systems) { | 388 const std::vector<KeySystemInfo>& concrete_key_systems) { |
| 389 DCHECK(thread_checker_.CalledOnValidThread()); | 389 DCHECK(thread_checker_.CalledOnValidThread()); |
| 390 DCHECK(concrete_key_system_map_.empty()); | 390 DCHECK(concrete_key_system_map_.empty()); |
| 391 DCHECK(parent_key_system_map_.empty()); | 391 DCHECK(parent_key_system_map_.empty()); |
| 392 | 392 |
| 393 for (const KeySystemInfo& info : concrete_key_systems) { | 393 for (const KeySystemInfo& info : concrete_key_systems) { |
| 394 DCHECK(!info.key_system.empty()); | 394 DCHECK(!info.key_system.empty()); |
| 395 DCHECK_NE(info.persistent_license_support, EME_SESSION_TYPE_INVALID); | 395 DCHECK_NE(info.persistent_license_support, EME_SESSION_TYPE_INVALID); |
| 396 DCHECK_NE(info.persistent_release_message_support, | 396 DCHECK_NE(info.persistent_release_message_support, |
| 397 EME_SESSION_TYPE_INVALID); | 397 EME_SESSION_TYPE_INVALID); |
| 398 // REQUESTABLE and REQUESTABLE_WITH_PERMISSION are not available until we | 398 // TODO(sandersd): Add REQUESTABLE and REQUESTABLE_WITH_PERMISSION for |
| 399 // can block access/ per-CDM-instance. http://crbug.com/457482 | 399 // persistent_state_support once we can block access per-CDM-instance |
| 400 // Note: Even once that is fixed, distinctive identifiers should never be | 400 // (http://crbug.com/457482). |
| 401 // REQUESTABLE, since user permission is always required. | |
| 402 DCHECK(info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED || | 401 DCHECK(info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED || |
| 403 info.persistent_state_support == EME_FEATURE_ALWAYS_ENABLED); | 402 info.persistent_state_support == EME_FEATURE_ALWAYS_ENABLED); |
| 403 // TODO(sandersd): Allow REQUESTABLE_WITH_PERMISSION for all key systems on |
| 404 // all platforms once we have proper enforcement (http://crbug.com/457482). |
| 405 // On Chrome OS, an ID will not be used without permission, but we cannot |
| 406 // currently prevent the CDM from requesting the permission again when no |
| 407 // there was no initial prompt. Thus, we block "not-allowed" below. |
| 408 #if defined(OS_CHROMEOS) |
| 409 DCHECK(info.distinctive_identifier_support == EME_FEATURE_NOT_SUPPORTED || |
| 410 (info.distinctive_identifier_support == |
| 411 EME_FEATURE_REQUESTABLE_WITH_PERMISSION && |
| 412 info.key_system == kWidevineKeySystem) || |
| 413 info.distinctive_identifier_support == EME_FEATURE_ALWAYS_ENABLED); |
| 414 #else |
| 404 DCHECK(info.distinctive_identifier_support == EME_FEATURE_NOT_SUPPORTED || | 415 DCHECK(info.distinctive_identifier_support == EME_FEATURE_NOT_SUPPORTED || |
| 405 info.distinctive_identifier_support == EME_FEATURE_ALWAYS_ENABLED); | 416 info.distinctive_identifier_support == EME_FEATURE_ALWAYS_ENABLED); |
| 417 #endif |
| 406 if (info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED) { | 418 if (info.persistent_state_support == EME_FEATURE_NOT_SUPPORTED) { |
| 407 DCHECK_EQ(info.persistent_license_support, | 419 DCHECK_EQ(info.persistent_license_support, |
| 408 EME_SESSION_TYPE_NOT_SUPPORTED); | 420 EME_SESSION_TYPE_NOT_SUPPORTED); |
| 409 DCHECK_EQ(info.persistent_release_message_support, | 421 DCHECK_EQ(info.persistent_release_message_support, |
| 410 EME_SESSION_TYPE_NOT_SUPPORTED); | 422 EME_SESSION_TYPE_NOT_SUPPORTED); |
| 411 } | 423 } |
| 412 DCHECK(!IsSupportedKeySystem(info.key_system)) | 424 DCHECK(!IsSupportedKeySystem(info.key_system)) |
| 413 << "Key system '" << info.key_system << "' already registered"; | 425 << "Key system '" << info.key_system << "' already registered"; |
| 414 DCHECK(!parent_key_system_map_.count(info.key_system)) | 426 DCHECK(!parent_key_system_map_.count(info.key_system)) |
| 415 << "'" << info.key_system << "' is already registered as a parent"; | 427 << "'" << info.key_system << "' is already registered as a parent"; |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 return false; | 720 return false; |
| 709 } | 721 } |
| 710 | 722 |
| 711 switch (key_system_iter->second.distinctive_identifier_support) { | 723 switch (key_system_iter->second.distinctive_identifier_support) { |
| 712 case EME_FEATURE_INVALID: | 724 case EME_FEATURE_INVALID: |
| 713 NOTREACHED(); | 725 NOTREACHED(); |
| 714 return false; | 726 return false; |
| 715 case EME_FEATURE_NOT_SUPPORTED: | 727 case EME_FEATURE_NOT_SUPPORTED: |
| 716 return requirement != EME_FEATURE_REQUIRED; | 728 return requirement != EME_FEATURE_REQUIRED; |
| 717 case EME_FEATURE_REQUESTABLE_WITH_PERMISSION: | 729 case EME_FEATURE_REQUESTABLE_WITH_PERMISSION: |
| 730 // TODO(sandersd): Remove this hack once crbug.com/457482 and |
| 731 // crbug.com/460616 are addressed. |
| 732 // We cannot currently enforce "not-allowed", so don't allow it. |
| 733 // Note: Removing this check will expose crbug.com/460616. |
| 734 if (requirement == EME_FEATURE_NOT_ALLOWED) |
| 735 return false; |
| 718 return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted; | 736 return (requirement != EME_FEATURE_REQUIRED) || is_permission_granted; |
| 719 case EME_FEATURE_REQUESTABLE: | 737 case EME_FEATURE_REQUESTABLE: |
| 720 NOTREACHED(); | 738 NOTREACHED(); |
| 721 return true; | 739 return true; |
| 722 case EME_FEATURE_ALWAYS_ENABLED: | 740 case EME_FEATURE_ALWAYS_ENABLED: |
| 723 // Distinctive identifiers always require user permission. | 741 // Distinctive identifiers always require user permission. |
| 724 return (requirement != EME_FEATURE_NOT_ALLOWED) && is_permission_granted; | 742 return (requirement != EME_FEATURE_NOT_ALLOWED) && is_permission_granted; |
| 725 } | 743 } |
| 726 | 744 |
| 727 NOTREACHED(); | 745 NOTREACHED(); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 | 886 |
| 869 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { | 887 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask) { |
| 870 KeySystems::GetInstance().AddContainerMask(container, mask); | 888 KeySystems::GetInstance().AddContainerMask(container, mask); |
| 871 } | 889 } |
| 872 | 890 |
| 873 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { | 891 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask) { |
| 874 KeySystems::GetInstance().AddCodecMask(codec, mask); | 892 KeySystems::GetInstance().AddCodecMask(codec, mask); |
| 875 } | 893 } |
| 876 | 894 |
| 877 } // namespace media | 895 } // namespace media |
| OLD | NEW |