Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: content/child/simple_webmimeregistry_impl.cc

Issue 471913002: Added a method to detect all supported "image/*" MIME types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a test for SimpleWebMimeRegistryImpl. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 || (ascii_mime_type.substr(0, 6) == "image/"
jam 2014/08/25 18:01:15 nit: put the '||' in the previous line also use S
43 && net::IsSupportedNonImageMimeType(ascii_mime_type))) ?
jam 2014/08/25 18:01:15 && in previous line
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
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
OLDNEW
« no previous file with comments | « content/child/simple_webmimeregistry_impl.h ('k') | content/child/simple_webmimeregistry_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698