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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; | 28 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; |
29 } | 29 } |
30 | 30 |
31 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType( | 31 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType( |
32 const WebString& mime_type) { | 32 const WebString& mime_type) { |
33 return net::IsSupportedImageMimeType(ToASCIIOrEmpty(mime_type)) ? | 33 return net::IsSupportedImageMimeType(ToASCIIOrEmpty(mime_type)) ? |
34 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; | 34 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; |
35 } | 35 } |
36 | 36 |
37 WebMimeRegistry::SupportsType | 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; |
| 45 } |
| 46 |
| 47 WebMimeRegistry::SupportsType |
38 SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType( | 48 SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType( |
39 const WebString& mime_type) { | 49 const WebString& mime_type) { |
40 return net::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) ? | 50 return net::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) ? |
41 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; | 51 WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported; |
42 } | 52 } |
43 | 53 |
44 // When debugging layout tests failures in the test shell, | 54 // When debugging layout tests failures in the test shell, |
45 // see TestShellWebMimeRegistryImpl. | 55 // see TestShellWebMimeRegistryImpl. |
46 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType( | 56 WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType( |
47 const WebString& mime_type, | 57 const WebString& mime_type, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 101 |
92 WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile( | 102 WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile( |
93 const WebString& file_path) { | 103 const WebString& file_path) { |
94 std::string mime_type; | 104 std::string mime_type; |
95 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path), | 105 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path), |
96 &mime_type); | 106 &mime_type); |
97 return WebString::fromUTF8(mime_type); | 107 return WebString::fromUTF8(mime_type); |
98 } | 108 } |
99 | 109 |
100 } // namespace content | 110 } // namespace content |
OLD | NEW |