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

Unified Diff: content/browser/frame_host/navigation_request.cc

Issue 1416953007: Add a function to add extra headers from NavigationThrottle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data-reduction-proxy-resource-throttle
Patch Set: Fixed compilation issue Created 5 years, 1 month 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: content/browser/frame_host/navigation_request.cc
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc
index 0fa8adf29875200f0874ae8ff90e031f309a41ae..a1e067f69abba2a233089877340ece84226efea1 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -7,7 +7,6 @@
#include "content/browser/frame_host/frame_tree.h"
#include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/frame_host/navigation_controller_impl.h"
-#include "content/browser/frame_host/navigation_handle_impl.h"
#include "content/browser/frame_host/navigation_request_info.h"
#include "content/browser/frame_host/navigator.h"
#include "content/browser/loader/navigation_url_loader.h"
@@ -284,7 +283,8 @@ void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) {
}
void NavigationRequest::OnStartChecksComplete(
- NavigationThrottle::ThrottleCheckResult result) {
+ NavigationThrottle::ThrottleCheckResult result,
+ const NavigationHandleImpl::ExtraHeadersList& extra_headers_list) {
CHECK(result != NavigationThrottle::DEFER);
// Abort the request if needed. This will destroy the NavigationRequest.
@@ -295,13 +295,22 @@ void NavigationRequest::OnStartChecksComplete(
return;
}
+ // Add extra headers to the request before sending it to the network stack.
+ net::HttpRequestHeaders headers;
+ headers.AddHeadersFromString(begin_params_.headers);
+ for (const auto& header : extra_headers_list)
+ headers.SetHeader(header.first, header.second);
+ begin_params_.headers = headers.ToString();
+ info_->begin_params.headers = headers.ToString();
+
loader_ = NavigationURLLoader::Create(
frame_tree_node_->navigator()->GetController()->GetBrowserContext(),
info_.Pass(), navigation_handle_->service_worker_handle(), this);
}
void NavigationRequest::OnRedirectChecksComplete(
- NavigationThrottle::ThrottleCheckResult result) {
+ NavigationThrottle::ThrottleCheckResult result,
+ const NavigationHandleImpl::ExtraHeadersList& extra_headers_list) {
CHECK(result != NavigationThrottle::DEFER);
// Abort the request if needed. This will destroy the NavigationRequest.
@@ -312,7 +321,7 @@ void NavigationRequest::OnRedirectChecksComplete(
return;
}
- loader_->FollowRedirect();
+ loader_->FollowRedirect(extra_headers_list);
navigation_handle_->DidRedirectNavigation(common_params_.url);
}

Powered by Google App Engine
This is Rietveld 408576698