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

Side by Side Diff: components/mime_util/mime_util.cc

Issue 1423663012: Removing x-x509-user-cert mime handler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/mime_util/mime_util.h" 5 #include "components/mime_util/mime_util.h"
6 6
7 #include "base/containers/hash_tables.h" 7 #include "base/containers/hash_tables.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 11
12 #if !defined(OS_IOS) 12 #if !defined(OS_IOS)
13 // iOS doesn't use and must not depend on //media 13 // iOS doesn't use and must not depend on //media
14 #include "media/base/mime_util.h" 14 #include "media/base/mime_util.h"
15 #endif 15 #endif
16 16
17 namespace mime_util { 17 namespace mime_util {
18 18
19 namespace { 19 namespace {
20 20
21 // Dictionary of cryptographic file mime types. 21 // Dictionary of cryptographic file mime types.
22 struct CertificateMimeTypeInfo { 22 struct CertificateMimeTypeInfo {
23 const char* const mime_type; 23 const char* const mime_type;
24 net::CertificateMimeType cert_type; 24 net::CertificateMimeType cert_type;
25 }; 25 };
26 26
27 #if defined(OS_ANDROID)
27 const CertificateMimeTypeInfo kSupportedCertificateTypes[] = { 28 const CertificateMimeTypeInfo kSupportedCertificateTypes[] = {
28 {"application/x-x509-user-cert", net::CERTIFICATE_MIME_TYPE_X509_USER_CERT}, 29 {"application/x-x509-user-cert", net::CERTIFICATE_MIME_TYPE_X509_USER_CERT},
29 #if defined(OS_ANDROID)
30 {"application/x-x509-ca-cert", net::CERTIFICATE_MIME_TYPE_X509_CA_CERT}, 30 {"application/x-x509-ca-cert", net::CERTIFICATE_MIME_TYPE_X509_CA_CERT},
31 {"application/x-pkcs12", net::CERTIFICATE_MIME_TYPE_PKCS12_ARCHIVE}, 31 {"application/x-pkcs12", net::CERTIFICATE_MIME_TYPE_PKCS12_ARCHIVE},
32 };
32 #endif 33 #endif
33 };
34 34
35 // From WebKit's WebCore/platform/MIMETypeRegistry.cpp: 35 // From WebKit's WebCore/platform/MIMETypeRegistry.cpp:
36 36
37 const char* const kSupportedImageTypes[] = {"image/jpeg", 37 const char* const kSupportedImageTypes[] = {"image/jpeg",
38 "image/pjpeg", 38 "image/pjpeg",
39 "image/jpg", 39 "image/jpg",
40 "image/webp", 40 "image/webp",
41 "image/png", 41 "image/png",
42 "image/gif", 42 "image/gif",
43 "image/bmp", 43 "image/bmp",
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 for (size_t i = 0; i < arraysize(kSupportedNonImageTypes); ++i) 139 for (size_t i = 0; i < arraysize(kSupportedNonImageTypes); ++i)
140 non_image_types_.insert(kSupportedNonImageTypes[i]); 140 non_image_types_.insert(kSupportedNonImageTypes[i]);
141 for (size_t i = 0; i < arraysize(kSupportedImageTypes); ++i) 141 for (size_t i = 0; i < arraysize(kSupportedImageTypes); ++i)
142 image_types_.insert(kSupportedImageTypes[i]); 142 image_types_.insert(kSupportedImageTypes[i]);
143 for (size_t i = 0; i < arraysize(kUnsupportedTextTypes); ++i) 143 for (size_t i = 0; i < arraysize(kUnsupportedTextTypes); ++i)
144 unsupported_text_types_.insert(kUnsupportedTextTypes[i]); 144 unsupported_text_types_.insert(kUnsupportedTextTypes[i]);
145 for (size_t i = 0; i < arraysize(kSupportedJavascriptTypes); ++i) { 145 for (size_t i = 0; i < arraysize(kSupportedJavascriptTypes); ++i) {
146 javascript_types_.insert(kSupportedJavascriptTypes[i]); 146 javascript_types_.insert(kSupportedJavascriptTypes[i]);
147 non_image_types_.insert(kSupportedJavascriptTypes[i]); 147 non_image_types_.insert(kSupportedJavascriptTypes[i]);
148 } 148 }
149 #if defined(OS_ANDROID)
149 for (size_t i = 0; i < arraysize(kSupportedCertificateTypes); ++i) 150 for (size_t i = 0; i < arraysize(kSupportedCertificateTypes); ++i)
150 non_image_types_.insert(kSupportedCertificateTypes[i].mime_type); 151 non_image_types_.insert(kSupportedCertificateTypes[i].mime_type);
152 #endif
151 } 153 }
152 154
153 bool MimeUtil::IsSupportedImageMimeType(const std::string& mime_type) const { 155 bool MimeUtil::IsSupportedImageMimeType(const std::string& mime_type) const {
154 return image_types_.find(base::ToLowerASCII(mime_type)) != image_types_.end(); 156 return image_types_.find(base::ToLowerASCII(mime_type)) != image_types_.end();
155 } 157 }
156 158
157 bool MimeUtil::IsSupportedNonImageMimeType(const std::string& mime_type) const { 159 bool MimeUtil::IsSupportedNonImageMimeType(const std::string& mime_type) const {
158 return non_image_types_.find(base::ToLowerASCII(mime_type)) != 160 return non_image_types_.find(base::ToLowerASCII(mime_type)) !=
159 non_image_types_.end() || 161 non_image_types_.end() ||
160 #if !defined(OS_IOS) 162 #if !defined(OS_IOS)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 GetCertificateMimeTypeForMimeType(mime_type); 214 GetCertificateMimeTypeForMimeType(mime_type);
213 return file_type != net::CERTIFICATE_MIME_TYPE_UNKNOWN; 215 return file_type != net::CERTIFICATE_MIME_TYPE_UNKNOWN;
214 } 216 }
215 217
216 bool IsSupportedMimeType(const std::string& mime_type) { 218 bool IsSupportedMimeType(const std::string& mime_type) {
217 return g_mime_util.Get().IsSupportedMimeType(mime_type); 219 return g_mime_util.Get().IsSupportedMimeType(mime_type);
218 } 220 }
219 221
220 net::CertificateMimeType GetCertificateMimeTypeForMimeType( 222 net::CertificateMimeType GetCertificateMimeTypeForMimeType(
221 const std::string& mime_type) { 223 const std::string& mime_type) {
224 #if defined(OS_ANDROID)
222 // Don't create a map, there is only one entry in the table, 225 // Don't create a map, there is only one entry in the table,
223 // except on Android. 226 // except on Android.
224 for (size_t i = 0; i < arraysize(kSupportedCertificateTypes); ++i) { 227 for (size_t i = 0; i < arraysize(kSupportedCertificateTypes); ++i) {
225 if (base::EqualsCaseInsensitiveASCII( 228 if (base::EqualsCaseInsensitiveASCII(
226 mime_type, kSupportedCertificateTypes[i].mime_type)) { 229 mime_type, kSupportedCertificateTypes[i].mime_type)) {
227 return kSupportedCertificateTypes[i].cert_type; 230 return kSupportedCertificateTypes[i].cert_type;
228 } 231 }
229 } 232 }
233 #endif
230 234
231 return net::CERTIFICATE_MIME_TYPE_UNKNOWN; 235 return net::CERTIFICATE_MIME_TYPE_UNKNOWN;
232 } 236 }
233 237
234 } // namespace mime_util 238 } // namespace mime_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698