| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sky/engine/testing/platform/webmimeregistry_impl.h" | |
| 6 | |
| 7 #include "base/files/file_path.h" | |
| 8 #include "base/strings/string_util.h" | |
| 9 #include "base/strings/sys_string_conversions.h" | |
| 10 #include "base/strings/utf_string_conversions.h" | |
| 11 #include "net/base/mime_util.h" | |
| 12 #include "sky/engine/public/platform/WebString.h" | |
| 13 | |
| 14 namespace sky { | |
| 15 namespace { | |
| 16 | |
| 17 std::string ToASCIIOrEmpty(const blink::WebString& string) { | |
| 18 return base::IsStringASCII(string) ? base::UTF16ToASCII(string) | |
| 19 : std::string(); | |
| 20 } | |
| 21 | |
| 22 } // namespace | |
| 23 | |
| 24 blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsMIMEType( | |
| 25 const blink::WebString& mime_type) { | |
| 26 return net::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) ? | |
| 27 blink::WebMimeRegistry::IsSupported : | |
| 28 blink::WebMimeRegistry::IsNotSupported; | |
| 29 } | |
| 30 | |
| 31 blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsImageMIMEType( | |
| 32 const blink::WebString& mime_type) { | |
| 33 return net::IsSupportedImageMimeType(ToASCIIOrEmpty(mime_type)) ? | |
| 34 blink::WebMimeRegistry::IsSupported : | |
| 35 blink::WebMimeRegistry::IsNotSupported; | |
| 36 } | |
| 37 | |
| 38 blink::WebMimeRegistry::SupportsType | |
| 39 WebMimeRegistryImpl::supportsImagePrefixedMIMEType( | |
| 40 const blink::WebString& mime_type) { | |
| 41 std::string ascii_mime_type = ToASCIIOrEmpty(mime_type); | |
| 42 return (net::IsSupportedImageMimeType(ascii_mime_type) || | |
| 43 (StartsWithASCII(ascii_mime_type, "image/", true) && | |
| 44 net::IsSupportedNonImageMimeType(ascii_mime_type))) | |
| 45 ? WebMimeRegistry::IsSupported | |
| 46 : WebMimeRegistry::IsNotSupported; | |
| 47 } | |
| 48 | |
| 49 blink::WebMimeRegistry::SupportsType | |
| 50 WebMimeRegistryImpl::supportsJavaScriptMIMEType( | |
| 51 const blink::WebString& mime_type) { | |
| 52 return net::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) ? | |
| 53 blink::WebMimeRegistry::IsSupported : | |
| 54 blink::WebMimeRegistry::IsNotSupported; | |
| 55 } | |
| 56 | |
| 57 blink::WebMimeRegistry::SupportsType WebMimeRegistryImpl::supportsMediaMIMEType( | |
| 58 const blink::WebString& mime_type, | |
| 59 const blink::WebString& codecs, | |
| 60 const blink::WebString& key_system) { | |
| 61 NOTIMPLEMENTED(); | |
| 62 return IsNotSupported; | |
| 63 } | |
| 64 | |
| 65 blink::WebMimeRegistry::SupportsType | |
| 66 WebMimeRegistryImpl::supportsNonImageMIMEType( | |
| 67 const blink::WebString& mime_type) { | |
| 68 return net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) ? | |
| 69 blink::WebMimeRegistry::IsSupported : | |
| 70 blink::WebMimeRegistry::IsNotSupported; | |
| 71 } | |
| 72 | |
| 73 blink::WebString WebMimeRegistryImpl::mimeTypeForExtension( | |
| 74 const blink::WebString& file_extension) { | |
| 75 NOTIMPLEMENTED(); | |
| 76 return blink::WebString(); | |
| 77 } | |
| 78 | |
| 79 blink::WebString WebMimeRegistryImpl::wellKnownMimeTypeForExtension( | |
| 80 const blink::WebString& file_extension) { | |
| 81 NOTIMPLEMENTED(); | |
| 82 return blink::WebString(); | |
| 83 } | |
| 84 | |
| 85 blink::WebString WebMimeRegistryImpl::mimeTypeFromFile( | |
| 86 const blink::WebString& file_path) { | |
| 87 NOTIMPLEMENTED(); | |
| 88 return blink::WebString(); | |
| 89 } | |
| 90 | |
| 91 } // namespace sky | |
| OLD | NEW |