| OLD | NEW |
| 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 #include "media/base/mime_util.h" |
| 11 | 12 |
| 12 namespace mime_util { | 13 namespace mime_util { |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 // Dictionary of cryptographic file mime types. | 17 // Dictionary of cryptographic file mime types. |
| 17 struct CertificateMimeTypeInfo { | 18 struct CertificateMimeTypeInfo { |
| 18 const char* const mime_type; | 19 const char* const mime_type; |
| 19 net::CertificateMimeType cert_type; | 20 net::CertificateMimeType cert_type; |
| 20 }; | 21 }; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 image_types_.end(); | 151 image_types_.end(); |
| 151 } | 152 } |
| 152 | 153 |
| 153 bool MimeUtil::IsSupportedNonImageMimeType(const std::string& mime_type) const { | 154 bool MimeUtil::IsSupportedNonImageMimeType(const std::string& mime_type) const { |
| 154 return non_image_types_.find(base::StringToLowerASCII(mime_type)) != | 155 return non_image_types_.find(base::StringToLowerASCII(mime_type)) != |
| 155 non_image_types_.end() || | 156 non_image_types_.end() || |
| 156 (StartsWithASCII(mime_type, "text/", false /* case insensitive */) && | 157 (StartsWithASCII(mime_type, "text/", false /* case insensitive */) && |
| 157 !IsUnsupportedTextMimeType(mime_type)) || | 158 !IsUnsupportedTextMimeType(mime_type)) || |
| 158 (StartsWithASCII(mime_type, "application/", false) && | 159 (StartsWithASCII(mime_type, "application/", false) && |
| 159 net::MatchesMimeType("application/*+json", mime_type)) || | 160 net::MatchesMimeType("application/*+json", mime_type)) || |
| 160 net::IsSupportedMediaMimeType(mime_type); | 161 media::IsSupportedMediaMimeType(mime_type); |
| 161 } | 162 } |
| 162 | 163 |
| 163 bool MimeUtil::IsUnsupportedTextMimeType(const std::string& mime_type) const { | 164 bool MimeUtil::IsUnsupportedTextMimeType(const std::string& mime_type) const { |
| 164 return unsupported_text_types_.find(base::StringToLowerASCII(mime_type)) != | 165 return unsupported_text_types_.find(base::StringToLowerASCII(mime_type)) != |
| 165 unsupported_text_types_.end(); | 166 unsupported_text_types_.end(); |
| 166 } | 167 } |
| 167 | 168 |
| 168 bool MimeUtil::IsSupportedJavascriptMimeType( | 169 bool MimeUtil::IsSupportedJavascriptMimeType( |
| 169 const std::string& mime_type) const { | 170 const std::string& mime_type) const { |
| 170 return javascript_types_.find(mime_type) != javascript_types_.end(); | 171 return javascript_types_.find(mime_type) != javascript_types_.end(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 if (base::strcasecmp(mime_type.c_str(), | 217 if (base::strcasecmp(mime_type.c_str(), |
| 217 kSupportedCertificateTypes[i].mime_type) == 0) { | 218 kSupportedCertificateTypes[i].mime_type) == 0) { |
| 218 return kSupportedCertificateTypes[i].cert_type; | 219 return kSupportedCertificateTypes[i].cert_type; |
| 219 } | 220 } |
| 220 } | 221 } |
| 221 | 222 |
| 222 return net::CERTIFICATE_MIME_TYPE_UNKNOWN; | 223 return net::CERTIFICATE_MIME_TYPE_UNKNOWN; |
| 223 } | 224 } |
| 224 | 225 |
| 225 } // namespace mime_util | 226 } // namespace mime_util |
| OLD | NEW |