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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 base::StringPairs pattern_parameters; | 217 base::StringPairs pattern_parameters; |
218 base::SplitStringIntoKeyValuePairs(mime_type_pattern.substr(semicolon + 1), | 218 base::SplitStringIntoKeyValuePairs(mime_type_pattern.substr(semicolon + 1), |
219 '=', ';', &pattern_parameters); | 219 '=', ';', &pattern_parameters); |
220 base::StringPairs test_parameters; | 220 base::StringPairs test_parameters; |
221 base::SplitStringIntoKeyValuePairs(mime_type.substr(test_semicolon + 1), | 221 base::SplitStringIntoKeyValuePairs(mime_type.substr(test_semicolon + 1), |
222 '=', ';', &test_parameters); | 222 '=', ';', &test_parameters); |
223 | 223 |
224 // Put the parameters to maps with the keys converted to lower case. | 224 // Put the parameters to maps with the keys converted to lower case. |
225 StringPairMap pattern_parameter_map; | 225 StringPairMap pattern_parameter_map; |
226 for (const auto& pair : pattern_parameters) { | 226 for (const auto& pair : pattern_parameters) { |
227 pattern_parameter_map[base::StringToLowerASCII(pair.first)] = pair.second; | 227 pattern_parameter_map[base::ToLowerASCII(pair.first)] = pair.second; |
228 } | 228 } |
229 | 229 |
230 StringPairMap test_parameter_map; | 230 StringPairMap test_parameter_map; |
231 for (const auto& pair : test_parameters) { | 231 for (const auto& pair : test_parameters) { |
232 test_parameter_map[base::StringToLowerASCII(pair.first)] = pair.second; | 232 test_parameter_map[base::ToLowerASCII(pair.first)] = pair.second; |
233 } | 233 } |
234 | 234 |
235 if (pattern_parameter_map.size() > test_parameter_map.size()) | 235 if (pattern_parameter_map.size() > test_parameter_map.size()) |
236 return false; | 236 return false; |
237 | 237 |
238 for (const auto& parameter_pair : pattern_parameter_map) { | 238 for (const auto& parameter_pair : pattern_parameter_map) { |
239 const auto& test_parameter_pair_it = | 239 const auto& test_parameter_pair_it = |
240 test_parameter_map.find(parameter_pair.first); | 240 test_parameter_map.find(parameter_pair.first); |
241 if (test_parameter_pair_it == test_parameter_map.end()) | 241 if (test_parameter_pair_it == test_parameter_map.end()) |
242 return false; | 242 return false; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 return false; | 320 return false; |
321 | 321 |
322 if (top_level_type) | 322 if (top_level_type) |
323 *top_level_type = components[0]; | 323 *top_level_type = components[0]; |
324 if (subtype) | 324 if (subtype) |
325 *subtype = components[1]; | 325 *subtype = components[1]; |
326 return true; | 326 return true; |
327 } | 327 } |
328 | 328 |
329 bool MimeUtil::IsValidTopLevelMimeType(const std::string& type_string) const { | 329 bool MimeUtil::IsValidTopLevelMimeType(const std::string& type_string) const { |
330 std::string lower_type = base::StringToLowerASCII(type_string); | 330 std::string lower_type = base::ToLowerASCII(type_string); |
331 for (size_t i = 0; i < arraysize(legal_top_level_types); ++i) { | 331 for (size_t i = 0; i < arraysize(legal_top_level_types); ++i) { |
332 if (lower_type.compare(legal_top_level_types[i]) == 0) | 332 if (lower_type.compare(legal_top_level_types[i]) == 0) |
333 return true; | 333 return true; |
334 } | 334 } |
335 | 335 |
336 return type_string.size() > 2 && | 336 return type_string.size() > 2 && |
337 base::StartsWith(type_string, "x-", | 337 base::StartsWith(type_string, "x-", |
338 base::CompareCase::INSENSITIVE_ASCII); | 338 base::CompareCase::INSENSITIVE_ASCII); |
339 } | 339 } |
340 | 340 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 } | 514 } |
515 | 515 |
516 } // namespace | 516 } // namespace |
517 | 517 |
518 void GetExtensionsForMimeType( | 518 void GetExtensionsForMimeType( |
519 const std::string& unsafe_mime_type, | 519 const std::string& unsafe_mime_type, |
520 std::vector<base::FilePath::StringType>* extensions) { | 520 std::vector<base::FilePath::StringType>* extensions) { |
521 if (unsafe_mime_type == "*/*" || unsafe_mime_type == "*") | 521 if (unsafe_mime_type == "*/*" || unsafe_mime_type == "*") |
522 return; | 522 return; |
523 | 523 |
524 const std::string mime_type = base::StringToLowerASCII(unsafe_mime_type); | 524 const std::string mime_type = base::ToLowerASCII(unsafe_mime_type); |
525 base::hash_set<base::FilePath::StringType> unique_extensions; | 525 base::hash_set<base::FilePath::StringType> unique_extensions; |
526 | 526 |
527 if (base::EndsWith(mime_type, "/*", base::CompareCase::INSENSITIVE_ASCII)) { | 527 if (base::EndsWith(mime_type, "/*", base::CompareCase::INSENSITIVE_ASCII)) { |
528 std::string leading_mime_type = mime_type.substr(0, mime_type.length() - 1); | 528 std::string leading_mime_type = mime_type.substr(0, mime_type.length() - 1); |
529 | 529 |
530 // Find the matching StandardType from within kStandardTypes, or fall | 530 // Find the matching StandardType from within kStandardTypes, or fall |
531 // through to the last (default) StandardType. | 531 // through to the last (default) StandardType. |
532 const StandardType* type = NULL; | 532 const StandardType* type = NULL; |
533 for (size_t i = 0; i < arraysize(kStandardTypes); ++i) { | 533 for (size_t i = 0; i < arraysize(kStandardTypes); ++i) { |
534 type = &(kStandardTypes[i]); | 534 type = &(kStandardTypes[i]); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 post_data->append("\r\n" + value + "\r\n"); | 580 post_data->append("\r\n" + value + "\r\n"); |
581 } | 581 } |
582 | 582 |
583 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, | 583 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, |
584 std::string* post_data) { | 584 std::string* post_data) { |
585 DCHECK(post_data); | 585 DCHECK(post_data); |
586 post_data->append("--" + mime_boundary + "--\r\n"); | 586 post_data->append("--" + mime_boundary + "--\r\n"); |
587 } | 587 } |
588 | 588 |
589 } // namespace net | 589 } // namespace net |
OLD | NEW |