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