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

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

Issue 2584513003: PlzNavigate: identify same-page browser-initiated navigation. (Closed)
Patch Set: PlzNavigate: identify same-page browser-initiated navigation. Created 4 years 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 "content/browser/appcache/appcache_navigation_handle.h" 9 #include "content/browser/appcache/appcache_navigation_handle.h"
10 #include "content/browser/appcache/chrome_appcache_service.h" 10 #include "content/browser/appcache/chrome_appcache_service.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 bool is_same_document_history_load, 194 bool is_same_document_history_load,
195 bool is_history_navigation_in_new_child, 195 bool is_history_navigation_in_new_child,
196 const base::TimeTicks& navigation_start, 196 const base::TimeTicks& navigation_start,
197 NavigationControllerImpl* controller) { 197 NavigationControllerImpl* controller) {
198 // Fill POST data in the request body. 198 // Fill POST data in the request body.
199 scoped_refptr<ResourceRequestBodyImpl> request_body; 199 scoped_refptr<ResourceRequestBodyImpl> request_body;
200 if (frame_entry.method() == "POST") 200 if (frame_entry.method() == "POST")
201 request_body = frame_entry.GetPostData(); 201 request_body = frame_entry.GetPostData();
202 202
203 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( 203 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest(
204 frame_tree_node, entry.ConstructCommonNavigationParams( 204 frame_tree_node,
205 frame_entry, request_body, dest_url, dest_referrer, 205 entry.ConstructCommonNavigationParams(frame_entry, request_body, dest_url,
206 navigation_type, lofi_state, navigation_start), 206 dest_referrer, navigation_type,
207 lofi_state, navigation_start),
207 BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL, 208 BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL,
208 false, // has_user_gestures 209 false, // has_user_gestures
209 false, // skip_service_worker 210 false, // skip_service_worker
210 REQUEST_CONTEXT_TYPE_LOCATION), 211 REQUEST_CONTEXT_TYPE_LOCATION),
211 entry.ConstructRequestNavigationParams( 212 entry.ConstructRequestNavigationParams(
212 frame_entry, is_same_document_history_load, 213 frame_entry, net::AreURLsInPageNavigation(
213 is_history_navigation_in_new_child, 214 frame_tree_node->current_url(), dest_url),
215 is_same_document_history_load, is_history_navigation_in_new_child,
214 entry.GetSubframeUniqueNames(frame_tree_node), 216 entry.GetSubframeUniqueNames(frame_tree_node),
215 frame_tree_node->has_committed_real_load(), 217 frame_tree_node->has_committed_real_load(),
216 controller->GetPendingEntryIndex() == -1, 218 controller->GetPendingEntryIndex() == -1,
217 controller->GetIndexOfEntry(&entry), 219 controller->GetIndexOfEntry(&entry),
218 controller->GetLastCommittedEntryIndex(), 220 controller->GetLastCommittedEntryIndex(),
219 controller->GetEntryCount()), 221 controller->GetEntryCount()),
220 true, &frame_entry, &entry)); 222 true, &frame_entry, &entry));
221 return navigation_request; 223 return navigation_request;
222 } 224 }
223 225
224 // static 226 // static
225 std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( 227 std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated(
226 FrameTreeNode* frame_tree_node, 228 FrameTreeNode* frame_tree_node,
227 const CommonNavigationParams& common_params, 229 const CommonNavigationParams& common_params,
228 const BeginNavigationParams& begin_params, 230 const BeginNavigationParams& begin_params,
229 int current_history_list_offset, 231 int current_history_list_offset,
230 int current_history_list_length) { 232 int current_history_list_length) {
231 // TODO(clamy): Check if some PageState should be provided here. 233 // TODO(clamy): Check if some PageState should be provided here.
232 // TODO(clamy): See how we should handle override of the user agent when the 234 // TODO(clamy): See how we should handle override of the user agent when the
233 // navigation may start in a renderer and commit in another one. 235 // navigation may start in a renderer and commit in another one.
234 // TODO(clamy): See if the navigation start time should be measured in the 236 // TODO(clamy): See if the navigation start time should be measured in the
235 // renderer and sent to the browser instead of being measured here. 237 // renderer and sent to the browser instead of being measured here.
236 // TODO(clamy): The pending history list offset should be properly set. 238 // TODO(clamy): The pending history list offset should be properly set.
237 RequestNavigationParams request_params( 239 RequestNavigationParams request_params(
238 false, // is_overriding_user_agent 240 false, // is_overriding_user_agent
239 std::vector<GURL>(), // redirects 241 std::vector<GURL>(), // redirects
240 false, // can_load_local_resources 242 false, // can_load_local_resources
241 PageState(), // page_state 243 PageState(), // page_state
242 0, // nav_entry_id 244 0, // nav_entry_id
245 false, // is_same_document_navigation
243 false, // is_same_document_history_load 246 false, // is_same_document_history_load
244 false, // is_history_navigation_in_new_child 247 false, // is_history_navigation_in_new_child
245 std::map<std::string, bool>(), // subframe_unique_names 248 std::map<std::string, bool>(), // subframe_unique_names
246 frame_tree_node->has_committed_real_load(), 249 frame_tree_node->has_committed_real_load(),
247 false, // intended_as_new_entry 250 false, // intended_as_new_entry
248 -1, // pending_history_list_offset 251 -1, // pending_history_list_offset
249 current_history_list_offset, current_history_list_length, 252 current_history_list_offset, current_history_list_length,
250 false, // is_view_source 253 false, // is_view_source
251 false, // should_clear_history_list 254 false, // should_clear_history_list
252 begin_params.has_user_gesture); 255 begin_params.has_user_gesture);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 312
310 NavigationRequest::~NavigationRequest() { 313 NavigationRequest::~NavigationRequest() {
311 } 314 }
312 315
313 void NavigationRequest::BeginNavigation() { 316 void NavigationRequest::BeginNavigation() {
314 DCHECK(!loader_); 317 DCHECK(!loader_);
315 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); 318 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE);
316 state_ = STARTED; 319 state_ = STARTED;
317 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get()); 320 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get());
318 321
319 if (ShouldMakeNetworkRequestForURL(common_params_.url)) { 322 if (ShouldMakeNetworkRequestForURL(common_params_.url) &&
323 !request_params_.is_same_document_navigation) {
320 // It's safe to use base::Unretained because this NavigationRequest owns 324 // It's safe to use base::Unretained because this NavigationRequest owns
321 // the NavigationHandle where the callback will be stored. 325 // the NavigationHandle where the callback will be stored.
322 // TODO(clamy): pass the real value for |is_external_protocol| if needed. 326 // TODO(clamy): pass the real value for |is_external_protocol| if needed.
323 // TODO(clamy): pass the method to the NavigationHandle instead of a 327 // TODO(clamy): pass the method to the NavigationHandle instead of a
324 // boolean. 328 // boolean.
325 navigation_handle_->WillStartRequest( 329 navigation_handle_->WillStartRequest(
326 common_params_.method, common_params_.post_data, 330 common_params_.method, common_params_.post_data,
327 Referrer::SanitizeForRequest(common_params_.url, 331 Referrer::SanitizeForRequest(common_params_.url,
328 common_params_.referrer), 332 common_params_.referrer),
329 begin_params_.has_user_gesture, common_params_.transition, false, 333 begin_params_.has_user_gesture, common_params_.transition, false,
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 // Have the processing of the response resume in the network stack. 640 // Have the processing of the response resume in the network stack.
637 loader_->ProceedWithResponse(); 641 loader_->ProceedWithResponse();
638 642
639 CommitNavigation(); 643 CommitNavigation();
640 644
641 // DO NOT ADD CODE after this. The previous call to CommitNavigation caused 645 // DO NOT ADD CODE after this. The previous call to CommitNavigation caused
642 // the destruction of the NavigationRequest. 646 // the destruction of the NavigationRequest.
643 } 647 }
644 648
645 void NavigationRequest::CommitNavigation() { 649 void NavigationRequest::CommitNavigation() {
646 DCHECK(response_ || !ShouldMakeNetworkRequestForURL(common_params_.url)); 650 DCHECK(response_ || !ShouldMakeNetworkRequestForURL(common_params_.url) ||
651 request_params_.is_same_document_navigation);
647 DCHECK(!common_params_.url.SchemeIs(url::kJavaScriptScheme)); 652 DCHECK(!common_params_.url.SchemeIs(url::kJavaScriptScheme));
648 653
649 // Retrieve the RenderFrameHost that needs to commit the navigation. 654 // Retrieve the RenderFrameHost that needs to commit the navigation.
650 RenderFrameHostImpl* render_frame_host = 655 RenderFrameHostImpl* render_frame_host =
651 navigation_handle_->GetRenderFrameHost(); 656 navigation_handle_->GetRenderFrameHost();
652 DCHECK(render_frame_host == 657 DCHECK(render_frame_host ==
653 frame_tree_node_->render_manager()->current_frame_host() || 658 frame_tree_node_->render_manager()->current_frame_host() ||
654 render_frame_host == 659 render_frame_host ==
655 frame_tree_node_->render_manager()->speculative_frame_host()); 660 frame_tree_node_->render_manager()->speculative_frame_host());
656 661
657 TransferNavigationHandleOwnership(render_frame_host); 662 TransferNavigationHandleOwnership(render_frame_host);
658 663
659 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 664 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
660 665
661 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 666 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
662 common_params_, request_params_, 667 common_params_, request_params_,
663 is_view_source_); 668 is_view_source_);
664 669
665 frame_tree_node_->ResetNavigationRequest(true); 670 frame_tree_node_->ResetNavigationRequest(true);
666 } 671 }
667 672
668 } // namespace content 673 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698