Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / mojo / services / html_viewer / webmimeregistry_impl.cc
blobedaed24e39e9cdfb0161e7a34e4aaec720ff2bf0
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"
14 namespace mojo {
15 namespace {
17 std::string ToASCIIOrEmpty(const blink::WebString& string) {
18 return base::IsStringASCII(string) ? base::UTF16ToASCII(string)
19 : std::string();
22 } // namespace
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::supportsImagePrefixedMIMEType(
40 const blink::WebString& mime_type) {
41 std::string ascii_mime_type = ToASCIIOrEmpty(mime_type);
42 return (net::IsSupportedImageMimeType(ascii_mime_type) ||
43 (StartsWithASCII(ascii_mime_type, "image/", true) &&
44 net::IsSupportedNonImageMimeType(ascii_mime_type)))
45 ? WebMimeRegistry::IsSupported
46 : WebMimeRegistry::IsNotSupported;
49 blink::WebMimeRegistry::SupportsType
50 WebMimeRegistryImpl::supportsJavaScriptMIMEType(
51 const blink::WebString& mime_type) {
52 return net::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) ?
53 blink::WebMimeRegistry::IsSupported :
54 blink::WebMimeRegistry::IsNotSupported;
57 blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsMediaMIMEType(
58 const blink::WebString& mime_type,
59 const blink::WebString& codecs,
60 const blink::WebString& key_system) {
61 NOTIMPLEMENTED();
62 return IsNotSupported;
65 bool WebMimeRegistryImpl::supportsMediaSourceMIMEType(
66 const blink::WebString& mime_type,
67 const blink::WebString& codecs) {
68 NOTIMPLEMENTED();
69 return false;
72 bool WebMimeRegistryImpl::supportsEncryptedMediaMIMEType(
73 const blink::WebString& key_system,
74 const blink::WebString& mime_type,
75 const blink::WebString& codecs) {
76 NOTIMPLEMENTED();
77 return false;
80 blink::WebMimeRegistry::SupportsType
81 WebMimeRegistryImpl::supportsNonImageMIMEType(
82 const blink::WebString& mime_type) {
83 return net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) ?
84 blink::WebMimeRegistry::IsSupported :
85 blink::WebMimeRegistry::IsNotSupported;
88 blink::WebString WebMimeRegistryImpl::mimeTypeForExtension(
89 const blink::WebString& file_extension) {
90 NOTIMPLEMENTED();
91 return blink::WebString();
94 blink::WebString WebMimeRegistryImpl::wellKnownMimeTypeForExtension(
95 const blink::WebString& file_extension) {
96 NOTIMPLEMENTED();
97 return blink::WebString();
100 blink::WebString WebMimeRegistryImpl::mimeTypeFromFile(
101 const blink::WebString& file_path) {
102 NOTIMPLEMENTED();
103 return blink::WebString();
106 } // namespace mojo