| 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 "components/html_viewer/web_mime_registry_impl.h" | 5 #include "components/html_viewer/web_mime_registry_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 26 matching lines...) Expand all Loading... |
| 37 return mime_util::IsSupportedImageMimeType(ToASCIIOrEmpty(mime_type)) | 37 return mime_util::IsSupportedImageMimeType(ToASCIIOrEmpty(mime_type)) |
| 38 ? blink::WebMimeRegistry::IsSupported | 38 ? blink::WebMimeRegistry::IsSupported |
| 39 : blink::WebMimeRegistry::IsNotSupported; | 39 : blink::WebMimeRegistry::IsNotSupported; |
| 40 } | 40 } |
| 41 | 41 |
| 42 blink::WebMimeRegistry::SupportsType | 42 blink::WebMimeRegistry::SupportsType |
| 43 WebMimeRegistryImpl::supportsImagePrefixedMIMEType( | 43 WebMimeRegistryImpl::supportsImagePrefixedMIMEType( |
| 44 const blink::WebString& mime_type) { | 44 const blink::WebString& mime_type) { |
| 45 std::string ascii_mime_type = ToASCIIOrEmpty(mime_type); | 45 std::string ascii_mime_type = ToASCIIOrEmpty(mime_type); |
| 46 return (mime_util::IsSupportedImageMimeType(ascii_mime_type) || | 46 return (mime_util::IsSupportedImageMimeType(ascii_mime_type) || |
| 47 (base::StartsWithASCII(ascii_mime_type, "image/", true) && | 47 (base::StartsWith(ascii_mime_type, "image/", |
| 48 base::CompareCase::SENSITIVE) && |
| 48 mime_util::IsSupportedNonImageMimeType(ascii_mime_type))) | 49 mime_util::IsSupportedNonImageMimeType(ascii_mime_type))) |
| 49 ? WebMimeRegistry::IsSupported | 50 ? WebMimeRegistry::IsSupported |
| 50 : WebMimeRegistry::IsNotSupported; | 51 : WebMimeRegistry::IsNotSupported; |
| 51 } | 52 } |
| 52 | 53 |
| 53 blink::WebMimeRegistry::SupportsType | 54 blink::WebMimeRegistry::SupportsType |
| 54 WebMimeRegistryImpl::supportsJavaScriptMIMEType( | 55 WebMimeRegistryImpl::supportsJavaScriptMIMEType( |
| 55 const blink::WebString& mime_type) { | 56 const blink::WebString& mime_type) { |
| 56 return mime_util::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) | 57 return mime_util::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) |
| 57 ? blink::WebMimeRegistry::IsSupported | 58 ? blink::WebMimeRegistry::IsSupported |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 130 |
| 130 blink::WebString WebMimeRegistryImpl::mimeTypeFromFile( | 131 blink::WebString WebMimeRegistryImpl::mimeTypeFromFile( |
| 131 const blink::WebString& file_path) { | 132 const blink::WebString& file_path) { |
| 132 std::string mime_type; | 133 std::string mime_type; |
| 133 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path), | 134 net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path), |
| 134 &mime_type); | 135 &mime_type); |
| 135 return blink::WebString::fromUTF8(mime_type); | 136 return blink::WebString::fromUTF8(mime_type); |
| 136 } | 137 } |
| 137 | 138 |
| 138 } // namespace html_viewer | 139 } // namespace html_viewer |
| OLD | NEW |