Index: net/base/mime_util.cc |
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc |
index 6ae918b8da068ad1005c6c36cc30814c8c28d5ff..b0054b951af498c9b31f89041704a048d80f0d2d 100644 |
--- a/net/base/mime_util.cc |
+++ b/net/base/mime_util.cc |
@@ -339,13 +339,28 @@ static const char* const supported_non_image_types[] = { |
"application/rss+xml", |
"application/xhtml+xml", |
"application/json", |
- "application/x-x509-user-cert", |
"multipart/related", // For MHTML support. |
"multipart/x-mixed-replace" |
// Note: ADDING a new type here will probably render it AS HTML. This can |
// result in cross site scripting. |
}; |
+// Dictionary of cryptographic file mime types. |
+struct CertificateMimeTypeInfo { |
+ const char* mime_type; |
+ CertificateMimeType cert_type; |
+}; |
+ |
+static const CertificateMimeTypeInfo supported_certificate_types[] = { |
+ { "application/x-x509-user-cert", |
darin (slow to review)
2012/11/27 05:24:34
nit: indentation is wrong
digit1
2012/11/27 10:19:48
I treated this a a line-continuation indent. Do yo
darin (slow to review)
2012/11/27 21:27:53
It's an array, much like supported_non_image_types
digit1
2012/11/27 22:33:04
Oh snap. Of course, I wasn't looking at the right
|
+ CERTIFICATE_MIME_TYPE_X509_USER_CERT }, |
+#if defined(OS_ANDROID) |
+ { "application/x-x509-ca-cert", CERTIFICATE_MIME_TYPE_X509_CA_CERT }, |
+ { "application/x-pkcs12", |
+ CERTIFICATE_MIME_TYPE_PKCS12_ARCHIVE }, |
+#endif |
+}; |
+ |
// These types are excluded from the logic that allows all text/ types because |
// while they are technically text, it's very unlikely that a user expects to |
// see them rendered in text form. |
@@ -433,6 +448,8 @@ void MimeUtil::InitializeMimeTypeMaps() { |
// Initialize the supported non-image types. |
for (size_t i = 0; i < arraysize(supported_non_image_types); ++i) |
non_image_map_.insert(supported_non_image_types[i]); |
+ for (size_t i = 0; i < arraysize(supported_certificate_types); ++i) |
+ non_image_map_.insert(supported_certificate_types[i].mime_type); |
for (size_t i = 0; i < arraysize(unsupported_text_types); ++i) |
unsupported_text_map_.insert(unsupported_text_types[i]); |
for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) |
@@ -968,4 +985,21 @@ const std::string GetIANAMediaType(const std::string& mime_type) { |
return ""; |
} |
+CertificateMimeType GetCertificateMimeTypeForMimeType( |
+ const std::string& mime_type) { |
+ // Don't create a map, there is only one entry in the table, |
+ // except on Android. |
+ for (size_t i = 0; i < arraysize(supported_certificate_types); ++i) { |
+ if (mime_type == net::supported_certificate_types[i].mime_type) |
+ return net::supported_certificate_types[i].cert_type; |
+ } |
+ return CERTIFICATE_MIME_TYPE_UNKNOWN; |
+} |
+ |
+bool IsSupportedCertificateMimeType(const std::string& mime_type) { |
+ CertificateMimeType file_type = |
+ GetCertificateMimeTypeForMimeType(mime_type); |
+ return file_type != CERTIFICATE_MIME_TYPE_UNKNOWN; |
+} |
+ |
} // namespace net |