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
3 // found in the LICENSE file.
5 #include "mojo/services/html_viewer/webmimeregistry_impl.h"
7 #include "base/files/file_path.h"
8 #include "base/strings/string_util.h"
9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "net/base/mime_util.h"
12 #include "third_party/WebKit/public/platform/WebString.h"
17 std::string ToASCIIOrEmpty(const blink::WebString& string) {
18 return base::IsStringASCII(string) ? base::UTF16ToASCII(string)
24 blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsMIMEType(
25 const blink::WebString& mime_type) {
26 return net::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) ?
27 blink::WebMimeRegistry::IsSupported :
28 blink::WebMimeRegistry::IsNotSupported;
31 blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsImageMIMEType(
32 const blink::WebString& mime_type) {
33 return net::IsSupportedImageMimeType(ToASCIIOrEmpty(mime_type)) ?
34 blink::WebMimeRegistry::IsSupported :
35 blink::WebMimeRegistry::IsNotSupported;
38 blink::WebMimeRegistry::SupportsType
39 WebMimeRegistryImpl::supportsJavaScriptMIMEType(
40 const blink::WebString& mime_type) {
41 return net::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) ?
42 blink::WebMimeRegistry::IsSupported :
43 blink::WebMimeRegistry::IsNotSupported;
46 blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsMediaMIMEType(
47 const blink::WebString& mime_type,
48 const blink::WebString& codecs,
49 const blink::WebString& key_system) {
51 return IsNotSupported;
54 bool WebMimeRegistryImpl::supportsMediaSourceMIMEType(
55 const blink::WebString& mime_type,
56 const blink::WebString& codecs) {
61 bool WebMimeRegistryImpl::supportsEncryptedMediaMIMEType(
62 const blink::WebString& key_system,
63 const blink::WebString& mime_type,
64 const blink::WebString& codecs) {
69 blink::WebMimeRegistry::SupportsType
70 WebMimeRegistryImpl::supportsNonImageMIMEType(
71 const blink::WebString& mime_type) {
72 return net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) ?
73 blink::WebMimeRegistry::IsSupported :
74 blink::WebMimeRegistry::IsNotSupported;
77 blink::WebString WebMimeRegistryImpl::mimeTypeForExtension(
78 const blink::WebString& file_extension) {
80 return blink::WebString();
83 blink::WebString WebMimeRegistryImpl::wellKnownMimeTypeForExtension(
84 const blink::WebString& file_extension) {
86 return blink::WebString();
89 blink::WebString WebMimeRegistryImpl::mimeTypeFromFile(
90 const blink::WebString& file_path) {
92 return blink::WebString();