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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/frame_host/navigation_request.h" 5 #include "content/browser/frame_host/navigation_request.h"
6 6
7 #include "content/browser/frame_host/frame_tree.h" 7 #include "content/browser/frame_host/frame_tree.h"
8 #include "content/browser/frame_host/frame_tree_node.h" 8 #include "content/browser/frame_host/frame_tree_node.h"
9 #include "content/browser/frame_host/navigation_controller_impl.h" 9 #include "content/browser/frame_host/navigation_controller_impl.h"
10 #include "content/browser/frame_host/navigation_handle_impl.h"
11 #include "content/browser/frame_host/navigation_request_info.h" 10 #include "content/browser/frame_host/navigation_request_info.h"
12 #include "content/browser/frame_host/navigator.h" 11 #include "content/browser/frame_host/navigator.h"
13 #include "content/browser/loader/navigation_url_loader.h" 12 #include "content/browser/loader/navigation_url_loader.h"
14 #include "content/browser/service_worker/service_worker_navigation_handle.h" 13 #include "content/browser/service_worker/service_worker_navigation_handle.h"
15 #include "content/browser/site_instance_impl.h" 14 #include "content/browser/site_instance_impl.h"
16 #include "content/common/resource_request_body.h" 15 #include "content/common/resource_request_body.h"
17 #include "content/public/browser/navigation_controller.h" 16 #include "content/public/browser/navigation_controller.h"
18 #include "content/public/browser/stream_handle.h" 17 #include "content/public/browser/stream_handle.h"
19 #include "content/public/common/content_client.h" 18 #include "content/public/common/content_client.h"
20 #include "net/base/load_flags.h" 19 #include "net/base/load_flags.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 frame_tree_node_->navigator()->FailedNavigation( 276 frame_tree_node_->navigator()->FailedNavigation(
278 frame_tree_node_, has_stale_copy_in_cache, net_error); 277 frame_tree_node_, has_stale_copy_in_cache, net_error);
279 } 278 }
280 279
281 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { 280 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) {
282 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, 281 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp,
283 common_params_.url); 282 common_params_.url);
284 } 283 }
285 284
286 void NavigationRequest::OnStartChecksComplete( 285 void NavigationRequest::OnStartChecksComplete(
287 NavigationThrottle::ThrottleCheckResult result) { 286 NavigationThrottle::ThrottleCheckResult result,
287 const NavigationHandleImpl::ExtraHeadersList& extra_headers_list) {
288 CHECK(result != NavigationThrottle::DEFER); 288 CHECK(result != NavigationThrottle::DEFER);
289 289
290 // Abort the request if needed. This will destroy the NavigationRequest. 290 // Abort the request if needed. This will destroy the NavigationRequest.
291 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 291 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
292 result == NavigationThrottle::CANCEL) { 292 result == NavigationThrottle::CANCEL) {
293 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 293 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
294 frame_tree_node_->ResetNavigationRequest(false); 294 frame_tree_node_->ResetNavigationRequest(false);
295 return; 295 return;
296 } 296 }
297 297
298 // Add extra headers to the request before sending it to the network stack.
299 net::HttpRequestHeaders headers;
300 headers.AddHeadersFromString(begin_params_.headers);
301 for (const auto& header : extra_headers_list)
302 headers.SetHeader(header.first, header.second);
303 begin_params_.headers = headers.ToString();
304 info_->begin_params.headers = headers.ToString();
305
298 loader_ = NavigationURLLoader::Create( 306 loader_ = NavigationURLLoader::Create(
299 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), 307 frame_tree_node_->navigator()->GetController()->GetBrowserContext(),
300 info_.Pass(), navigation_handle_->service_worker_handle(), this); 308 info_.Pass(), navigation_handle_->service_worker_handle(), this);
301 } 309 }
302 310
303 void NavigationRequest::OnRedirectChecksComplete( 311 void NavigationRequest::OnRedirectChecksComplete(
304 NavigationThrottle::ThrottleCheckResult result) { 312 NavigationThrottle::ThrottleCheckResult result,
313 const NavigationHandleImpl::ExtraHeadersList& extra_headers_list) {
305 CHECK(result != NavigationThrottle::DEFER); 314 CHECK(result != NavigationThrottle::DEFER);
306 315
307 // Abort the request if needed. This will destroy the NavigationRequest. 316 // Abort the request if needed. This will destroy the NavigationRequest.
308 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 317 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
309 result == NavigationThrottle::CANCEL) { 318 result == NavigationThrottle::CANCEL) {
310 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 319 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
311 frame_tree_node_->ResetNavigationRequest(false); 320 frame_tree_node_->ResetNavigationRequest(false);
312 return; 321 return;
313 } 322 }
314 323
315 loader_->FollowRedirect(); 324 loader_->FollowRedirect(extra_headers_list);
316 navigation_handle_->DidRedirectNavigation(common_params_.url); 325 navigation_handle_->DidRedirectNavigation(common_params_.url);
317 } 326 }
318 327
319 } // namespace content 328 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698