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 "net/base/mime_util.h" | 11 #include "net/base/mime_util.h" |
12 #include "third_party/WebKit/public/platform/WebString.h" | 12 #include "third_party/WebKit/public/platform/WebString.h" |
13 | 13 |
14 using blink::WebString; | 14 using blink::WebString; |
15 using blink::WebMimeRegistry; | 15 using blink::WebMimeRegistry; |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 //static | 19 //static |
20 std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) { | 20 std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) { |
21 return base::IsStringASCII(string) ? base::UTF16ToASCII(string) | 21 return IsStringASCII(string) ? base::UTF16ToASCII(string) : std::string(); |
22 : std::string(); | |
23 } | 22 } |
24 | 23 |
25 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType( | 24 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType( |
26 const WebString& mime_type) { | 25 const WebString& mime_type) { |
27 return net::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) ? | 26 return net::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) ? |
28 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; | 27 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; |
29 } | 28 } |
30 | 29 |
31 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType( | 30 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType( |
32 const WebString& mime_type) { | 31 const WebString& mime_type) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 90 |
92 WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile( | 91 WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile( |
93 const WebString& file_path) { | 92 const WebString& file_path) { |
94 std::string mime_type; | 93 std::string mime_type; |
95 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path), | 94 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path), |
96 &mime_type); | 95 &mime_type); |
97 return WebString::fromUTF8(mime_type); | 96 return WebString::fromUTF8(mime_type); |
98 } | 97 } |
99 | 98 |
100 } // namespace content | 99 } // namespace content |
OLD | NEW |