| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <iterator> | 6 #include <iterator> |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 167 |
| 168 // Lookup table for string compare based string -> Codec mappings. | 168 // Lookup table for string compare based string -> Codec mappings. |
| 169 StringToCodecMappings string_to_codec_map_; | 169 StringToCodecMappings string_to_codec_map_; |
| 170 }; // class MimeUtil | 170 }; // class MimeUtil |
| 171 | 171 |
| 172 // This variable is Leaky because we need to access it from WorkerPool threads. | 172 // This variable is Leaky because we need to access it from WorkerPool threads. |
| 173 static base::LazyInstance<MimeUtil>::Leaky g_mime_util = | 173 static base::LazyInstance<MimeUtil>::Leaky g_mime_util = |
| 174 LAZY_INSTANCE_INITIALIZER; | 174 LAZY_INSTANCE_INITIALIZER; |
| 175 | 175 |
| 176 struct MimeInfo { | 176 struct MimeInfo { |
| 177 const char* mime_type; | 177 const char* const mime_type; |
| 178 const char* extensions; // comma separated list | 178 const char* const extensions; // comma separated list |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 static const MimeInfo primary_mappings[] = { | 181 static const MimeInfo primary_mappings[] = { |
| 182 { "text/html", "html,htm,shtml,shtm" }, | 182 { "text/html", "html,htm,shtml,shtm" }, |
| 183 { "text/css", "css" }, | 183 { "text/css", "css" }, |
| 184 { "text/xml", "xml" }, | 184 { "text/xml", "xml" }, |
| 185 { "image/gif", "gif" }, | 185 { "image/gif", "gif" }, |
| 186 { "image/jpeg", "jpeg,jpg" }, | 186 { "image/jpeg", "jpeg,jpg" }, |
| 187 { "image/webp", "webp" }, | 187 { "image/webp", "webp" }, |
| 188 { "image/png", "png" }, | 188 { "image/png", "png" }, |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 "application/xhtml+xml", | 378 "application/xhtml+xml", |
| 379 "application/json", | 379 "application/json", |
| 380 "multipart/related", // For MHTML support. | 380 "multipart/related", // For MHTML support. |
| 381 "multipart/x-mixed-replace" | 381 "multipart/x-mixed-replace" |
| 382 // Note: ADDING a new type here will probably render it AS HTML. This can | 382 // Note: ADDING a new type here will probably render it AS HTML. This can |
| 383 // result in cross site scripting. | 383 // result in cross site scripting. |
| 384 }; | 384 }; |
| 385 | 385 |
| 386 // Dictionary of cryptographic file mime types. | 386 // Dictionary of cryptographic file mime types. |
| 387 struct CertificateMimeTypeInfo { | 387 struct CertificateMimeTypeInfo { |
| 388 const char* mime_type; | 388 const char* const mime_type; |
| 389 CertificateMimeType cert_type; | 389 CertificateMimeType cert_type; |
| 390 }; | 390 }; |
| 391 | 391 |
| 392 static const CertificateMimeTypeInfo supported_certificate_types[] = { | 392 static const CertificateMimeTypeInfo supported_certificate_types[] = { |
| 393 { "application/x-x509-user-cert", | 393 { "application/x-x509-user-cert", |
| 394 CERTIFICATE_MIME_TYPE_X509_USER_CERT }, | 394 CERTIFICATE_MIME_TYPE_X509_USER_CERT }, |
| 395 #if defined(OS_ANDROID) | 395 #if defined(OS_ANDROID) |
| 396 { "application/x-x509-ca-cert", CERTIFICATE_MIME_TYPE_X509_CA_CERT }, | 396 { "application/x-x509-ca-cert", CERTIFICATE_MIME_TYPE_X509_CA_CERT }, |
| 397 { "application/x-pkcs12", CERTIFICATE_MIME_TYPE_PKCS12_ARCHIVE }, | 397 { "application/x-pkcs12", CERTIFICATE_MIME_TYPE_PKCS12_ARCHIVE }, |
| 398 #endif | 398 #endif |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 if ((!mimeType.compare("application/vnd.apple.mpegurl") || | 491 if ((!mimeType.compare("application/vnd.apple.mpegurl") || |
| 492 !mimeType.compare("application/x-mpegurl")) && | 492 !mimeType.compare("application/x-mpegurl")) && |
| 493 base::android::BuildInfo::GetInstance()->sdk_int() < 14) { | 493 base::android::BuildInfo::GetInstance()->sdk_int() < 14) { |
| 494 return false; | 494 return false; |
| 495 } | 495 } |
| 496 return true; | 496 return true; |
| 497 } | 497 } |
| 498 #endif | 498 #endif |
| 499 | 499 |
| 500 struct MediaFormatStrict { | 500 struct MediaFormatStrict { |
| 501 const char* mime_type; | 501 const char* const mime_type; |
| 502 const char* codecs_list; | 502 const char* const codecs_list; |
| 503 }; | 503 }; |
| 504 | 504 |
| 505 // Following is the list of RFC 6381 compliant codecs: | 505 // Following is the list of RFC 6381 compliant codecs: |
| 506 // mp4a.66 - MPEG-2 AAC MAIN | 506 // mp4a.66 - MPEG-2 AAC MAIN |
| 507 // mp4a.67 - MPEG-2 AAC LC | 507 // mp4a.67 - MPEG-2 AAC LC |
| 508 // mp4a.68 - MPEG-2 AAC SSR | 508 // mp4a.68 - MPEG-2 AAC SSR |
| 509 // mp4a.69 - MPEG-2 extension to MPEG-1 | 509 // mp4a.69 - MPEG-2 extension to MPEG-1 |
| 510 // mp4a.6B - MPEG-1 audio | 510 // mp4a.6B - MPEG-1 audio |
| 511 // mp4a.40.2 - MPEG-4 AAC LC | 511 // mp4a.40.2 - MPEG-4 AAC LC |
| 512 // mp4a.40.02 - MPEG-4 AAC LC (leading 0 in aud-oti for compatibility) | 512 // mp4a.40.02 - MPEG-4 AAC LC (leading 0 in aud-oti for compatibility) |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 return false; | 792 return false; |
| 793 | 793 |
| 794 if (!right.empty() && | 794 if (!right.empty() && |
| 795 base_type.rfind(right) != base_type.length() - right.length()) | 795 base_type.rfind(right) != base_type.length() - right.length()) |
| 796 return false; | 796 return false; |
| 797 | 797 |
| 798 return MatchesMimeTypeParameters(mime_type_pattern, mime_type); | 798 return MatchesMimeTypeParameters(mime_type_pattern, mime_type); |
| 799 } | 799 } |
| 800 | 800 |
| 801 // See http://www.iana.org/assignments/media-types/media-types.xhtml | 801 // See http://www.iana.org/assignments/media-types/media-types.xhtml |
| 802 static const char* legal_top_level_types[] = { | 802 static const char* const legal_top_level_types[] = { |
| 803 "application", | 803 "application", |
| 804 "audio", | 804 "audio", |
| 805 "example", | 805 "example", |
| 806 "image", | 806 "image", |
| 807 "message", | 807 "message", |
| 808 "model", | 808 "model", |
| 809 "multipart", | 809 "multipart", |
| 810 "text", | 810 "text", |
| 811 "video", | 811 "video", |
| 812 }; | 812 }; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 "video/sd-video", | 1216 "video/sd-video", |
| 1217 "video/webm", | 1217 "video/webm", |
| 1218 "video/x-dv", | 1218 "video/x-dv", |
| 1219 "video/x-m4v", | 1219 "video/x-m4v", |
| 1220 "video/x-mpeg", | 1220 "video/x-mpeg", |
| 1221 "video/x-ms-asf", | 1221 "video/x-ms-asf", |
| 1222 "video/x-ms-wmv" | 1222 "video/x-ms-wmv" |
| 1223 }; | 1223 }; |
| 1224 | 1224 |
| 1225 struct StandardType { | 1225 struct StandardType { |
| 1226 const char* leading_mime_type; | 1226 const char* const leading_mime_type; |
| 1227 const char* const* standard_types; | 1227 const char* const* standard_types; |
| 1228 size_t standard_types_len; | 1228 size_t standard_types_len; |
| 1229 }; | 1229 }; |
| 1230 static const StandardType kStandardTypes[] = { | 1230 static const StandardType kStandardTypes[] = { |
| 1231 { "image/", kStandardImageTypes, arraysize(kStandardImageTypes) }, | 1231 { "image/", kStandardImageTypes, arraysize(kStandardImageTypes) }, |
| 1232 { "audio/", kStandardAudioTypes, arraysize(kStandardAudioTypes) }, | 1232 { "audio/", kStandardAudioTypes, arraysize(kStandardAudioTypes) }, |
| 1233 { "video/", kStandardVideoTypes, arraysize(kStandardVideoTypes) }, | 1233 { "video/", kStandardVideoTypes, arraysize(kStandardVideoTypes) }, |
| 1234 { NULL, NULL, 0 } | 1234 { NULL, NULL, 0 } |
| 1235 }; | 1235 }; |
| 1236 | 1236 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 post_data->append("\r\n" + value + "\r\n"); | 1379 post_data->append("\r\n" + value + "\r\n"); |
| 1380 } | 1380 } |
| 1381 | 1381 |
| 1382 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, | 1382 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, |
| 1383 std::string* post_data) { | 1383 std::string* post_data) { |
| 1384 DCHECK(post_data); | 1384 DCHECK(post_data); |
| 1385 post_data->append("--" + mime_boundary + "--\r\n"); | 1385 post_data->append("--" + mime_boundary + "--\r\n"); |
| 1386 } | 1386 } |
| 1387 | 1387 |
| 1388 } // namespace net | 1388 } // namespace net |
| OLD | NEW |