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

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: Move check for is_history_navigation_in_new_child up 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);
jam 2017/05/16 20:13:11 btw I was tracing this code as part of https://cod
Charlie Reis 2017/05/18 21:26:46 Yep, it's still needed, but some races mean we are
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 ReloadType reload_type, 1170 ReloadType reload_type,
1160 PreviewsState previews_state, 1171 PreviewsState previews_state,
1161 bool is_same_document_history_load, 1172 bool is_same_document_history_load,
1162 bool is_history_navigation_in_new_child, 1173 bool is_history_navigation_in_new_child,
1163 base::TimeTicks navigation_start) { 1174 base::TimeTicks navigation_start) {
1164 CHECK(IsBrowserSideNavigationEnabled()); 1175 CHECK(IsBrowserSideNavigationEnabled());
1165 DCHECK(frame_tree_node); 1176 DCHECK(frame_tree_node);
1166 1177
1167 // This value must be set here because creating a NavigationRequest might 1178 // This value must be set here because creating a NavigationRequest might
1168 // change the renderer live/non-live status and change this result. 1179 // change the renderer live/non-live status and change this result.
1180 // We don't want to dispatch a beforeunload handler if
1181 // is_history_navigation_in_new_child is true. This indicates a newly created
1182 // child frame which does not have a beforunload handler.
1169 bool should_dispatch_beforeunload = 1183 bool should_dispatch_beforeunload =
1170 !is_same_document_history_load && 1184 !is_same_document_history_load &&
1185 !is_history_navigation_in_new_child &&
1171 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); 1186 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload();
1172 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType( 1187 FrameMsg_Navigate_Type::Value navigation_type = GetNavigationType(
1173 frame_tree_node->current_url(), // old_url 1188 frame_tree_node->current_url(), // old_url
1174 dest_url, // new_url 1189 dest_url, // new_url
1175 reload_type, // reload_type 1190 reload_type, // reload_type
1176 entry, // entry 1191 entry, // entry
1177 frame_entry, // frame_entry 1192 frame_entry, // frame_entry
1178 is_same_document_history_load); // is_same_document_history_load 1193 is_same_document_history_load); // is_same_document_history_load
1179 std::unique_ptr<NavigationRequest> scoped_request = 1194 std::unique_ptr<NavigationRequest> scoped_request =
1180 NavigationRequest::CreateBrowserInitiated( 1195 NavigationRequest::CreateBrowserInitiated(
(...skipping 140 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