Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: net/base/mime_util.cc

Issue 448853002: Move StringToLowerASCII to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/host_mapping_rules.cc ('k') | net/base/sdch_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 // wildcards. The plugin mime types could be: 760 // wildcards. The plugin mime types could be:
761 // application/x-foo 761 // application/x-foo
762 // application/* 762 // application/*
763 // application/*+xml 763 // application/*+xml
764 // * 764 // *
765 // Also tests mime parameters -- all parameters in the pattern must be present 765 // Also tests mime parameters -- all parameters in the pattern must be present
766 // in the tested type for a match to succeed. 766 // in the tested type for a match to succeed.
767 bool MimeUtil::MatchesMimeType(const std::string& mime_type_pattern, 767 bool MimeUtil::MatchesMimeType(const std::string& mime_type_pattern,
768 const std::string& mime_type) const { 768 const std::string& mime_type) const {
769 // Verify caller is passing lowercase strings. 769 // Verify caller is passing lowercase strings.
770 DCHECK_EQ(StringToLowerASCII(mime_type_pattern), mime_type_pattern); 770 DCHECK_EQ(base::StringToLowerASCII(mime_type_pattern), mime_type_pattern);
771 DCHECK_EQ(StringToLowerASCII(mime_type), mime_type); 771 DCHECK_EQ(base::StringToLowerASCII(mime_type), mime_type);
772 772
773 if (mime_type_pattern.empty()) 773 if (mime_type_pattern.empty())
774 return false; 774 return false;
775 775
776 std::string::size_type semicolon = mime_type_pattern.find(';'); 776 std::string::size_type semicolon = mime_type_pattern.find(';');
777 const std::string base_pattern(mime_type_pattern.substr(0, semicolon)); 777 const std::string base_pattern(mime_type_pattern.substr(0, semicolon));
778 semicolon = mime_type.find(';'); 778 semicolon = mime_type.find(';');
779 const std::string base_type(mime_type.substr(0, semicolon)); 779 const std::string base_type(mime_type.substr(0, semicolon));
780 780
781 if (base_pattern == "*" || base_pattern == "*/*") 781 if (base_pattern == "*" || base_pattern == "*/*")
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 return false; 831 return false;
832 832
833 if (top_level_type) 833 if (top_level_type)
834 *top_level_type = components[0]; 834 *top_level_type = components[0];
835 if (subtype) 835 if (subtype)
836 *subtype = components[1]; 836 *subtype = components[1];
837 return true; 837 return true;
838 } 838 }
839 839
840 bool MimeUtil::IsValidTopLevelMimeType(const std::string& type_string) const { 840 bool MimeUtil::IsValidTopLevelMimeType(const std::string& type_string) const {
841 std::string lower_type = StringToLowerASCII(type_string); 841 std::string lower_type = base::StringToLowerASCII(type_string);
842 for (size_t i = 0; i < arraysize(legal_top_level_types); ++i) { 842 for (size_t i = 0; i < arraysize(legal_top_level_types); ++i) {
843 if (lower_type.compare(legal_top_level_types[i]) == 0) 843 if (lower_type.compare(legal_top_level_types[i]) == 0)
844 return true; 844 return true;
845 } 845 }
846 846
847 return type_string.size() > 2 && StartsWithASCII(type_string, "x-", false); 847 return type_string.size() > 2 && StartsWithASCII(type_string, "x-", false);
848 } 848 }
849 849
850 bool MimeUtil::AreSupportedMediaCodecs( 850 bool MimeUtil::AreSupportedMediaCodecs(
851 const std::vector<std::string>& codecs) const { 851 const std::vector<std::string>& codecs) const {
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 (*target)[old_target_size + i] = *iter; 1263 (*target)[old_target_size + i] = *iter;
1264 } 1264 }
1265 } 1265 }
1266 1266
1267 void GetExtensionsForMimeType( 1267 void GetExtensionsForMimeType(
1268 const std::string& unsafe_mime_type, 1268 const std::string& unsafe_mime_type,
1269 std::vector<base::FilePath::StringType>* extensions) { 1269 std::vector<base::FilePath::StringType>* extensions) {
1270 if (unsafe_mime_type == "*/*" || unsafe_mime_type == "*") 1270 if (unsafe_mime_type == "*/*" || unsafe_mime_type == "*")
1271 return; 1271 return;
1272 1272
1273 const std::string mime_type = StringToLowerASCII(unsafe_mime_type); 1273 const std::string mime_type = base::StringToLowerASCII(unsafe_mime_type);
1274 base::hash_set<base::FilePath::StringType> unique_extensions; 1274 base::hash_set<base::FilePath::StringType> unique_extensions;
1275 1275
1276 if (EndsWith(mime_type, "/*", true)) { 1276 if (EndsWith(mime_type, "/*", true)) {
1277 std::string leading_mime_type = mime_type.substr(0, mime_type.length() - 1); 1277 std::string leading_mime_type = mime_type.substr(0, mime_type.length() - 1);
1278 1278
1279 // Find the matching StandardType from within kStandardTypes, or fall 1279 // Find the matching StandardType from within kStandardTypes, or fall
1280 // through to the last (default) StandardType. 1280 // through to the last (default) StandardType.
1281 const StandardType* type = NULL; 1281 const StandardType* type = NULL;
1282 for (size_t i = 0; i < arraysize(kStandardTypes); ++i) { 1282 for (size_t i = 0; i < arraysize(kStandardTypes); ++i) {
1283 type = &(kStandardTypes[i]); 1283 type = &(kStandardTypes[i]);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 post_data->append("\r\n" + value + "\r\n"); 1359 post_data->append("\r\n" + value + "\r\n");
1360 } 1360 }
1361 1361
1362 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, 1362 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary,
1363 std::string* post_data) { 1363 std::string* post_data) {
1364 DCHECK(post_data); 1364 DCHECK(post_data);
1365 post_data->append("--" + mime_boundary + "--\r\n"); 1365 post_data->append("--" + mime_boundary + "--\r\n");
1366 } 1366 }
1367 1367
1368 } // namespace net 1368 } // namespace net
OLDNEW
« no previous file with comments | « net/base/host_mapping_rules.cc ('k') | net/base/sdch_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698