| 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 "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" | 5 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 16 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| 17 #include "chrome/browser/extensions/extension_warning_set.h" | |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/browser/renderer_host/web_cache_manager.h" | 18 #include "chrome/browser/renderer_host/web_cache_manager.h" |
| 20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
| 22 #include "extensions/browser/extension_system.h" | 21 #include "extensions/browser/extension_system.h" |
| 23 #include "extensions/browser/runtime_data.h" | 22 #include "extensions/browser/runtime_data.h" |
| 23 #include "extensions/browser/warning_set.h" |
| 24 #include "net/base/net_log.h" | 24 #include "net/base/net_log.h" |
| 25 #include "net/cookies/cookie_util.h" | 25 #include "net/cookies/cookie_util.h" |
| 26 #include "net/cookies/parsed_cookie.h" | 26 #include "net/cookies/parsed_cookie.h" |
| 27 #include "net/http/http_util.h" | 27 #include "net/http/http_util.h" |
| 28 #include "net/url_request/url_request.h" | 28 #include "net/url_request/url_request.h" |
| 29 #include "url/url_constants.h" | 29 #include "url/url_constants.h" |
| 30 | 30 |
| 31 // TODO(battre): move all static functions into an anonymous namespace at the | 31 // TODO(battre): move all static functions into an anonymous namespace at the |
| 32 // top of this file. | 32 // top of this file. |
| 33 | 33 |
| 34 using base::Time; | 34 using base::Time; |
| 35 using content::ResourceType; | 35 using content::ResourceType; |
| 36 using extensions::ExtensionWarning; | |
| 37 using net::cookie_util::ParsedRequestCookie; | 36 using net::cookie_util::ParsedRequestCookie; |
| 38 using net::cookie_util::ParsedRequestCookies; | 37 using net::cookie_util::ParsedRequestCookies; |
| 39 | 38 |
| 40 namespace extension_web_request_api_helpers { | 39 namespace extension_web_request_api_helpers { |
| 41 | 40 |
| 42 namespace { | 41 namespace { |
| 43 | 42 |
| 44 typedef std::vector<linked_ptr<net::ParsedCookie> > ParsedResponseCookies; | 43 typedef std::vector<linked_ptr<net::ParsedCookie> > ParsedResponseCookies; |
| 45 | 44 |
| 46 static const char* kResourceTypeStrings[] = { | 45 static const char* kResourceTypeStrings[] = { |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 // Helper function for MergeRedirectUrlOfResponses() that allows ignoring | 407 // Helper function for MergeRedirectUrlOfResponses() that allows ignoring |
| 409 // all redirects but those to data:// urls and about:blank. This is important | 408 // all redirects but those to data:// urls and about:blank. This is important |
| 410 // to treat these URLs as "cancel urls", i.e. URLs that extensions redirect | 409 // to treat these URLs as "cancel urls", i.e. URLs that extensions redirect |
| 411 // to if they want to express that they want to cancel a request. This reduces | 410 // to if they want to express that they want to cancel a request. This reduces |
| 412 // the number of conflicts that we need to flag, as canceling is considered | 411 // the number of conflicts that we need to flag, as canceling is considered |
| 413 // a higher precedence operation that redirects. | 412 // a higher precedence operation that redirects. |
| 414 // Returns whether a redirect occurred. | 413 // Returns whether a redirect occurred. |
| 415 static bool MergeRedirectUrlOfResponsesHelper( | 414 static bool MergeRedirectUrlOfResponsesHelper( |
| 416 const EventResponseDeltas& deltas, | 415 const EventResponseDeltas& deltas, |
| 417 GURL* new_url, | 416 GURL* new_url, |
| 418 extensions::ExtensionWarningSet* conflicting_extensions, | 417 extensions::WarningSet* conflicting_extensions, |
| 419 const net::BoundNetLog* net_log, | 418 const net::BoundNetLog* net_log, |
| 420 bool consider_only_cancel_scheme_urls) { | 419 bool consider_only_cancel_scheme_urls) { |
| 421 bool redirected = false; | 420 bool redirected = false; |
| 422 | 421 |
| 423 // Extension that determines the |new_url|. | 422 // Extension that determines the |new_url|. |
| 424 std::string winning_extension_id; | 423 std::string winning_extension_id; |
| 425 EventResponseDeltas::const_iterator delta; | 424 EventResponseDeltas::const_iterator delta; |
| 426 for (delta = deltas.begin(); delta != deltas.end(); ++delta) { | 425 for (delta = deltas.begin(); delta != deltas.end(); ++delta) { |
| 427 if ((*delta)->new_url.is_empty()) | 426 if ((*delta)->new_url.is_empty()) |
| 428 continue; | 427 continue; |
| 429 if (consider_only_cancel_scheme_urls && | 428 if (consider_only_cancel_scheme_urls && |
| 430 !(*delta)->new_url.SchemeIs(url::kDataScheme) && | 429 !(*delta)->new_url.SchemeIs(url::kDataScheme) && |
| 431 (*delta)->new_url.spec() != "about:blank") { | 430 (*delta)->new_url.spec() != "about:blank") { |
| 432 continue; | 431 continue; |
| 433 } | 432 } |
| 434 | 433 |
| 435 if (!redirected || *new_url == (*delta)->new_url) { | 434 if (!redirected || *new_url == (*delta)->new_url) { |
| 436 *new_url = (*delta)->new_url; | 435 *new_url = (*delta)->new_url; |
| 437 winning_extension_id = (*delta)->extension_id; | 436 winning_extension_id = (*delta)->extension_id; |
| 438 redirected = true; | 437 redirected = true; |
| 439 net_log->AddEvent( | 438 net_log->AddEvent( |
| 440 net::NetLog::TYPE_CHROME_EXTENSION_REDIRECTED_REQUEST, | 439 net::NetLog::TYPE_CHROME_EXTENSION_REDIRECTED_REQUEST, |
| 441 CreateNetLogExtensionIdCallback(delta->get())); | 440 CreateNetLogExtensionIdCallback(delta->get())); |
| 442 } else { | 441 } else { |
| 443 conflicting_extensions->insert( | 442 conflicting_extensions->insert( |
| 444 ExtensionWarning::CreateRedirectConflictWarning( | 443 extensions::Warning::CreateRedirectConflictWarning( |
| 445 (*delta)->extension_id, | 444 (*delta)->extension_id, |
| 446 winning_extension_id, | 445 winning_extension_id, |
| 447 (*delta)->new_url, | 446 (*delta)->new_url, |
| 448 *new_url)); | 447 *new_url)); |
| 449 net_log->AddEvent( | 448 net_log->AddEvent( |
| 450 net::NetLog::TYPE_CHROME_EXTENSION_IGNORED_DUE_TO_CONFLICT, | 449 net::NetLog::TYPE_CHROME_EXTENSION_IGNORED_DUE_TO_CONFLICT, |
| 451 CreateNetLogExtensionIdCallback(delta->get())); | 450 CreateNetLogExtensionIdCallback(delta->get())); |
| 452 } | 451 } |
| 453 } | 452 } |
| 454 return redirected; | 453 return redirected; |
| 455 } | 454 } |
| 456 | 455 |
| 457 void MergeRedirectUrlOfResponses( | 456 void MergeRedirectUrlOfResponses( |
| 458 const EventResponseDeltas& deltas, | 457 const EventResponseDeltas& deltas, |
| 459 GURL* new_url, | 458 GURL* new_url, |
| 460 extensions::ExtensionWarningSet* conflicting_extensions, | 459 extensions::WarningSet* conflicting_extensions, |
| 461 const net::BoundNetLog* net_log) { | 460 const net::BoundNetLog* net_log) { |
| 462 | 461 |
| 463 // First handle only redirects to data:// URLs and about:blank. These are a | 462 // First handle only redirects to data:// URLs and about:blank. These are a |
| 464 // special case as they represent a way of cancelling a request. | 463 // special case as they represent a way of cancelling a request. |
| 465 if (MergeRedirectUrlOfResponsesHelper( | 464 if (MergeRedirectUrlOfResponsesHelper( |
| 466 deltas, new_url, conflicting_extensions, net_log, true)) { | 465 deltas, new_url, conflicting_extensions, net_log, true)) { |
| 467 // If any extension cancelled a request by redirecting to a data:// URL or | 466 // If any extension cancelled a request by redirecting to a data:// URL or |
| 468 // about:blank, we don't consider the other redirects. | 467 // about:blank, we don't consider the other redirects. |
| 469 return; | 468 return; |
| 470 } | 469 } |
| 471 | 470 |
| 472 // Handle all other redirects. | 471 // Handle all other redirects. |
| 473 MergeRedirectUrlOfResponsesHelper( | 472 MergeRedirectUrlOfResponsesHelper( |
| 474 deltas, new_url, conflicting_extensions, net_log, false); | 473 deltas, new_url, conflicting_extensions, net_log, false); |
| 475 } | 474 } |
| 476 | 475 |
| 477 void MergeOnBeforeRequestResponses( | 476 void MergeOnBeforeRequestResponses( |
| 478 const EventResponseDeltas& deltas, | 477 const EventResponseDeltas& deltas, |
| 479 GURL* new_url, | 478 GURL* new_url, |
| 480 extensions::ExtensionWarningSet* conflicting_extensions, | 479 extensions::WarningSet* conflicting_extensions, |
| 481 const net::BoundNetLog* net_log) { | 480 const net::BoundNetLog* net_log) { |
| 482 MergeRedirectUrlOfResponses(deltas, new_url, conflicting_extensions, net_log); | 481 MergeRedirectUrlOfResponses(deltas, new_url, conflicting_extensions, net_log); |
| 483 } | 482 } |
| 484 | 483 |
| 485 static bool DoesRequestCookieMatchFilter( | 484 static bool DoesRequestCookieMatchFilter( |
| 486 const ParsedRequestCookie& cookie, | 485 const ParsedRequestCookie& cookie, |
| 487 RequestCookie* filter) { | 486 RequestCookie* filter) { |
| 488 if (!filter) return true; | 487 if (!filter) return true; |
| 489 if (filter->name.get() && cookie.first != *filter->name) return false; | 488 if (filter->name.get() && cookie.first != *filter->name) return false; |
| 490 if (filter->value.get() && cookie.second != *filter->value) return false; | 489 if (filter->value.get() && cookie.second != *filter->value) return false; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 } | 595 } |
| 597 } | 596 } |
| 598 } | 597 } |
| 599 } | 598 } |
| 600 return modified; | 599 return modified; |
| 601 } | 600 } |
| 602 | 601 |
| 603 void MergeCookiesInOnBeforeSendHeadersResponses( | 602 void MergeCookiesInOnBeforeSendHeadersResponses( |
| 604 const EventResponseDeltas& deltas, | 603 const EventResponseDeltas& deltas, |
| 605 net::HttpRequestHeaders* request_headers, | 604 net::HttpRequestHeaders* request_headers, |
| 606 extensions::ExtensionWarningSet* conflicting_extensions, | 605 extensions::WarningSet* conflicting_extensions, |
| 607 const net::BoundNetLog* net_log) { | 606 const net::BoundNetLog* net_log) { |
| 608 // Skip all work if there are no registered cookie modifications. | 607 // Skip all work if there are no registered cookie modifications. |
| 609 bool cookie_modifications_exist = false; | 608 bool cookie_modifications_exist = false; |
| 610 EventResponseDeltas::const_iterator delta; | 609 EventResponseDeltas::const_iterator delta; |
| 611 for (delta = deltas.begin(); delta != deltas.end(); ++delta) { | 610 for (delta = deltas.begin(); delta != deltas.end(); ++delta) { |
| 612 cookie_modifications_exist |= | 611 cookie_modifications_exist |= |
| 613 !(*delta)->request_cookie_modifications.empty(); | 612 !(*delta)->request_cookie_modifications.empty(); |
| 614 } | 613 } |
| 615 if (!cookie_modifications_exist) | 614 if (!cookie_modifications_exist) |
| 616 return; | 615 return; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 if (*i == key) | 667 if (*i == key) |
| 669 return (*delta)->extension_id; | 668 return (*delta)->extension_id; |
| 670 } | 669 } |
| 671 } | 670 } |
| 672 return std::string(); | 671 return std::string(); |
| 673 } | 672 } |
| 674 | 673 |
| 675 void MergeOnBeforeSendHeadersResponses( | 674 void MergeOnBeforeSendHeadersResponses( |
| 676 const EventResponseDeltas& deltas, | 675 const EventResponseDeltas& deltas, |
| 677 net::HttpRequestHeaders* request_headers, | 676 net::HttpRequestHeaders* request_headers, |
| 678 extensions::ExtensionWarningSet* conflicting_extensions, | 677 extensions::WarningSet* conflicting_extensions, |
| 679 const net::BoundNetLog* net_log) { | 678 const net::BoundNetLog* net_log) { |
| 680 EventResponseDeltas::const_iterator delta; | 679 EventResponseDeltas::const_iterator delta; |
| 681 | 680 |
| 682 // Here we collect which headers we have removed or set to new values | 681 // Here we collect which headers we have removed or set to new values |
| 683 // so far due to extensions of higher precedence. | 682 // so far due to extensions of higher precedence. |
| 684 std::set<std::string> removed_headers; | 683 std::set<std::string> removed_headers; |
| 685 std::set<std::string> set_headers; | 684 std::set<std::string> set_headers; |
| 686 | 685 |
| 687 // We assume here that the deltas are sorted in decreasing extension | 686 // We assume here that the deltas are sorted in decreasing extension |
| 688 // precedence (i.e. decreasing extension installation time). | 687 // precedence (i.e. decreasing extension installation time). |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 ++key) { | 768 ++key) { |
| 770 request_headers->RemoveHeader(*key); | 769 request_headers->RemoveHeader(*key); |
| 771 removed_headers.insert(*key); | 770 removed_headers.insert(*key); |
| 772 } | 771 } |
| 773 } | 772 } |
| 774 net_log->AddEvent( | 773 net_log->AddEvent( |
| 775 net::NetLog::TYPE_CHROME_EXTENSION_MODIFIED_HEADERS, | 774 net::NetLog::TYPE_CHROME_EXTENSION_MODIFIED_HEADERS, |
| 776 base::Bind(&NetLogModificationCallback, delta->get())); | 775 base::Bind(&NetLogModificationCallback, delta->get())); |
| 777 } else { | 776 } else { |
| 778 conflicting_extensions->insert( | 777 conflicting_extensions->insert( |
| 779 ExtensionWarning::CreateRequestHeaderConflictWarning( | 778 extensions::Warning::CreateRequestHeaderConflictWarning( |
| 780 (*delta)->extension_id, winning_extension_id, | 779 (*delta)->extension_id, winning_extension_id, |
| 781 conflicting_header)); | 780 conflicting_header)); |
| 782 net_log->AddEvent( | 781 net_log->AddEvent( |
| 783 net::NetLog::TYPE_CHROME_EXTENSION_IGNORED_DUE_TO_CONFLICT, | 782 net::NetLog::TYPE_CHROME_EXTENSION_IGNORED_DUE_TO_CONFLICT, |
| 784 CreateNetLogExtensionIdCallback(delta->get())); | 783 CreateNetLogExtensionIdCallback(delta->get())); |
| 785 } | 784 } |
| 786 } | 785 } |
| 787 | 786 |
| 788 MergeCookiesInOnBeforeSendHeadersResponses(deltas, request_headers, | 787 MergeCookiesInOnBeforeSendHeadersResponses(deltas, request_headers, |
| 789 conflicting_extensions, net_log); | 788 conflicting_extensions, net_log); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 } | 975 } |
| 977 } | 976 } |
| 978 } | 977 } |
| 979 return modified; | 978 return modified; |
| 980 } | 979 } |
| 981 | 980 |
| 982 void MergeCookiesInOnHeadersReceivedResponses( | 981 void MergeCookiesInOnHeadersReceivedResponses( |
| 983 const EventResponseDeltas& deltas, | 982 const EventResponseDeltas& deltas, |
| 984 const net::HttpResponseHeaders* original_response_headers, | 983 const net::HttpResponseHeaders* original_response_headers, |
| 985 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, | 984 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, |
| 986 extensions::ExtensionWarningSet* conflicting_extensions, | 985 extensions::WarningSet* conflicting_extensions, |
| 987 const net::BoundNetLog* net_log) { | 986 const net::BoundNetLog* net_log) { |
| 988 // Skip all work if there are no registered cookie modifications. | 987 // Skip all work if there are no registered cookie modifications. |
| 989 bool cookie_modifications_exist = false; | 988 bool cookie_modifications_exist = false; |
| 990 EventResponseDeltas::const_reverse_iterator delta; | 989 EventResponseDeltas::const_reverse_iterator delta; |
| 991 for (delta = deltas.rbegin(); delta != deltas.rend(); ++delta) { | 990 for (delta = deltas.rbegin(); delta != deltas.rend(); ++delta) { |
| 992 cookie_modifications_exist |= | 991 cookie_modifications_exist |= |
| 993 !(*delta)->response_cookie_modifications.empty(); | 992 !(*delta)->response_cookie_modifications.empty(); |
| 994 } | 993 } |
| 995 if (!cookie_modifications_exist) | 994 if (!cookie_modifications_exist) |
| 996 return; | 995 return; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 } | 1036 } |
| 1038 } | 1037 } |
| 1039 return std::string(); | 1038 return std::string(); |
| 1040 } | 1039 } |
| 1041 | 1040 |
| 1042 void MergeOnHeadersReceivedResponses( | 1041 void MergeOnHeadersReceivedResponses( |
| 1043 const EventResponseDeltas& deltas, | 1042 const EventResponseDeltas& deltas, |
| 1044 const net::HttpResponseHeaders* original_response_headers, | 1043 const net::HttpResponseHeaders* original_response_headers, |
| 1045 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, | 1044 scoped_refptr<net::HttpResponseHeaders>* override_response_headers, |
| 1046 GURL* allowed_unsafe_redirect_url, | 1045 GURL* allowed_unsafe_redirect_url, |
| 1047 extensions::ExtensionWarningSet* conflicting_extensions, | 1046 extensions::WarningSet* conflicting_extensions, |
| 1048 const net::BoundNetLog* net_log) { | 1047 const net::BoundNetLog* net_log) { |
| 1049 EventResponseDeltas::const_iterator delta; | 1048 EventResponseDeltas::const_iterator delta; |
| 1050 | 1049 |
| 1051 // Here we collect which headers we have removed or added so far due to | 1050 // Here we collect which headers we have removed or added so far due to |
| 1052 // extensions of higher precedence. Header keys are always stored as | 1051 // extensions of higher precedence. Header keys are always stored as |
| 1053 // lower case. | 1052 // lower case. |
| 1054 std::set<ResponseHeader> removed_headers; | 1053 std::set<ResponseHeader> removed_headers; |
| 1055 std::set<ResponseHeader> added_headers; | 1054 std::set<ResponseHeader> added_headers; |
| 1056 | 1055 |
| 1057 // We assume here that the deltas are sorted in decreasing extension | 1056 // We assume here that the deltas are sorted in decreasing extension |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 continue; | 1106 continue; |
| 1108 added_headers.insert(lowercase_header); | 1107 added_headers.insert(lowercase_header); |
| 1109 (*override_response_headers)->AddHeader(i->first + ": " + i->second); | 1108 (*override_response_headers)->AddHeader(i->first + ": " + i->second); |
| 1110 } | 1109 } |
| 1111 } | 1110 } |
| 1112 net_log->AddEvent( | 1111 net_log->AddEvent( |
| 1113 net::NetLog::TYPE_CHROME_EXTENSION_MODIFIED_HEADERS, | 1112 net::NetLog::TYPE_CHROME_EXTENSION_MODIFIED_HEADERS, |
| 1114 CreateNetLogExtensionIdCallback(delta->get())); | 1113 CreateNetLogExtensionIdCallback(delta->get())); |
| 1115 } else { | 1114 } else { |
| 1116 conflicting_extensions->insert( | 1115 conflicting_extensions->insert( |
| 1117 ExtensionWarning::CreateResponseHeaderConflictWarning( | 1116 extensions::Warning::CreateResponseHeaderConflictWarning( |
| 1118 (*delta)->extension_id, winning_extension_id, | 1117 (*delta)->extension_id, winning_extension_id, |
| 1119 conflicting_header)); | 1118 conflicting_header)); |
| 1120 net_log->AddEvent( | 1119 net_log->AddEvent( |
| 1121 net::NetLog::TYPE_CHROME_EXTENSION_IGNORED_DUE_TO_CONFLICT, | 1120 net::NetLog::TYPE_CHROME_EXTENSION_IGNORED_DUE_TO_CONFLICT, |
| 1122 CreateNetLogExtensionIdCallback(delta->get())); | 1121 CreateNetLogExtensionIdCallback(delta->get())); |
| 1123 } | 1122 } |
| 1124 } | 1123 } |
| 1125 | 1124 |
| 1126 MergeCookiesInOnHeadersReceivedResponses(deltas, original_response_headers, | 1125 MergeCookiesInOnHeadersReceivedResponses(deltas, original_response_headers, |
| 1127 override_response_headers, conflicting_extensions, net_log); | 1126 override_response_headers, conflicting_extensions, net_log); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1140 (*override_response_headers)->AddHeader("Location: " + new_url.spec()); | 1139 (*override_response_headers)->AddHeader("Location: " + new_url.spec()); |
| 1141 // Explicitly mark the URL as safe for redirection, to prevent the request | 1140 // Explicitly mark the URL as safe for redirection, to prevent the request |
| 1142 // from being blocked because of net::ERR_UNSAFE_REDIRECT. | 1141 // from being blocked because of net::ERR_UNSAFE_REDIRECT. |
| 1143 *allowed_unsafe_redirect_url = new_url; | 1142 *allowed_unsafe_redirect_url = new_url; |
| 1144 } | 1143 } |
| 1145 } | 1144 } |
| 1146 | 1145 |
| 1147 bool MergeOnAuthRequiredResponses( | 1146 bool MergeOnAuthRequiredResponses( |
| 1148 const EventResponseDeltas& deltas, | 1147 const EventResponseDeltas& deltas, |
| 1149 net::AuthCredentials* auth_credentials, | 1148 net::AuthCredentials* auth_credentials, |
| 1150 extensions::ExtensionWarningSet* conflicting_extensions, | 1149 extensions::WarningSet* conflicting_extensions, |
| 1151 const net::BoundNetLog* net_log) { | 1150 const net::BoundNetLog* net_log) { |
| 1152 CHECK(auth_credentials); | 1151 CHECK(auth_credentials); |
| 1153 bool credentials_set = false; | 1152 bool credentials_set = false; |
| 1154 std::string winning_extension_id; | 1153 std::string winning_extension_id; |
| 1155 | 1154 |
| 1156 for (EventResponseDeltas::const_iterator delta = deltas.begin(); | 1155 for (EventResponseDeltas::const_iterator delta = deltas.begin(); |
| 1157 delta != deltas.end(); | 1156 delta != deltas.end(); |
| 1158 ++delta) { | 1157 ++delta) { |
| 1159 if (!(*delta)->auth_credentials.get()) | 1158 if (!(*delta)->auth_credentials.get()) |
| 1160 continue; | 1159 continue; |
| 1161 bool different = | 1160 bool different = |
| 1162 auth_credentials->username() != | 1161 auth_credentials->username() != |
| 1163 (*delta)->auth_credentials->username() || | 1162 (*delta)->auth_credentials->username() || |
| 1164 auth_credentials->password() != (*delta)->auth_credentials->password(); | 1163 auth_credentials->password() != (*delta)->auth_credentials->password(); |
| 1165 if (credentials_set && different) { | 1164 if (credentials_set && different) { |
| 1166 conflicting_extensions->insert( | 1165 conflicting_extensions->insert( |
| 1167 ExtensionWarning::CreateCredentialsConflictWarning( | 1166 extensions::Warning::CreateCredentialsConflictWarning( |
| 1168 (*delta)->extension_id, winning_extension_id)); | 1167 (*delta)->extension_id, winning_extension_id)); |
| 1169 net_log->AddEvent( | 1168 net_log->AddEvent( |
| 1170 net::NetLog::TYPE_CHROME_EXTENSION_IGNORED_DUE_TO_CONFLICT, | 1169 net::NetLog::TYPE_CHROME_EXTENSION_IGNORED_DUE_TO_CONFLICT, |
| 1171 CreateNetLogExtensionIdCallback(delta->get())); | 1170 CreateNetLogExtensionIdCallback(delta->get())); |
| 1172 } else { | 1171 } else { |
| 1173 net_log->AddEvent( | 1172 net_log->AddEvent( |
| 1174 net::NetLog::TYPE_CHROME_EXTENSION_PROVIDE_AUTH_CREDENTIALS, | 1173 net::NetLog::TYPE_CHROME_EXTENSION_PROVIDE_AUTH_CREDENTIALS, |
| 1175 CreateNetLogExtensionIdCallback(delta->get())); | 1174 CreateNetLogExtensionIdCallback(delta->get())); |
| 1176 *auth_credentials = *(*delta)->auth_credentials; | 1175 *auth_credentials = *(*delta)->auth_credentials; |
| 1177 credentials_set = true; | 1176 credentials_set = true; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 for (content::RenderProcessHost::iterator it = | 1235 for (content::RenderProcessHost::iterator it = |
| 1237 content::RenderProcessHost::AllHostsIterator(); | 1236 content::RenderProcessHost::AllHostsIterator(); |
| 1238 !it.IsAtEnd(); it.Advance()) { | 1237 !it.IsAtEnd(); it.Advance()) { |
| 1239 content::RenderProcessHost* host = it.GetCurrentValue(); | 1238 content::RenderProcessHost* host = it.GetCurrentValue(); |
| 1240 if (host->GetBrowserContext() == browser_context) | 1239 if (host->GetBrowserContext() == browser_context) |
| 1241 SendExtensionWebRequestStatusToHost(host); | 1240 SendExtensionWebRequestStatusToHost(host); |
| 1242 } | 1241 } |
| 1243 } | 1242 } |
| 1244 | 1243 |
| 1245 } // namespace extension_web_request_api_helpers | 1244 } // namespace extension_web_request_api_helpers |
| OLD | NEW |