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

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

Issue 2584513003: PlzNavigate: identify same-page browser-initiated navigation. (Closed)
Patch Set: Very minor fix. 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 9f676eb677e923edb349021448e6600222f3df1e..5576ce8ab6f63ed72f5567a15dd768de5349a291 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -222,10 +222,16 @@ 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_history_navigation = frame_entry.page_state().IsValid();
+ bool is_same_document_fragment_change =
+ net::AreURLsInPageNavigation(frame_tree_node->current_url(), dest_url) &&
+ !is_history_navigation;
nasko 2017/01/13 02:51:10 Can you put a comment why is_history_navigation ne
arthursonzogni 2017/01/13 15:18:37 Yes, it is more than useful. Done.
+
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
@@ -233,8 +239,8 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated(
blink::WebMixedContentContextType::Blockable,
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,
@@ -254,6 +260,9 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated(
const BeginNavigationParams& begin_params,
int current_history_list_offset,
int current_history_list_length) {
+ bool is_same_document_fragment_change = net::AreURLsInPageNavigation(
+ frame_tree_node->current_url(), common_params.url);
+
// TODO(clamy): Check if some PageState should be provided here.
arthursonzogni 2017/01/13 15:18:37 Do we know now? Does history navigations could cal
// TODO(clamy): See how we should handle override of the user agent when the
// navigation may start in a renderer and commit in another one.
@@ -261,27 +270,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
+ is_same_document_fragment_change, // 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;
}
@@ -348,7 +357,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.
@@ -383,11 +393,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
@@ -702,7 +712,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