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 "components/mime_util/mime_util.h" | 11 #include "components/mime_util/mime_util.h" |
12 #include "net/base/mime_util.h" | 12 #include "net/base/mime_util.h" |
13 #include "third_party/WebKit/public/platform/WebString.h" | 13 #include "third_party/WebKit/public/platform/WebString.h" |
14 | 14 |
15 using blink::WebString; | 15 using blink::WebString; |
16 using blink::WebMimeRegistry; | 16 using blink::WebMimeRegistry; |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 //static | 20 //static |
21 std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) { | 21 std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) { |
22 return base::IsStringASCII(string) ? base::UTF16ToASCII(string) | 22 return base::IsStringASCII(string) |
23 : std::string(); | 23 ? base::UTF16ToASCII(base::StringPiece16(string)) |
| 24 : std::string(); |
24 } | 25 } |
25 | 26 |
26 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType( | 27 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType( |
27 const WebString& mime_type) { | 28 const WebString& mime_type) { |
28 return mime_util::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) | 29 return mime_util::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) |
29 ? WebMimeRegistry::IsSupported | 30 ? WebMimeRegistry::IsSupported |
30 : WebMimeRegistry::IsNotSupported; | 31 : WebMimeRegistry::IsNotSupported; |
31 } | 32 } |
32 | 33 |
33 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType( | 34 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 101 |
101 WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile( | 102 WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile( |
102 const WebString& file_path) { | 103 const WebString& file_path) { |
103 std::string mime_type; | 104 std::string mime_type; |
104 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path), | 105 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path), |
105 &mime_type); | 106 &mime_type); |
106 return WebString::fromUTF8(mime_type); | 107 return WebString::fromUTF8(mime_type); |
107 } | 108 } |
108 | 109 |
109 } // namespace content | 110 } // namespace content |
OLD | NEW |