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 "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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
354 break; | 354 break; |
355 } | 355 } |
356 } | 356 } |
357 if (!header_found) | 357 if (!header_found) |
358 result->deleted_response_headers.push_back(ResponseHeader(name, value)); | 358 result->deleted_response_headers.push_back(ResponseHeader(name, value)); |
359 } | 359 } |
360 } | 360 } |
361 | 361 |
362 // Find added headers (header keys are treated case insensitively). | 362 // Find added headers (header keys are treated case insensitively). |
363 { | 363 { |
364 for (ResponseHeaders::const_iterator i = new_response_headers->begin(); | 364 for (const auto& i : *new_response_headers) { |
365 i != new_response_headers->end(); ++i) { | 365 std::string name_lowercase = base::ToLowerASCII(i.first); |
366 void* iter = NULL; | 366 void* iter = nullptr; |
not at google - send to devlin
2015/09/08 22:55:34
I presume you don't need |iter| for anything?
robwu
2015/09/08 23:00:21
iter is just used to keep track of the header iter
| |
367 std::string name; | |
367 std::string value; | 368 std::string value; |
368 bool header_found = false; | 369 bool header_found = false; |
369 while (old_response_headers->EnumerateHeader(&iter, i->first, &value) && | 370 while (old_response_headers->EnumerateHeaderLines(&iter, &name, &value)) { |
370 !header_found) { | 371 if (base::LowerCaseEqualsASCII(name, name_lowercase) && |
not at google - send to devlin
2015/09/08 22:55:34
Seems like you could use EqualsCaseInsensitiveASCI
robwu
2015/09/08 23:00:20
Possibly, but transforming once to lowercase and s
| |
371 header_found = (value == i->second); | 372 value == i.second) { |
373 header_found = true; | |
374 break; | |
375 } | |
372 } | 376 } |
373 if (!header_found) | 377 if (!header_found) |
374 result->added_response_headers.push_back(*i); | 378 result->added_response_headers.push_back(i); |
375 } | 379 } |
376 } | 380 } |
377 | 381 |
378 return result; | 382 return result; |
379 } | 383 } |
380 | 384 |
381 EventResponseDelta* CalculateOnAuthRequiredDelta( | 385 EventResponseDelta* CalculateOnAuthRequiredDelta( |
382 const std::string& extension_id, | 386 const std::string& extension_id, |
383 const base::Time& extension_install_time, | 387 const base::Time& extension_install_time, |
384 bool cancel, | 388 bool cancel, |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1272 std::find(kResourceTypeStrings, | 1276 std::find(kResourceTypeStrings, |
1273 kResourceTypeStrings + kResourceTypeStringsLength, | 1277 kResourceTypeStrings + kResourceTypeStringsLength, |
1274 type_str); | 1278 type_str); |
1275 if (iter == (kResourceTypeStrings + kResourceTypeStringsLength)) | 1279 if (iter == (kResourceTypeStrings + kResourceTypeStringsLength)) |
1276 return false; | 1280 return false; |
1277 *type = kResourceTypeValues[iter - kResourceTypeStrings]; | 1281 *type = kResourceTypeValues[iter - kResourceTypeStrings]; |
1278 return true; | 1282 return true; |
1279 } | 1283 } |
1280 | 1284 |
1281 } // namespace extension_web_request_api_helpers | 1285 } // namespace extension_web_request_api_helpers |
OLD | NEW |