Removing uses of X11 native key events.
[chromium-blink-merge.git] / content / child / simple_webmimeregistry_impl.cc
blob510b25b73411985772c5e30b77e9c19c13d87155
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 "content/child/simple_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 using blink::WebString;
15 using blink::WebMimeRegistry;
17 namespace content {
19 //static
20 std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) {
21 return base::IsStringASCII(string) ? base::UTF16ToASCII(string)
22 : std::string();
25 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType(
26 const WebString& mime_type) {
27 return net::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) ?
28 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
31 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType(
32 const WebString& mime_type) {
33 return net::IsSupportedImageMimeType(ToASCIIOrEmpty(mime_type)) ?
34 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
37 WebMimeRegistry::SupportsType
38 SimpleWebMimeRegistryImpl::supportsImagePrefixedMIMEType(
39 const WebString& mime_type) {
40 std::string ascii_mime_type = ToASCIIOrEmpty(mime_type);
41 return (net::IsSupportedImageMimeType(ascii_mime_type) ||
42 (StartsWithASCII(ascii_mime_type, "image/", true) &&
43 net::IsSupportedNonImageMimeType(ascii_mime_type))) ?
44 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
47 WebMimeRegistry::SupportsType
48 SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType(
49 const WebString& mime_type) {
50 return net::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) ?
51 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
54 // When debugging layout tests failures in the test shell,
55 // see TestShellWebMimeRegistryImpl.
56 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType(
57 const WebString& mime_type,
58 const WebString& codecs,
59 const WebString& key_system) {
60 // Media features are only supported at the content/renderer/ layer.
61 return IsNotSupported;
64 bool SimpleWebMimeRegistryImpl::supportsMediaSourceMIMEType(
65 const WebString& mime_type,
66 const WebString& codecs) {
67 // Media features are only supported at the content/renderer layer.
68 return false;
71 bool SimpleWebMimeRegistryImpl::supportsEncryptedMediaMIMEType(
72 const blink::WebString& key_system,
73 const blink::WebString& mime_type,
74 const blink::WebString& codecs) {
75 // Media features are only supported at the content/renderer layer.
76 return false;
79 WebMimeRegistry::SupportsType
80 SimpleWebMimeRegistryImpl::supportsNonImageMIMEType(
81 const WebString& mime_type) {
82 return net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) ?
83 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
86 WebString SimpleWebMimeRegistryImpl::mimeTypeForExtension(
87 const WebString& file_extension) {
88 std::string mime_type;
89 net::GetMimeTypeFromExtension(
90 base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type);
91 return WebString::fromUTF8(mime_type);
94 WebString SimpleWebMimeRegistryImpl::wellKnownMimeTypeForExtension(
95 const WebString& file_extension) {
96 std::string mime_type;
97 net::GetWellKnownMimeTypeFromExtension(
98 base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type);
99 return WebString::fromUTF8(mime_type);
102 WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile(
103 const WebString& file_path) {
104 std::string mime_type;
105 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path),
106 &mime_type);
107 return WebString::fromUTF8(mime_type);
110 } // namespace content