Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / mojo / services / html_viewer / webmimeregistry_impl.cc
index 73a97ac..2faac17 100644 (file)
@@ -36,6 +36,17 @@ blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsImageMIMEType(
 }
 
 blink::WebMimeRegistry::SupportsType
+WebMimeRegistryImpl::supportsImagePrefixedMIMEType(
+    const blink::WebString& mime_type) {
+  std::string ascii_mime_type = ToASCIIOrEmpty(mime_type);
+  return (net::IsSupportedImageMimeType(ascii_mime_type) ||
+          (StartsWithASCII(ascii_mime_type, "image/", true) &&
+           net::IsSupportedNonImageMimeType(ascii_mime_type)))
+             ? WebMimeRegistry::IsSupported
+             : WebMimeRegistry::IsNotSupported;
+}
+
+blink::WebMimeRegistry::SupportsType
     WebMimeRegistryImpl::supportsJavaScriptMIMEType(
     const blink::WebString& mime_type) {
   return net::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) ?
@@ -47,8 +58,32 @@ blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsMediaMIMEType(
     const blink::WebString& mime_type,
     const blink::WebString& codecs,
     const blink::WebString& key_system) {
-  NOTIMPLEMENTED();
-  return IsNotSupported;
+  const std::string mime_type_ascii = ToASCIIOrEmpty(mime_type);
+  // Not supporting the container is a flat-out no.
+  if (!net::IsSupportedMediaMimeType(mime_type_ascii))
+    return IsNotSupported;
+
+  // Mojo does not currently support any key systems.
+  if (!key_system.isEmpty())
+    return IsNotSupported;
+
+  // Check list of strict codecs to see if it is supported.
+  if (net::IsStrictMediaMimeType(mime_type_ascii)) {
+    // Check if the codecs are a perfect match.
+    std::vector<std::string> strict_codecs;
+    net::ParseCodecString(ToASCIIOrEmpty(codecs), &strict_codecs, false);
+    return static_cast<WebMimeRegistry::SupportsType>(
+        net::IsSupportedStrictMediaMimeType(mime_type_ascii, strict_codecs));
+  }
+
+  // If we don't recognize the codec, it's possible we support it.
+  std::vector<std::string> parsed_codecs;
+  net::ParseCodecString(ToASCIIOrEmpty(codecs), &parsed_codecs, true);
+  if (!net::AreSupportedMediaCodecs(parsed_codecs))
+    return MayBeSupported;
+
+  // Otherwise we have a perfect match.
+  return IsSupported;
 }
 
 bool WebMimeRegistryImpl::supportsMediaSourceMIMEType(