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

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

Issue 2735183003: PlzNavigate: stop navigations when opening a document for write (Closed)
Patch Set: Created 3 years, 9 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
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 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 // The renderer-initiated navigation request is ignored iff a) there is an 1001 // 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 1002 // ongoing request b) which is browser or user-initiated and c) the renderer
1003 // request is not user-initiated. 1003 // request is not user-initiated.
1004 if (ongoing_navigation_request && 1004 if (ongoing_navigation_request &&
1005 (ongoing_navigation_request->browser_initiated() || 1005 (ongoing_navigation_request->browser_initiated() ||
1006 ongoing_navigation_request->begin_params().has_user_gesture) && 1006 ongoing_navigation_request->begin_params().has_user_gesture) &&
1007 !begin_params.has_user_gesture) { 1007 !begin_params.has_user_gesture) {
1008 RenderFrameHost* current_frame_host = 1008 RenderFrameHost* current_frame_host =
1009 frame_tree_node->render_manager()->current_frame_host(); 1009 frame_tree_node->render_manager()->current_frame_host();
1010 current_frame_host->Send( 1010 current_frame_host->Send(
1011 new FrameMsg_Stop(current_frame_host->GetRoutingID())); 1011 new FrameMsg_DroppedNavigation(current_frame_host->GetRoutingID()));
1012 return; 1012 return;
1013 } 1013 }
1014 1014
1015 // In all other cases the current navigation, if any, is canceled and a new 1015 // In all other cases the current navigation, if any, is canceled and a new
1016 // NavigationRequest is created for the node. 1016 // NavigationRequest is created for the node.
1017 frame_tree_node->CreatedNavigationRequest( 1017 frame_tree_node->CreatedNavigationRequest(
1018 NavigationRequest::CreateRendererInitiated( 1018 NavigationRequest::CreateRendererInitiated(
1019 frame_tree_node, common_params, begin_params, 1019 frame_tree_node, common_params, begin_params,
1020 controller_->GetLastCommittedEntryIndex(), 1020 controller_->GetLastCommittedEntryIndex(),
1021 controller_->GetEntryCount())); 1021 controller_->GetEntryCount()));
(...skipping 14 matching lines...) Expand all
1036 1036
1037 // For main frames, NavigationHandle will be created after the call to 1037 // For main frames, NavigationHandle will be created after the call to
1038 // |DidStartMainFrameNavigation|, so it receives the most up to date pending 1038 // |DidStartMainFrameNavigation|, so it receives the most up to date pending
1039 // entry from the NavigationController. 1039 // entry from the NavigationController.
1040 NavigationEntry* pending_entry = controller_->GetPendingEntry(); 1040 NavigationEntry* pending_entry = controller_->GetPendingEntry();
1041 navigation_request->CreateNavigationHandle( 1041 navigation_request->CreateNavigationHandle(
1042 pending_entry ? pending_entry->GetUniqueID() : 0); 1042 pending_entry ? pending_entry->GetUniqueID() : 0);
1043 navigation_request->BeginNavigation(); 1043 navigation_request->BeginNavigation();
1044 } 1044 }
1045 1045
1046 void NavigatorImpl::OnAbortNavigation(FrameTreeNode* frame_tree_node) {
1047 DCHECK(frame_tree_node);
1048
1049 NavigationRequest* ongoing_navigation_request =
1050 frame_tree_node->navigation_request();
1051 if (!ongoing_navigation_request ||
1052 ongoing_navigation_request->browser_initiated()) {
1053 return;
1054 }
1055
1056 // Abort the renderer-initiated navigation request.
1057 CancelNavigation(frame_tree_node);
1058 }
1059
1046 // PlzNavigate 1060 // PlzNavigate
1047 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) { 1061 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) {
1048 CHECK(IsBrowserSideNavigationEnabled()); 1062 CHECK(IsBrowserSideNavigationEnabled());
1049 frame_tree_node->ResetNavigationRequest(false); 1063 frame_tree_node->ResetNavigationRequest(false);
1050 if (frame_tree_node->IsMainFrame()) 1064 if (frame_tree_node->IsMainFrame())
1051 navigation_data_.reset(); 1065 navigation_data_.reset();
1052 } 1066 }
1053 1067
1054 void NavigatorImpl::LogResourceRequestTime( 1068 void NavigatorImpl::LogResourceRequestTime(
1055 base::TimeTicks timestamp, const GURL& url) { 1069 base::TimeTicks timestamp, const GURL& url) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 if (navigation_handle) 1302 if (navigation_handle)
1289 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); 1303 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID());
1290 1304
1291 controller_->SetPendingEntry(std::move(entry)); 1305 controller_->SetPendingEntry(std::move(entry));
1292 if (delegate_) 1306 if (delegate_)
1293 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 1307 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
1294 } 1308 }
1295 } 1309 }
1296 1310
1297 } // namespace content 1311 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698