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

Unified Diff: chrome/browser/extensions/api/web_request/web_request_api.cc

Issue 154473002: Support redirectUrl at onHeadersReceived in WebRequest / DWR API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass allowed_unsafe_redirect_url via delegate parameter instead of HttpResponseHeaders + fragment t… Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/web_request/web_request_api.cc
diff --git a/chrome/browser/extensions/api/web_request/web_request_api.cc b/chrome/browser/extensions/api/web_request/web_request_api.cc
index cb7a821dcdbc4f0e811d3cef0c8df2d7af90fcd4..d73b1d8a292155f7e2a42a45ad34d59e1ce0769b 100644
--- a/chrome/browser/extensions/api/web_request/web_request_api.cc
+++ b/chrome/browser/extensions/api/web_request/web_request_api.cc
@@ -495,7 +495,7 @@ struct ExtensionWebRequestEventRouter::BlockedRequest {
net::CompletionCallback callback;
// If non-empty, this contains the new URL that the request will redirect to.
- // Only valid for OnBeforeRequest.
+ // Only valid for OnBeforeRequest and OnHeadersReceived.
GURL* new_url;
// The request headers that will be issued along with this request. Only valid
@@ -828,7 +828,8 @@ int ExtensionWebRequestEventRouter::OnHeadersReceived(
net::URLRequest* request,
const net::CompletionCallback& callback,
const net::HttpResponseHeaders* original_response_headers,
- scoped_refptr<net::HttpResponseHeaders>* override_response_headers) {
+ scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
+ GURL* allowed_unsafe_redirect_url) {
// We hide events from the system context as well as sensitive requests.
if (!profile ||
WebRequestPermissions::HideRequest(extension_info_map, request))
@@ -878,6 +879,8 @@ int ExtensionWebRequestEventRouter::OnHeadersReceived(
override_response_headers;
blocked_requests_[request->identifier()].original_response_headers =
original_response_headers;
+ blocked_requests_[request->identifier()].new_url =
+ allowed_unsafe_redirect_url;
if (blocked_requests_[request->identifier()].num_handlers_blocking == 0) {
// If there are no blocking handlers, only the declarative rules tried
@@ -1555,7 +1558,7 @@ helpers::EventResponseDelta* CalculateDelta(
response->response_headers.get();
return helpers::CalculateOnHeadersReceivedDelta(
response->extension_id, response->extension_install_time,
- response->cancel, old_headers, new_headers);
+ response->cancel, response->new_url, old_headers, new_headers);
}
case ExtensionWebRequestEventRouter::kOnAuthRequired:
return helpers::CalculateOnAuthRequiredDelta(
@@ -1845,6 +1848,7 @@ int ExtensionWebRequestEventRouter::ExecuteDeltas(
blocked_request.response_deltas,
blocked_request.original_response_headers.get(),
blocked_request.override_response_headers,
+ blocked_request.new_url,
&warnings,
blocked_request.net_log);
} else if (blocked_request.event == kOnAuthRequired) {

Powered by Google App Engine
This is Rietveld 408576698