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

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: Rebase 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 begin_params.renderer_navigation_id));
1012 return; 1013 return;
1013 } 1014 }
1014 1015
1015 // In all other cases the current navigation, if any, is canceled and a new 1016 // In all other cases the current navigation, if any, is canceled and a new
1016 // NavigationRequest is created for the node. 1017 // NavigationRequest is created for the node.
1017 frame_tree_node->CreatedNavigationRequest( 1018 frame_tree_node->CreatedNavigationRequest(
1018 NavigationRequest::CreateRendererInitiated( 1019 NavigationRequest::CreateRendererInitiated(
1019 frame_tree_node, common_params, begin_params, 1020 frame_tree_node, common_params, begin_params,
1020 controller_->GetLastCommittedEntryIndex(), 1021 controller_->GetLastCommittedEntryIndex(),
1021 controller_->GetEntryCount())); 1022 controller_->GetEntryCount()));
(...skipping 14 matching lines...) Expand all
1036 1037
1037 // For main frames, NavigationHandle will be created after the call to 1038 // For main frames, NavigationHandle will be created after the call to
1038 // |DidStartMainFrameNavigation|, so it receives the most up to date pending 1039 // |DidStartMainFrameNavigation|, so it receives the most up to date pending
1039 // entry from the NavigationController. 1040 // entry from the NavigationController.
1040 NavigationEntry* pending_entry = controller_->GetPendingEntry(); 1041 NavigationEntry* pending_entry = controller_->GetPendingEntry();
1041 navigation_request->CreateNavigationHandle( 1042 navigation_request->CreateNavigationHandle(
1042 pending_entry ? pending_entry->GetUniqueID() : 0); 1043 pending_entry ? pending_entry->GetUniqueID() : 0);
1043 navigation_request->BeginNavigation(); 1044 navigation_request->BeginNavigation();
1044 } 1045 }
1045 1046
1047 void NavigatorImpl::OnAbortNavigation(FrameTreeNode* frame_tree_node) {
1048 DCHECK(frame_tree_node);
1049
1050 NavigationRequest* ongoing_navigation_request =
1051 frame_tree_node->navigation_request();
1052 if (!ongoing_navigation_request ||
1053 ongoing_navigation_request->browser_initiated()) {
1054 return;
1055 }
1056
1057 // Abort the renderer-initiated navigation request.
1058 CancelNavigation(frame_tree_node);
1059 }
1060
1046 // PlzNavigate 1061 // PlzNavigate
1047 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) { 1062 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) {
1048 CHECK(IsBrowserSideNavigationEnabled()); 1063 CHECK(IsBrowserSideNavigationEnabled());
1049 frame_tree_node->ResetNavigationRequest(false); 1064 frame_tree_node->ResetNavigationRequest(false);
1050 if (frame_tree_node->IsMainFrame()) 1065 if (frame_tree_node->IsMainFrame())
1051 navigation_data_.reset(); 1066 navigation_data_.reset();
1052 } 1067 }
1053 1068
1054 void NavigatorImpl::LogResourceRequestTime( 1069 void NavigatorImpl::LogResourceRequestTime(
1055 base::TimeTicks timestamp, const GURL& url) { 1070 base::TimeTicks timestamp, const GURL& url) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 if (navigation_handle) 1303 if (navigation_handle)
1289 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); 1304 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID());
1290 1305
1291 controller_->SetPendingEntry(std::move(entry)); 1306 controller_->SetPendingEntry(std::move(entry));
1292 if (delegate_) 1307 if (delegate_)
1293 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 1308 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
1294 } 1309 }
1295 } 1310 }
1296 1311
1297 } // namespace content 1312 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698