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

Side by Side Diff: extensions/browser/api/web_request/web_request_api_helpers.cc

Issue 1282363003: Convert remaining StringToLowerASCII to ToLowerASCII (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « device/hid/hid_service_win.cc ('k') | extensions/browser/extension_registry.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 "extensions/browser/api/web_request/web_request_api_helpers.h" 5 #include "extensions/browser/api/web_request/web_request_api_helpers.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 337
338 if (!new_response_headers) 338 if (!new_response_headers)
339 return result; 339 return result;
340 340
341 // Find deleted headers (header keys are treated case insensitively). 341 // Find deleted headers (header keys are treated case insensitively).
342 { 342 {
343 void* iter = NULL; 343 void* iter = NULL;
344 std::string name; 344 std::string name;
345 std::string value; 345 std::string value;
346 while (old_response_headers->EnumerateHeaderLines(&iter, &name, &value)) { 346 while (old_response_headers->EnumerateHeaderLines(&iter, &name, &value)) {
347 std::string name_lowercase(name); 347 std::string name_lowercase = base::ToLowerASCII(name);
348 base::StringToLowerASCII(&name_lowercase);
349 348
350 bool header_found = false; 349 bool header_found = false;
351 for (ResponseHeaders::const_iterator i = new_response_headers->begin(); 350 for (const auto& i : *new_response_headers) {
352 i != new_response_headers->end(); ++i) { 351 if (base::LowerCaseEqualsASCII(i.first, name_lowercase) &&
353 if (base::LowerCaseEqualsASCII(i->first, name_lowercase.c_str()) && 352 value == i.second) {
354 value == i->second) {
355 header_found = true; 353 header_found = true;
356 break; 354 break;
357 } 355 }
358 } 356 }
359 if (!header_found) 357 if (!header_found)
360 result->deleted_response_headers.push_back(ResponseHeader(name, value)); 358 result->deleted_response_headers.push_back(ResponseHeader(name, value));
361 } 359 }
362 } 360 }
363 361
364 // Find added headers (header keys are treated case insensitively). 362 // Find added headers (header keys are treated case insensitively).
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 modified |= MergeEditResponseCookieModifications(deltas, &cookies); 1010 modified |= MergeEditResponseCookieModifications(deltas, &cookies);
1013 modified |= MergeRemoveResponseCookieModifications(deltas, &cookies); 1011 modified |= MergeRemoveResponseCookieModifications(deltas, &cookies);
1014 1012
1015 // Store new value. 1013 // Store new value.
1016 if (modified) 1014 if (modified)
1017 StoreResponseCookies(cookies, *override_response_headers); 1015 StoreResponseCookies(cookies, *override_response_headers);
1018 } 1016 }
1019 1017
1020 // Converts the key of the (key, value) pair to lower case. 1018 // Converts the key of the (key, value) pair to lower case.
1021 static ResponseHeader ToLowerCase(const ResponseHeader& header) { 1019 static ResponseHeader ToLowerCase(const ResponseHeader& header) {
1022 std::string lower_key(header.first); 1020 return ResponseHeader(base::ToLowerASCII(header.first), header.second);
1023 base::StringToLowerASCII(&lower_key);
1024 return ResponseHeader(lower_key, header.second);
1025 } 1021 }
1026 1022
1027 // Returns the extension ID of the first extension in |deltas| that removes the 1023 // Returns the extension ID of the first extension in |deltas| that removes the
1028 // request header identified by |key|. 1024 // request header identified by |key|.
1029 static std::string FindRemoveResponseHeader( 1025 static std::string FindRemoveResponseHeader(
1030 const EventResponseDeltas& deltas, 1026 const EventResponseDeltas& deltas,
1031 const std::string& key) { 1027 const std::string& key) {
1032 std::string lower_key = base::StringToLowerASCII(key); 1028 std::string lower_key = base::ToLowerASCII(key);
1033 EventResponseDeltas::const_iterator delta; 1029 for (const auto& delta : deltas) {
1034 for (delta = deltas.begin(); delta != deltas.end(); ++delta) { 1030 for (const auto& deleted_hdr : delta->deleted_response_headers) {
1035 ResponseHeaders::const_iterator i; 1031 if (base::ToLowerASCII(deleted_hdr.first) == lower_key)
1036 for (i = (*delta)->deleted_response_headers.begin(); 1032 return delta->extension_id;
1037 i != (*delta)->deleted_response_headers.end(); ++i) {
1038 if (base::StringToLowerASCII(i->first) == lower_key)
1039 return (*delta)->extension_id;
1040 } 1033 }
1041 } 1034 }
1042 return std::string(); 1035 return std::string();
1043 } 1036 }
1044 1037
1045 void MergeOnHeadersReceivedResponses( 1038 void MergeOnHeadersReceivedResponses(
1046 const EventResponseDeltas& deltas, 1039 const EventResponseDeltas& deltas,
1047 const net::HttpResponseHeaders* original_response_headers, 1040 const net::HttpResponseHeaders* original_response_headers,
1048 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, 1041 scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
1049 GURL* allowed_unsafe_redirect_url, 1042 GURL* allowed_unsafe_redirect_url,
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 std::find(kResourceTypeStrings, 1272 std::find(kResourceTypeStrings,
1280 kResourceTypeStrings + kResourceTypeStringsLength, 1273 kResourceTypeStrings + kResourceTypeStringsLength,
1281 type_str); 1274 type_str);
1282 if (iter == (kResourceTypeStrings + kResourceTypeStringsLength)) 1275 if (iter == (kResourceTypeStrings + kResourceTypeStringsLength))
1283 return false; 1276 return false;
1284 *type = kResourceTypeValues[iter - kResourceTypeStrings]; 1277 *type = kResourceTypeValues[iter - kResourceTypeStrings];
1285 return true; 1278 return true;
1286 } 1279 }
1287 1280
1288 } // namespace extension_web_request_api_helpers 1281 } // namespace extension_web_request_api_helpers
OLDNEW
« no previous file with comments | « device/hid/hid_service_win.cc ('k') | extensions/browser/extension_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698