Chromium Code Reviews| 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 #if !defined(OS_IOS) | |
|
Ryan Sleevi
2015/05/13 23:55:53
newline between 10 & 11
https://www.chromium.org/
servolk
2015/05/14 00:13:23
Done.
| |
| 12 // iOS doesn't use and must not depend on //media | |
| 13 #include "media/base/mime_util.h" | |
| 14 #endif | |
| 11 | 15 |
| 12 namespace mime_util { | 16 namespace mime_util { |
| 13 | 17 |
| 14 namespace { | 18 namespace { |
| 15 | 19 |
| 16 // Dictionary of cryptographic file mime types. | 20 // Dictionary of cryptographic file mime types. |
| 17 struct CertificateMimeTypeInfo { | 21 struct CertificateMimeTypeInfo { |
| 18 const char* const mime_type; | 22 const char* const mime_type; |
| 19 net::CertificateMimeType cert_type; | 23 net::CertificateMimeType cert_type; |
| 20 }; | 24 }; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 } | 150 } |
| 147 | 151 |
| 148 bool MimeUtil::IsSupportedImageMimeType(const std::string& mime_type) const { | 152 bool MimeUtil::IsSupportedImageMimeType(const std::string& mime_type) const { |
| 149 return image_types_.find(base::StringToLowerASCII(mime_type)) != | 153 return image_types_.find(base::StringToLowerASCII(mime_type)) != |
| 150 image_types_.end(); | 154 image_types_.end(); |
| 151 } | 155 } |
| 152 | 156 |
| 153 bool MimeUtil::IsSupportedNonImageMimeType(const std::string& mime_type) const { | 157 bool MimeUtil::IsSupportedNonImageMimeType(const std::string& mime_type) const { |
| 154 return non_image_types_.find(base::StringToLowerASCII(mime_type)) != | 158 return non_image_types_.find(base::StringToLowerASCII(mime_type)) != |
| 155 non_image_types_.end() || | 159 non_image_types_.end() || |
| 160 #if !defined(OS_IOS) | |
| 161 media::IsSupportedMediaMimeType(mime_type) || | |
| 162 #endif | |
| 156 (StartsWithASCII(mime_type, "text/", false /* case insensitive */) && | 163 (StartsWithASCII(mime_type, "text/", false /* case insensitive */) && |
| 157 !IsUnsupportedTextMimeType(mime_type)) || | 164 !IsUnsupportedTextMimeType(mime_type)) || |
| 158 (StartsWithASCII(mime_type, "application/", false) && | 165 (StartsWithASCII(mime_type, "application/", false) && |
| 159 net::MatchesMimeType("application/*+json", mime_type)) || | 166 net::MatchesMimeType("application/*+json", mime_type)); |
| 160 net::IsSupportedMediaMimeType(mime_type); | |
| 161 } | 167 } |
| 162 | 168 |
| 163 bool MimeUtil::IsUnsupportedTextMimeType(const std::string& mime_type) const { | 169 bool MimeUtil::IsUnsupportedTextMimeType(const std::string& mime_type) const { |
| 164 return unsupported_text_types_.find(base::StringToLowerASCII(mime_type)) != | 170 return unsupported_text_types_.find(base::StringToLowerASCII(mime_type)) != |
| 165 unsupported_text_types_.end(); | 171 unsupported_text_types_.end(); |
| 166 } | 172 } |
| 167 | 173 |
| 168 bool MimeUtil::IsSupportedJavascriptMimeType( | 174 bool MimeUtil::IsSupportedJavascriptMimeType( |
| 169 const std::string& mime_type) const { | 175 const std::string& mime_type) const { |
| 170 return javascript_types_.find(mime_type) != javascript_types_.end(); | 176 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(), | 222 if (base::strcasecmp(mime_type.c_str(), |
| 217 kSupportedCertificateTypes[i].mime_type) == 0) { | 223 kSupportedCertificateTypes[i].mime_type) == 0) { |
| 218 return kSupportedCertificateTypes[i].cert_type; | 224 return kSupportedCertificateTypes[i].cert_type; |
| 219 } | 225 } |
| 220 } | 226 } |
| 221 | 227 |
| 222 return net::CERTIFICATE_MIME_TYPE_UNKNOWN; | 228 return net::CERTIFICATE_MIME_TYPE_UNKNOWN; |
| 223 } | 229 } |
| 224 | 230 |
| 225 } // namespace mime_util | 231 } // namespace mime_util |
| OLD | NEW |