OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/child/simple_webmimeregistry_impl.h" | 5 #include "content/child/simple_webmimeregistry_impl.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "content/common/mime_util.h" |
11 #include "net/base/mime_util.h" | 12 #include "net/base/mime_util.h" |
12 #include "third_party/WebKit/public/platform/WebString.h" | 13 #include "third_party/WebKit/public/platform/WebString.h" |
13 | 14 |
14 using blink::WebString; | 15 using blink::WebString; |
15 using blink::WebMimeRegistry; | 16 using blink::WebMimeRegistry; |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 //static | 20 //static |
20 std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) { | 21 std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) { |
21 return base::IsStringASCII(string) ? base::UTF16ToASCII(string) | 22 return base::IsStringASCII(string) ? base::UTF16ToASCII(string) |
22 : std::string(); | 23 : std::string(); |
23 } | 24 } |
24 | 25 |
25 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType( | 26 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType( |
26 const WebString& mime_type) { | 27 const WebString& mime_type) { |
27 return net::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) ? | 28 return content::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) ? |
28 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; | 29 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; |
29 } | 30 } |
30 | 31 |
31 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType( | 32 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType( |
32 const WebString& mime_type) { | 33 const WebString& mime_type) { |
33 return net::IsSupportedImageMimeType(ToASCIIOrEmpty(mime_type)) ? | 34 return net::IsSupportedImageMimeType(ToASCIIOrEmpty(mime_type)) ? |
34 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; | 35 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; |
35 } | 36 } |
36 | 37 |
37 WebMimeRegistry::SupportsType | 38 WebMimeRegistry::SupportsType |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 94 |
94 WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile( | 95 WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile( |
95 const WebString& file_path) { | 96 const WebString& file_path) { |
96 std::string mime_type; | 97 std::string mime_type; |
97 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path), | 98 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path), |
98 &mime_type); | 99 &mime_type); |
99 return WebString::fromUTF8(mime_type); | 100 return WebString::fromUTF8(mime_type); |
100 } | 101 } |
101 | 102 |
102 } // namespace content | 103 } // namespace content |
OLD | NEW |