Implemented rest of webkit api/glue code needed for HTML5 media canPlayType().

BUG=16636
TEST=we should respect the codecs= parameter when provided as a media mime type

Review URL: http://codereview.chromium.org/160073


git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21607 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/webkit/glue/simple_webmimeregistry_impl.cc b/webkit/glue/simple_webmimeregistry_impl.cc
index 95c39a1..29296ff1 100644
--- a/webkit/glue/simple_webmimeregistry_impl.cc
+++ b/webkit/glue/simple_webmimeregistry_impl.cc
@@ -12,27 +12,45 @@
 #include "webkit/glue/webkit_glue.h"
 
 using WebKit::WebString;
+using WebKit::WebMimeRegistry;
 
 namespace webkit_glue {
 
-bool SimpleWebMimeRegistryImpl::supportsImageMIMEType(
+WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType(
     const WebString& mime_type) {
-  return net::IsSupportedImageMimeType(UTF16ToASCII(mime_type).c_str());
+  if (!net::IsSupportedImageMimeType(UTF16ToASCII(mime_type).c_str()))
+    return WebMimeRegistry::IsNotSupported;
+  return WebMimeRegistry::IsSupported;
 }
 
-bool SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType(
+WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType(
     const WebString& mime_type) {
-  return net::IsSupportedJavascriptMimeType(UTF16ToASCII(mime_type).c_str());
+  if (!net::IsSupportedJavascriptMimeType(UTF16ToASCII(mime_type).c_str()))
+    return WebMimeRegistry::IsNotSupported;
+  return WebMimeRegistry::IsSupported;
 }
 
-bool SimpleWebMimeRegistryImpl::supportsMediaMIMEType(
-    const WebString& mime_type) {
-  return net::IsSupportedMediaMimeType(UTF16ToASCII(mime_type).c_str());
+WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType(
+    const WebString& mime_type, const WebString& codecs) {
+  // Not supporting the container is a flat-out no.
+  if (!net::IsSupportedMediaMimeType(UTF16ToASCII(mime_type).c_str()))
+    return IsNotSupported;
+
+  // If we don't recognize the codec, it's possible we support it.
+  std::vector<std::string> parsed_codecs;
+  net::ParseCodecString(UTF16ToASCII(codecs).c_str(), &parsed_codecs);
+  if (!net::AreSupportedMediaCodecs(parsed_codecs))
+    return MayBeSupported;
+
+  // Otherwise we have a perfect match.
+  return IsSupported;
 }
 
-bool SimpleWebMimeRegistryImpl::supportsNonImageMIMEType(
+WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsNonImageMIMEType(
     const WebString& mime_type) {
-  return net::IsSupportedNonImageMimeType(UTF16ToASCII(mime_type).c_str());
+  if (!net::IsSupportedNonImageMimeType(UTF16ToASCII(mime_type).c_str()))
+    return WebMimeRegistry::IsNotSupported;
+  return WebMimeRegistry::IsSupported;
 }
 
 WebString SimpleWebMimeRegistryImpl::mimeTypeForExtension(