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

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

Issue 2701093002: PlzNavigate: Cancel ongoing history navigations in the browser when we receive a navigation request… (Closed)
Patch Set: Address review comments Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/FlagExpectations/enable-browser-side-navigation » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/navigator_impl.h" 5 #include "content/browser/frame_host/navigator_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 const BeginNavigationParams& begin_params) { 991 const BeginNavigationParams& begin_params) {
992 // TODO(clamy): the url sent by the renderer should be validated with 992 // TODO(clamy): the url sent by the renderer should be validated with
993 // FilterURL. 993 // FilterURL.
994 // This is a renderer-initiated navigation. 994 // This is a renderer-initiated navigation.
995 CHECK(IsBrowserSideNavigationEnabled()); 995 CHECK(IsBrowserSideNavigationEnabled());
996 DCHECK(frame_tree_node); 996 DCHECK(frame_tree_node);
997 997
998 NavigationRequest* ongoing_navigation_request = 998 NavigationRequest* ongoing_navigation_request =
999 frame_tree_node->navigation_request(); 999 frame_tree_node->navigation_request();
1000 1000
1001 // Client redirects during the initial history navigation of a child frame
1002 // should take precedence over the history navigation (despite being renderer-
1003 // initiated). See https://crbug.com/348447 and https://crbug.com/691168.
1004 if (ongoing_navigation_request &&
1005 ongoing_navigation_request->request_params()
1006 .is_history_navigation_in_new_child) {
1007 // Preemptively clear this local pointer before deleting the request.
1008 ongoing_navigation_request = nullptr;
1009 frame_tree_node->ResetNavigationRequest(false);
1010 }
1011
1001 // The renderer-initiated navigation request is ignored iff a) there is an 1012 // The renderer-initiated navigation request is ignored iff a) there is an
1002 // ongoing request b) which is browser or user-initiated and c) the renderer 1013 // ongoing request b) which is browser or user-initiated and c) the renderer
1003 // request is not user-initiated. 1014 // request is not user-initiated.
1004 if (ongoing_navigation_request && 1015 if (ongoing_navigation_request &&
1005 (ongoing_navigation_request->browser_initiated() || 1016 (ongoing_navigation_request->browser_initiated() ||
1006 ongoing_navigation_request->begin_params().has_user_gesture) && 1017 ongoing_navigation_request->begin_params().has_user_gesture) &&
1007 !begin_params.has_user_gesture) { 1018 !begin_params.has_user_gesture) {
1008 RenderFrameHost* current_frame_host = 1019 RenderFrameHost* current_frame_host =
1009 frame_tree_node->render_manager()->current_frame_host(); 1020 frame_tree_node->render_manager()->current_frame_host();
1010 current_frame_host->Send( 1021 current_frame_host->Send(
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 frame_tree_node->navigation_request()->CreateNavigationHandle( 1215 frame_tree_node->navigation_request()->CreateNavigationHandle(
1205 entry.GetUniqueID()); 1216 entry.GetUniqueID());
1206 1217
1207 NavigationRequest* navigation_request = frame_tree_node->navigation_request(); 1218 NavigationRequest* navigation_request = frame_tree_node->navigation_request();
1208 if (!navigation_request) 1219 if (!navigation_request)
1209 return; // Navigation was synchronously stopped. 1220 return; // Navigation was synchronously stopped.
1210 1221
1211 // Have the current renderer execute its beforeunload event if needed. If it 1222 // Have the current renderer execute its beforeunload event if needed. If it
1212 // is not needed then NavigationRequest::BeginNavigation should be directly 1223 // is not needed then NavigationRequest::BeginNavigation should be directly
1213 // called instead. 1224 // called instead.
1214 if (should_dispatch_beforeunload && !IsRendererDebugURL(dest_url)) { 1225 // We don't want to dispatch a beforeunload handler if
1226 // is_history_navigation_in_new_child is true. This indicates a newly created
1227 // child frame which does not have a beforunload handler.
1228 if (should_dispatch_beforeunload && !IsRendererDebugURL(dest_url) &&
1229 !is_history_navigation_in_new_child) {
Charlie Reis 2017/02/18 00:22:52 Oh, sorry! I meant 1 line up from where it was, o
ananta 2017/02/18 00:32:05 Done.
1215 navigation_request->SetWaitingForRendererResponse(); 1230 navigation_request->SetWaitingForRendererResponse();
1216 frame_tree_node->current_frame_host()->DispatchBeforeUnload( 1231 frame_tree_node->current_frame_host()->DispatchBeforeUnload(
1217 true, reload_type != ReloadType::NONE); 1232 true, reload_type != ReloadType::NONE);
1218 } else { 1233 } else {
1219 navigation_request->BeginNavigation(); 1234 navigation_request->BeginNavigation();
1220 } 1235 }
1221 } 1236 }
1222 1237
1223 void NavigatorImpl::RecordNavigationMetrics( 1238 void NavigatorImpl::RecordNavigationMetrics(
1224 const LoadCommittedDetails& details, 1239 const LoadCommittedDetails& details,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 if (navigation_handle) 1336 if (navigation_handle)
1322 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); 1337 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID());
1323 1338
1324 controller_->SetPendingEntry(std::move(entry)); 1339 controller_->SetPendingEntry(std::move(entry));
1325 if (delegate_) 1340 if (delegate_)
1326 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 1341 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
1327 } 1342 }
1328 } 1343 }
1329 1344
1330 } // namespace content 1345 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/FlagExpectations/enable-browser-side-navigation » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698