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

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

Issue 914223002: PlzNavigate: Updated navigation cancel policy for renderer-initiated requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reverted method name; comment updates. Created 5 years, 10 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/navigator_impl.cc
diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc
index e4afbe62a6628ddf93e7e7c52ef6c120d1189dc8..032f4e3d32e1ee40bb94c01ae090a7aa595ad5e4 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -703,14 +703,27 @@ void NavigatorImpl::OnBeginNavigation(
const CommonNavigationParams& common_params,
const BeginNavigationParams& begin_params,
scoped_refptr<ResourceRequestBody> body) {
+ // This is a renderer-initiated navigation.
CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableBrowserSideNavigation));
DCHECK(frame_tree_node);
- // This is a renderer-initiated navigation, so generate a new
- // NavigationRequest and store it in the map.
- // TODO(clamy): Renderer-initiated navigations should not always cancel the
- // current one.
+ NavigationRequest* ongoing_navigation_request =
+ navigation_request_map_.get(frame_tree_node->frame_tree_node_id());
+
+ // The renderer-initiated navigation request is ignored iff a) there is an
+ // ongoing request b) which is browser or user-initiated and c) the renderer
+ // request is not user-initiated.
+ if (ongoing_navigation_request &&
+ (ongoing_navigation_request->browser_initiated() ||
+ ongoing_navigation_request->begin_params().has_user_gesture) &&
+ !begin_params.has_user_gesture) {
+ return;
+ }
+
+ // In all other cases the current navigation, if any, is canceled and a new
+ // NavigationRequest is created and stored in the map. Actual cancellation
+ // happens when the existing request map entry is replaced and destroyed.
scoped_ptr<NavigationRequest> navigation_request =
NavigationRequest::CreateRendererInitiated(
frame_tree_node, common_params, begin_params, body);
« no previous file with comments | « content/browser/frame_host/navigation_request.h ('k') | content/browser/frame_host/navigator_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698