| 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" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/stl_util.h" |
| 13 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "net/base/mime_util.h" | 17 #include "net/base/mime_util.h" |
| 17 #include "net/base/platform_mime_util.h" | 18 #include "net/base/platform_mime_util.h" |
| 18 | 19 |
| 19 using std::string; | 20 using std::string; |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 std::vector<std::string> pattern_parameters; | 529 std::vector<std::string> pattern_parameters; |
| 529 base::SplitString(mime_type_pattern.substr(semicolon + 1), | 530 base::SplitString(mime_type_pattern.substr(semicolon + 1), |
| 530 ';', &pattern_parameters); | 531 ';', &pattern_parameters); |
| 531 | 532 |
| 532 std::vector<std::string> test_parameters; | 533 std::vector<std::string> test_parameters; |
| 533 base::SplitString(mime_type.substr(test_semicolon + 1), | 534 base::SplitString(mime_type.substr(test_semicolon + 1), |
| 534 ';', &test_parameters); | 535 ';', &test_parameters); |
| 535 | 536 |
| 536 sort(pattern_parameters.begin(), pattern_parameters.end()); | 537 sort(pattern_parameters.begin(), pattern_parameters.end()); |
| 537 sort(test_parameters.begin(), test_parameters.end()); | 538 sort(test_parameters.begin(), test_parameters.end()); |
| 538 std::vector<std::string> difference; | 539 std::vector<std::string> difference = |
| 539 std::set_difference(pattern_parameters.begin(), pattern_parameters.end(), | 540 base::STLSetDifference<std::vector<std::string> >(pattern_parameters, |
| 540 test_parameters.begin(), test_parameters.end(), | 541 test_parameters); |
| 541 std::inserter(difference, difference.begin())); | |
| 542 | 542 |
| 543 return difference.size() == 0; | 543 return difference.size() == 0; |
| 544 } | 544 } |
| 545 return true; | 545 return true; |
| 546 } | 546 } |
| 547 | 547 |
| 548 // This comparison handles absolute maching and also basic | 548 // This comparison handles absolute maching and also basic |
| 549 // wildcards. The plugin mime types could be: | 549 // wildcards. The plugin mime types could be: |
| 550 // application/x-foo | 550 // application/x-foo |
| 551 // application/* | 551 // application/* |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 post_data->append("\r\n" + value + "\r\n"); | 994 post_data->append("\r\n" + value + "\r\n"); |
| 995 } | 995 } |
| 996 | 996 |
| 997 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, | 997 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, |
| 998 std::string* post_data) { | 998 std::string* post_data) { |
| 999 DCHECK(post_data); | 999 DCHECK(post_data); |
| 1000 post_data->append("--" + mime_boundary + "--\r\n"); | 1000 post_data->append("--" + mime_boundary + "--\r\n"); |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 } // namespace net | 1003 } // namespace net |
| OLD | NEW |