Index: net/base/mime_util.cc |
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc |
index f851ecd13785764d6b3a18825801a13411eca91a..88eeebe583e5bcf62fe8cf50512d4bdee198a7fb 100644 |
--- a/net/base/mime_util.cc |
+++ b/net/base/mime_util.cc |
@@ -337,13 +337,26 @@ 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 CertificateTypeInfo { |
+ const char* mime_type; |
+ CertificateType cert_type; |
+}; |
+ |
+static const CertificateTypeInfo supported_certificate_types[] = { |
Ryan Sleevi
2012/11/13 19:37:50
nit: whitespace (" " should be " ")
|
+ { "application/x-x509-user-cert", CERTIFICATE_TYPE_X509_USER_CERT }, |
+#if defined(OS_ANDROID) |
+ { "application/x-x509-ca-cert", CERTIFICATE_TYPE_X509_CA_CERT }, |
+ { "application/x-pkcs12", CERTIFICATE_TYPE_PKCS12_KEYCHAIN }, |
+#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. |
@@ -431,6 +444,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) |
@@ -922,4 +937,20 @@ const std::string GetIANAMediaType(const std::string& mime_type) { |
return ""; |
} |
+CertificateType GetCertificateTypeForMimeType( |
+ 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; |
Ryan Sleevi
2012/11/13 19:37:50
nit: indentation
|
+ } |
+ return CERTIFICATE_TYPE_UNKNOWN; |
+} |
+ |
+bool IsSupportedCertificateMimeType(const std::string& mime_type) { |
+ CertificateType file_type = GetCertificateTypeForMimeType(mime_type); |
+ return file_type != CERTIFICATE_TYPE_UNKNOWN; |
+} |
+ |
} // namespace net |