| 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 // Test length to prevent overlap between |left| and |right|. | 279 // Test length to prevent overlap between |left| and |right|. |
| 280 if (base_type.length() < base_pattern.length() - 1) | 280 if (base_type.length() < base_pattern.length() - 1) |
| 281 return false; | 281 return false; |
| 282 | 282 |
| 283 const std::string left(base_pattern.substr(0, star)); | 283 const std::string left(base_pattern.substr(0, star)); |
| 284 const std::string right(base_pattern.substr(star + 1)); | 284 const std::string right(base_pattern.substr(star + 1)); |
| 285 | 285 |
| 286 if (!base::StartsWithASCII(base_type, left, false)) | 286 if (!base::StartsWithASCII(base_type, left, false)) |
| 287 return false; | 287 return false; |
| 288 | 288 |
| 289 if (!right.empty() && !EndsWith(base_type, right, false)) | 289 if (!right.empty() && !base::EndsWith(base_type, right, false)) |
| 290 return false; | 290 return false; |
| 291 | 291 |
| 292 return MatchesMimeTypeParameters(mime_type_pattern, mime_type); | 292 return MatchesMimeTypeParameters(mime_type_pattern, mime_type); |
| 293 } | 293 } |
| 294 | 294 |
| 295 // See http://www.iana.org/assignments/media-types/media-types.xhtml | 295 // See http://www.iana.org/assignments/media-types/media-types.xhtml |
| 296 static const char* const legal_top_level_types[] = { | 296 static const char* const legal_top_level_types[] = { |
| 297 "application", | 297 "application", |
| 298 "audio", | 298 "audio", |
| 299 "example", | 299 "example", |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 | 514 |
| 515 void GetExtensionsForMimeType( | 515 void GetExtensionsForMimeType( |
| 516 const std::string& unsafe_mime_type, | 516 const std::string& unsafe_mime_type, |
| 517 std::vector<base::FilePath::StringType>* extensions) { | 517 std::vector<base::FilePath::StringType>* extensions) { |
| 518 if (unsafe_mime_type == "*/*" || unsafe_mime_type == "*") | 518 if (unsafe_mime_type == "*/*" || unsafe_mime_type == "*") |
| 519 return; | 519 return; |
| 520 | 520 |
| 521 const std::string mime_type = base::StringToLowerASCII(unsafe_mime_type); | 521 const std::string mime_type = base::StringToLowerASCII(unsafe_mime_type); |
| 522 base::hash_set<base::FilePath::StringType> unique_extensions; | 522 base::hash_set<base::FilePath::StringType> unique_extensions; |
| 523 | 523 |
| 524 if (EndsWith(mime_type, "/*", false)) { | 524 if (base::EndsWith(mime_type, "/*", false)) { |
| 525 std::string leading_mime_type = mime_type.substr(0, mime_type.length() - 1); | 525 std::string leading_mime_type = mime_type.substr(0, mime_type.length() - 1); |
| 526 | 526 |
| 527 // Find the matching StandardType from within kStandardTypes, or fall | 527 // Find the matching StandardType from within kStandardTypes, or fall |
| 528 // through to the last (default) StandardType. | 528 // through to the last (default) StandardType. |
| 529 const StandardType* type = NULL; | 529 const StandardType* type = NULL; |
| 530 for (size_t i = 0; i < arraysize(kStandardTypes); ++i) { | 530 for (size_t i = 0; i < arraysize(kStandardTypes); ++i) { |
| 531 type = &(kStandardTypes[i]); | 531 type = &(kStandardTypes[i]); |
| 532 if (type->leading_mime_type && | 532 if (type->leading_mime_type && |
| 533 leading_mime_type == type->leading_mime_type) | 533 leading_mime_type == type->leading_mime_type) |
| 534 break; | 534 break; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 post_data->append("\r\n" + value + "\r\n"); | 577 post_data->append("\r\n" + value + "\r\n"); |
| 578 } | 578 } |
| 579 | 579 |
| 580 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, | 580 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, |
| 581 std::string* post_data) { | 581 std::string* post_data) { |
| 582 DCHECK(post_data); | 582 DCHECK(post_data); |
| 583 post_data->append("--" + mime_boundary + "--\r\n"); | 583 post_data->append("--" + mime_boundary + "--\r\n"); |
| 584 } | 584 } |
| 585 | 585 |
| 586 } // namespace net | 586 } // namespace net |
| OLD | NEW |