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

Side by Side Diff: net/base/mime_util.cc

Issue 11266008: Fix certificate and keychain installation on Android. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: separate android and openssl CertDatabase implementations Created 8 years 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
« no previous file with comments | « net/base/mime_util.h ('k') | net/base/mime_util_certificate_type_list.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 5 #include <algorithm>
6 #include <iterator> 6 #include <iterator>
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "net/base/mime_util.h" 10 #include "net/base/mime_util.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 // behavior - css files will be displayed: 332 // behavior - css files will be displayed:
333 "text/css", 333 "text/css",
334 "text/vnd.chromium.ftp-dir", 334 "text/vnd.chromium.ftp-dir",
335 "text/", 335 "text/",
336 "image/svg+xml", // SVG is text-based XML, even though it has an image/ type 336 "image/svg+xml", // SVG is text-based XML, even though it has an image/ type
337 "application/xml", 337 "application/xml",
338 "application/atom+xml", 338 "application/atom+xml",
339 "application/rss+xml", 339 "application/rss+xml",
340 "application/xhtml+xml", 340 "application/xhtml+xml",
341 "application/json", 341 "application/json",
342 "application/x-x509-user-cert",
343 "multipart/related", // For MHTML support. 342 "multipart/related", // For MHTML support.
344 "multipart/x-mixed-replace" 343 "multipart/x-mixed-replace"
345 // Note: ADDING a new type here will probably render it AS HTML. This can 344 // Note: ADDING a new type here will probably render it AS HTML. This can
346 // result in cross site scripting. 345 // result in cross site scripting.
347 }; 346 };
348 347
348 // Dictionary of cryptographic file mime types.
349 struct CertificateMimeTypeInfo {
350 const char* mime_type;
351 CertificateMimeType cert_type;
352 };
353
354 static const CertificateMimeTypeInfo supported_certificate_types[] = {
355 { "application/x-x509-user-cert",
356 CERTIFICATE_MIME_TYPE_X509_USER_CERT },
357 #if defined(OS_ANDROID)
358 { "application/x-x509-ca-cert", CERTIFICATE_MIME_TYPE_X509_CA_CERT },
359 { "application/x-pkcs12", CERTIFICATE_MIME_TYPE_PKCS12_ARCHIVE },
360 #endif
361 };
362
349 // These types are excluded from the logic that allows all text/ types because 363 // These types are excluded from the logic that allows all text/ types because
350 // while they are technically text, it's very unlikely that a user expects to 364 // while they are technically text, it's very unlikely that a user expects to
351 // see them rendered in text form. 365 // see them rendered in text form.
352 static const char* const unsupported_text_types[] = { 366 static const char* const unsupported_text_types[] = {
353 "text/calendar", 367 "text/calendar",
354 "text/x-calendar", 368 "text/x-calendar",
355 "text/x-vcalendar", 369 "text/x-vcalendar",
356 "text/vcalendar", 370 "text/vcalendar",
357 "text/vcard", 371 "text/vcard",
358 "text/x-vcard", 372 "text/x-vcard",
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 return !codecs.empty(); 440 return !codecs.empty();
427 } 441 }
428 442
429 void MimeUtil::InitializeMimeTypeMaps() { 443 void MimeUtil::InitializeMimeTypeMaps() {
430 for (size_t i = 0; i < arraysize(supported_image_types); ++i) 444 for (size_t i = 0; i < arraysize(supported_image_types); ++i)
431 image_map_.insert(supported_image_types[i]); 445 image_map_.insert(supported_image_types[i]);
432 446
433 // Initialize the supported non-image types. 447 // Initialize the supported non-image types.
434 for (size_t i = 0; i < arraysize(supported_non_image_types); ++i) 448 for (size_t i = 0; i < arraysize(supported_non_image_types); ++i)
435 non_image_map_.insert(supported_non_image_types[i]); 449 non_image_map_.insert(supported_non_image_types[i]);
450 for (size_t i = 0; i < arraysize(supported_certificate_types); ++i)
451 non_image_map_.insert(supported_certificate_types[i].mime_type);
436 for (size_t i = 0; i < arraysize(unsupported_text_types); ++i) 452 for (size_t i = 0; i < arraysize(unsupported_text_types); ++i)
437 unsupported_text_map_.insert(unsupported_text_types[i]); 453 unsupported_text_map_.insert(unsupported_text_types[i]);
438 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) 454 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i)
439 non_image_map_.insert(supported_javascript_types[i]); 455 non_image_map_.insert(supported_javascript_types[i]);
440 for (size_t i = 0; i < arraysize(common_media_types); ++i) 456 for (size_t i = 0; i < arraysize(common_media_types); ++i)
441 non_image_map_.insert(common_media_types[i]); 457 non_image_map_.insert(common_media_types[i]);
442 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) 458 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
443 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) 459 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i)
444 non_image_map_.insert(proprietary_media_types[i]); 460 non_image_map_.insert(proprietary_media_types[i]);
445 #endif 461 #endif
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 977
962 const std::string GetIANAMediaType(const std::string& mime_type) { 978 const std::string GetIANAMediaType(const std::string& mime_type) {
963 for (size_t i = 0; i < arraysize(kIanaMediaTypes); ++i) { 979 for (size_t i = 0; i < arraysize(kIanaMediaTypes); ++i) {
964 if (StartsWithASCII(mime_type, kIanaMediaTypes[i].matcher, true)) { 980 if (StartsWithASCII(mime_type, kIanaMediaTypes[i].matcher, true)) {
965 return kIanaMediaTypes[i].name; 981 return kIanaMediaTypes[i].name;
966 } 982 }
967 } 983 }
968 return ""; 984 return "";
969 } 985 }
970 986
987 CertificateMimeType GetCertificateMimeTypeForMimeType(
988 const std::string& mime_type) {
989 // Don't create a map, there is only one entry in the table,
990 // except on Android.
991 for (size_t i = 0; i < arraysize(supported_certificate_types); ++i) {
992 if (mime_type == net::supported_certificate_types[i].mime_type)
993 return net::supported_certificate_types[i].cert_type;
994 }
995 return CERTIFICATE_MIME_TYPE_UNKNOWN;
996 }
997
998 bool IsSupportedCertificateMimeType(const std::string& mime_type) {
999 CertificateMimeType file_type =
1000 GetCertificateMimeTypeForMimeType(mime_type);
1001 return file_type != CERTIFICATE_MIME_TYPE_UNKNOWN;
1002 }
1003
971 } // namespace net 1004 } // namespace net
OLDNEW
« no previous file with comments | « net/base/mime_util.h ('k') | net/base/mime_util_certificate_type_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698