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

Side by Side Diff: content/browser/frame_host/navigation_request.cc

Issue 2966573003: Set UA override flag for Renderer-initiated NavigationRequest (Closed)
Patch Set: Created 3 years, 5 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 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 <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "content/browser/appcache/appcache_navigation_handle.h" 10 #include "content/browser/appcache/appcache_navigation_handle.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 return navigation_request; 255 return navigation_request;
256 } 256 }
257 257
258 // static 258 // static
259 std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( 259 std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated(
260 FrameTreeNode* frame_tree_node, 260 FrameTreeNode* frame_tree_node,
261 NavigationEntryImpl* entry, 261 NavigationEntryImpl* entry,
262 const CommonNavigationParams& common_params, 262 const CommonNavigationParams& common_params,
263 const BeginNavigationParams& begin_params, 263 const BeginNavigationParams& begin_params,
264 int current_history_list_offset, 264 int current_history_list_offset,
265 int current_history_list_length) { 265 int current_history_list_length,
266 bool override_user_agent) {
266 // Only normal navigations to a different document or reloads are expected. 267 // Only normal navigations to a different document or reloads are expected.
267 // - Renderer-initiated fragment-navigations never take place in the browser, 268 // - Renderer-initiated fragment-navigations never take place in the browser,
268 // even with PlzNavigate. 269 // even with PlzNavigate.
269 // - Restore-navigations are always browser-initiated. 270 // - Restore-navigations are always browser-initiated.
270 // - History-navigations use the browser-initiated path, event the ones that 271 // - History-navigations use the browser-initiated path, event the ones that
271 // are initiated by a javascript script, please see the IPC message 272 // are initiated by a javascript script, please see the IPC message
272 // ViewHostMsg_GoToEntryAtOffset. 273 // ViewHostMsg_GoToEntryAtOffset.
273 DCHECK(FrameMsg_Navigate_Type::IsReload(common_params.navigation_type) || 274 DCHECK(FrameMsg_Navigate_Type::IsReload(common_params.navigation_type) ||
274 common_params.navigation_type == 275 common_params.navigation_type ==
275 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT); 276 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT);
276 277
277 // TODO(clamy): See how we should handle override of the user agent when the
278 // navigation may start in a renderer and commit in another one.
279 // TODO(clamy): See if the navigation start time should be measured in the 278 // TODO(clamy): See if the navigation start time should be measured in the
280 // renderer and sent to the browser instead of being measured here. 279 // renderer and sent to the browser instead of being measured here.
281 // TODO(clamy): The pending history list offset should be properly set. 280 // TODO(clamy): The pending history list offset should be properly set.
282 RequestNavigationParams request_params( 281 RequestNavigationParams request_params(
283 false, // is_overriding_user_agent 282 override_user_agent,
284 std::vector<GURL>(), // redirects 283 std::vector<GURL>(), // redirects
285 common_params.url, common_params.method, 284 common_params.url, common_params.method,
286 false, // can_load_local_resources 285 false, // can_load_local_resources
287 PageState(), // page_state 286 PageState(), // page_state
288 0, // nav_entry_id 287 0, // nav_entry_id
289 false, // is_history_navigation_in_new_child 288 false, // is_history_navigation_in_new_child
290 std::map<std::string, bool>(), // subframe_unique_names 289 std::map<std::string, bool>(), // subframe_unique_names
291 frame_tree_node->has_committed_real_load(), 290 frame_tree_node->has_committed_real_load(),
292 false, // intended_as_new_entry 291 false, // intended_as_new_entry
293 -1, // pending_history_list_offset 292 -1, // pending_history_list_offset
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 source_site_instance_ = 350 source_site_instance_ =
352 frame_tree_node->current_frame_host()->GetSiteInstance(); 351 frame_tree_node->current_frame_host()->GetSiteInstance();
353 } 352 }
354 353
355 // Update the load flags with cache information. 354 // Update the load flags with cache information.
356 UpdateLoadFlagsWithCacheFlags(&begin_params_.load_flags, 355 UpdateLoadFlagsWithCacheFlags(&begin_params_.load_flags,
357 common_params_.navigation_type, 356 common_params_.navigation_type,
358 common_params_.method == "POST"); 357 common_params_.method == "POST");
359 358
360 // Add necessary headers that may not be present in the BeginNavigationParams. 359 // Add necessary headers that may not be present in the BeginNavigationParams.
360 if (entry)
361 nav_entry_id_ = entry->GetUniqueID();
362
361 std::string user_agent_override; 363 std::string user_agent_override;
362 if (entry) { 364 if (request_params.is_overriding_user_agent ||
363 nav_entry_id_ = entry->GetUniqueID(); 365 (entry && entry->GetIsOverridingUserAgent())) {
364 if (entry->GetIsOverridingUserAgent()) { 366 user_agent_override =
365 user_agent_override = 367 frame_tree_node_->navigator()->GetDelegate()->GetUserAgentOverride();
366 frame_tree_node_->navigator()->GetDelegate()->GetUserAgentOverride();
367 }
368 } 368 }
369 369
370 net::HttpRequestHeaders headers; 370 net::HttpRequestHeaders headers;
371 headers.AddHeadersFromString(begin_params_.headers); 371 headers.AddHeadersFromString(begin_params_.headers);
372 AddAdditionalRequestHeaders( 372 AddAdditionalRequestHeaders(
373 &headers, common_params_.url, common_params_.navigation_type, 373 &headers, common_params_.url, common_params_.navigation_type,
374 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), 374 frame_tree_node_->navigator()->GetController()->GetBrowserContext(),
375 common_params.method, user_agent_override, frame_tree_node); 375 common_params.method, user_agent_override, frame_tree_node);
376 begin_params_.headers = headers.ToString(); 376 begin_params_.headers = headers.ToString();
377 } 377 }
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 895 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
896 896
897 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 897 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
898 std::move(handle_), common_params_, 898 std::move(handle_), common_params_,
899 request_params_, is_view_source_); 899 request_params_, is_view_source_);
900 900
901 frame_tree_node_->ResetNavigationRequest(true, true); 901 frame_tree_node_->ResetNavigationRequest(true, true);
902 } 902 }
903 903
904 } // namespace content 904 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_request.h ('k') | content/browser/frame_host/navigator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698