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

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

Issue 2584513003: PlzNavigate: identify same-page browser-initiated navigation. (Closed)
Patch Set: Fix 2 WebContentsImplTest by assigning a document_sequence_number. Created 3 years, 11 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: 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 8a1007d4dd3d6550e05f76faa0f276bcaeedc3b5..9b3e0b24db69fc0d7c66b59c92b0ee4039301526 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -221,17 +221,21 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated(
// the renderer in the first place as part of OpenURL.
bool browser_initiated = !entry.is_renderer_initiated();
+ bool is_same_document_fragment_change =
+ net::AreURLsInPageNavigation(frame_tree_node->current_url(), dest_url);
nasko 2017/01/10 00:19:00 Why can't we use NavigationControllerImpl::IsURLIn
arthursonzogni 2017/01/12 17:32:30 I didn't know this function existed. I just tried
nasko 2017/01/13 02:51:09 Acknowledged.
+
std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest(
- frame_tree_node, entry.ConstructCommonNavigationParams(
- frame_entry, request_body, dest_url, dest_referrer,
- navigation_type, lofi_state, navigation_start),
+ frame_tree_node,
+ entry.ConstructCommonNavigationParams(frame_entry, request_body, dest_url,
+ dest_referrer, navigation_type,
+ lofi_state, navigation_start),
BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL,
false, // has_user_gestures
false, // skip_service_worker
REQUEST_CONTEXT_TYPE_LOCATION, initiator),
entry.ConstructRequestNavigationParams(
- frame_entry, is_same_document_history_load,
- is_history_navigation_in_new_child,
+ frame_entry, is_same_document_fragment_change,
+ is_same_document_history_load, is_history_navigation_in_new_child,
entry.GetSubframeUniqueNames(frame_tree_node),
frame_tree_node->has_committed_real_load(),
controller->GetPendingEntryIndex() == -1,
@@ -239,7 +243,7 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated(
controller->GetLastCommittedEntryIndex(),
controller->GetEntryCount()),
browser_initiated,
- true, // may_transfer
+ true, // may_transfer
&frame_entry, &entry));
return navigation_request;
}
@@ -258,27 +262,27 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated(
// renderer and sent to the browser instead of being measured here.
// TODO(clamy): The pending history list offset should be properly set.
RequestNavigationParams request_params(
- false, // is_overriding_user_agent
- std::vector<GURL>(), // redirects
- false, // can_load_local_resources
- PageState(), // page_state
- 0, // nav_entry_id
- false, // is_same_document_history_load
- false, // is_history_navigation_in_new_child
- std::map<std::string, bool>(), // subframe_unique_names
+ false, // is_overriding_user_agent
+ std::vector<GURL>(), // redirects
+ false, // can_load_local_resources
+ PageState(), // page_state
+ 0, // nav_entry_id
+ false, // is_same_document_fragment_change
+ false, // is_same_document_history_load
+ false, // is_history_navigation_in_new_child
+ std::map<std::string, bool>(), // subframe_unique_names
frame_tree_node->has_committed_real_load(),
- false, // intended_as_new_entry
- -1, // pending_history_list_offset
+ false, // intended_as_new_entry
+ -1, // pending_history_list_offset
current_history_list_offset, current_history_list_length,
- false, // is_view_source
- false, // should_clear_history_list
+ false, // is_view_source
+ false, // should_clear_history_list
begin_params.has_user_gesture);
- std::unique_ptr<NavigationRequest> navigation_request(
- new NavigationRequest(frame_tree_node, common_params, begin_params,
- request_params,
- false, // browser_initiated
- false, // may_transfer
- nullptr, nullptr));
+ std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest(
+ frame_tree_node, common_params, begin_params, request_params,
+ false, // browser_initiated
+ false, // may_transfer
+ nullptr, nullptr));
return navigation_request;
}
@@ -345,7 +349,8 @@ void NavigationRequest::BeginNavigation() {
state_ = STARTED;
RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get());
- if (ShouldMakeNetworkRequestForURL(common_params_.url)) {
+ if (ShouldMakeNetworkRequestForURL(common_params_.url) &&
+ !navigation_handle_->IsSamePage()) {
// It's safe to use base::Unretained because this NavigationRequest owns
// the NavigationHandle where the callback will be stored.
// TODO(clamy): pass the real value for |is_external_protocol| if needed.
@@ -379,11 +384,11 @@ void NavigationRequest::BeginNavigation() {
}
void NavigationRequest::CreateNavigationHandle(int pending_nav_entry_id) {
- // TODO(nasko): Update the NavigationHandle creation to ensure that the
- // proper values are specified for is_same_page.
+ bool is_same_page = request_params_.is_same_document_fragment_change ||
+ request_params_.is_same_document_history_load;
+
navigation_handle_ = NavigationHandleImpl::Create(
- common_params_.url, frame_tree_node_, !browser_initiated_,
- false, // is_same_page
+ common_params_.url, frame_tree_node_, !browser_initiated_, is_same_page,
common_params_.navigation_start, pending_nav_entry_id,
false); // started_in_context_menu
@@ -698,7 +703,8 @@ void NavigationRequest::OnWillProcessResponseChecksComplete(
}
void NavigationRequest::CommitNavigation() {
- DCHECK(response_ || !ShouldMakeNetworkRequestForURL(common_params_.url));
+ DCHECK(response_ || !ShouldMakeNetworkRequestForURL(common_params_.url) ||
+ navigation_handle_->IsSamePage());
DCHECK(!common_params_.url.SchemeIs(url::kJavaScriptScheme));
// Retrieve the RenderFrameHost that needs to commit the navigation.

Powered by Google App Engine
This is Rietveld 408576698