Index: content/renderer/media/webcontentdecryptionmodule_impl.cc |
diff --git a/content/renderer/media/webcontentdecryptionmodule_impl.cc b/content/renderer/media/webcontentdecryptionmodule_impl.cc |
index 9dcb39ee9ca98931c5f49c05035f805ed883e846..6ba5cc0c9e3ab0564368a8c7e8af3f74f2a1477f 100644 |
--- a/content/renderer/media/webcontentdecryptionmodule_impl.cc |
+++ b/content/renderer/media/webcontentdecryptionmodule_impl.cc |
@@ -16,6 +16,7 @@ |
#include "content/renderer/media/crypto/key_systems.h" |
#include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" |
#include "media/base/media_keys.h" |
+#include "net/base/mime_util.h" |
#include "third_party/WebKit/public/platform/WebString.h" |
#include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
#include "url/gurl.h" |
@@ -76,6 +77,108 @@ WebContentDecryptionModuleImpl* WebContentDecryptionModuleImpl::Create( |
return new WebContentDecryptionModuleImpl(adapter); |
} |
+// static |
+blink::WebContentDecryptionModule::KeySystemSupportedResult |
+WebContentDecryptionModuleImpl::IsKeySystemSupported( |
+ const blink::WebString& key_system, |
+ const blink::WebString& init_data_type, |
+ const blink::WebString& container, |
+ const blink::WebString& codecs, |
+ const blink::WebString& capability) { |
+ // Continuation (from Blink) of MediaKeys.isTypeSupported() algorithm. |
+ |
+ // 1. If keySystem is an empty string or contains an unrecognized or |
+ // unsupported Key System, return the empty string and abort these steps. |
+ // String comparison is case-sensitive. |
+ // 2. If the keySystem implementation is not available and usable, return the |
+ // empty string and abort these steps. |
+ // (Emptiness check is in Blink.) |
+ // TODO(sandersd): Implement ASCII checks on Blink side. |
+ const std::string key_system_ascii = key_system.utf8(); |
+ if (!IsSupportedKeySystem(key_system_ascii)) |
+ return blink::WebContentDecryptionModule::NotSupported; |
+ |
+ // 3. Follow the steps for the first matching condition from the following |
+ // list: |
+ // - If keySystem is a value that may be successfully passed to create() |
+ // Let probably result be "probably" |
+ // - Otherwise (as may be the case for strings that are only used for |
+ // discovery) |
+ // Let probably result be "maybe". |
+ blink::WebContentDecryptionModule::KeySystemSupportedResult probably_result = |
+ (IsConcreteSupportedKeySystem(key_system_ascii) ? |
ddorwin
2014/09/23 22:48:18
nit: () is not strictly necessary.
sandersd (OOO until July 31)
2014/09/24 22:22:34
Done.
|
+ blink::WebContentDecryptionModule::ProbablySupported : |
ddorwin
2014/09/23 22:48:17
nit: I'm not sure what the style guide says or for
sandersd (OOO until July 31)
2014/09/24 22:22:34
Done.
|
+ blink::WebContentDecryptionModule::MaybeSupported); |
+ |
+ // 4. If initDataType was not provided, follow the steps for the first |
+ // matching condition from the following list and abort these steps: |
+ // - If the user agent is not confident that the keySystem implementation |
+ // is available and usable |
+ // Return "maybe" |
+ // - Otherwise |
+ // Return probably result. |
+ if (init_data_type.isEmpty()) |
+ return probably_result; |
+ |
+ // 5. If initDataType is an empty string or contains an unrecognized or |
+ // unsupported initialization data type, return the empty string and abort |
+ // these steps. String comparison is case-sensitive. |
+ // 6. If initDataType is not an initialization data type supported by the |
+ // keySystem implementation, return the empty string and abort these steps. |
+ // 7. If the keySystem implementation supporting initDataType is not available |
+ // and usable, return the empty string and abort these steps. |
+ // (Emptiness check is in Blink.) |
+ const std::string init_data_type_ascii = init_data_type.utf8(); |
+ if (!IsSupportedKeySystemWithInitDataType(key_system_ascii, |
+ init_data_type_ascii)) |
+ return blink::WebContentDecryptionModule::NotSupported; |
+ |
+ // 8. If contentType was not provided, follow the steps for the first matching |
+ // condition from the following list and abort these steps: |
+ // - If the user agent is not confident that the keySystem implementation |
+ // supporting initDataType is available and usable |
+ // Return "maybe" |
+ // - Otherwise |
+ // Return probably result. |
+ if (container.isEmpty()) |
+ return probably_result; |
+ |
+ // 9. If contentType is an empty string or contains an invalid or |
+ // unrecognized MIME type, return the empty string and abort these steps. |
+ // 10. Let container be the container type specified by contentType. |
+ // 11. Let parameters be the RFC 6381 parameters, if any, specified by |
+ // contentType. |
+ // 12. Let media types be the set of media types specified by parameters. It |
+ // may be empty. The case-sensitivity of string comparisons is determined |
+ // by the appropriate RFC or other specification. |
+ // 13. If the user agent does not support container, return the empty string |
+ // and abort these steps. The case-sensitivity of string comparisons is |
+ // determined by the appropriate RFC. |
+ // 14. If the user agent and keySystem implementation do not support playback |
+ // of encrypted media data for all media types, return the empty string |
+ // and abort these steps. |
+ // (Emptiness check is in Blink.) |
+ const std::string container_ascii = container.utf8(); |
+ if (!IsSaneInitDataTypeWithContainer(init_data_type_ascii, container_ascii)) |
+ return blink::WebContentDecryptionModule::NotSupported; |
+ |
+ bool strip_codec_suffixes = !net::IsStrictMediaMimeType(container_ascii); |
ddorwin
2014/09/23 22:48:17
http://crbug.com/374751 also affects this line, so
sandersd (OOO until July 31)
2014/09/24 22:22:34
Done.
|
+ std::vector<std::string> codec_vector; |
+ net::ParseCodecString(codecs.utf8(), &codec_vector, strip_codec_suffixes); |
+ if (!IsSupportedKeySystemWithMediaMimeType( |
+ container_ascii, codec_vector, key_system_ascii)) |
+ return blink::WebContentDecryptionModule::NotSupported; |
+ |
+ // 15-18. (Capabilities.) |
+ // TODO(sandersd): Support capabilities. |
+ if (!capability.isEmpty()) |
+ return blink::WebContentDecryptionModule::NotSupported; |
+ |
+ // TODO(sandersd): If the codecs are all unambiguous and supported, return |
+ // |probably_result|. http://crbug.com/374751 |
+ return blink::WebContentDecryptionModule::MaybeSupported; |
+} |
+ |
WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( |
scoped_refptr<CdmSessionAdapter> adapter) |
: adapter_(adapter) {} |