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

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: Addressed commemts 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 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 if (!navigation_request) 961 if (!navigation_request)
962 return; 962 return;
963 963
964 DCHECK_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE, 964 DCHECK_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE,
965 navigation_request->state()); 965 navigation_request->state());
966 966
967 // If the navigation is allowed to proceed, send the request to the IO thread. 967 // If the navigation is allowed to proceed, send the request to the IO thread.
968 if (proceed) 968 if (proceed)
969 navigation_request->BeginNavigation(); 969 navigation_request->BeginNavigation();
970 else 970 else
971 CancelNavigation(frame_tree_node); 971 CancelNavigation(frame_tree_node, true);
972 } 972 }
973 973
974 // PlzNavigate 974 // PlzNavigate
975 void NavigatorImpl::OnBeginNavigation( 975 void NavigatorImpl::OnBeginNavigation(
976 FrameTreeNode* frame_tree_node, 976 FrameTreeNode* frame_tree_node,
977 const CommonNavigationParams& common_params, 977 const CommonNavigationParams& common_params,
978 const BeginNavigationParams& begin_params) { 978 const BeginNavigationParams& begin_params) {
979 // TODO(clamy): the url sent by the renderer should be validated with 979 // TODO(clamy): the url sent by the renderer should be validated with
980 // FilterURL. 980 // FilterURL.
981 // This is a renderer-initiated navigation. 981 // This is a renderer-initiated navigation.
982 CHECK(IsBrowserSideNavigationEnabled()); 982 CHECK(IsBrowserSideNavigationEnabled());
983 DCHECK(frame_tree_node); 983 DCHECK(frame_tree_node);
984 984
985 NavigationRequest* ongoing_navigation_request = 985 NavigationRequest* ongoing_navigation_request =
986 frame_tree_node->navigation_request(); 986 frame_tree_node->navigation_request();
987 987
988 // Client redirects during the initial history navigation of a child frame 988 // Client redirects during the initial history navigation of a child frame
989 // should take precedence over the history navigation (despite being renderer- 989 // should take precedence over the history navigation (despite being renderer-
990 // initiated). See https://crbug.com/348447 and https://crbug.com/691168. 990 // initiated). See https://crbug.com/348447 and https://crbug.com/691168.
991 if (ongoing_navigation_request && 991 if (ongoing_navigation_request &&
992 ongoing_navigation_request->request_params() 992 ongoing_navigation_request->request_params()
993 .is_history_navigation_in_new_child) { 993 .is_history_navigation_in_new_child) {
994 // Preemptively clear this local pointer before deleting the request. 994 // Preemptively clear this local pointer before deleting the request.
995 ongoing_navigation_request = nullptr; 995 ongoing_navigation_request = nullptr;
996 frame_tree_node->ResetNavigationRequest(false); 996 frame_tree_node->ResetNavigationRequest(false, true);
997 } 997 }
998 998
999 // The renderer-initiated navigation request is ignored iff a) there is an 999 // The renderer-initiated navigation request is ignored iff a) there is an
1000 // ongoing request b) which is browser or user-initiated and c) the renderer 1000 // ongoing request b) which is browser or user-initiated and c) the renderer
1001 // request is not user-initiated. 1001 // request is not user-initiated.
1002 if (ongoing_navigation_request && 1002 if (ongoing_navigation_request &&
1003 (ongoing_navigation_request->browser_initiated() || 1003 (ongoing_navigation_request->browser_initiated() ||
1004 ongoing_navigation_request->begin_params().has_user_gesture) && 1004 ongoing_navigation_request->begin_params().has_user_gesture) &&
1005 !begin_params.has_user_gesture) { 1005 !begin_params.has_user_gesture) {
1006 RenderFrameHost* current_frame_host = 1006 RenderFrameHost* current_frame_host =
(...skipping 27 matching lines...) Expand all
1034 1034
1035 // For main frames, NavigationHandle will be created after the call to 1035 // For main frames, NavigationHandle will be created after the call to
1036 // |DidStartMainFrameNavigation|, so it receives the most up to date pending 1036 // |DidStartMainFrameNavigation|, so it receives the most up to date pending
1037 // entry from the NavigationController. 1037 // entry from the NavigationController.
1038 NavigationEntry* pending_entry = controller_->GetPendingEntry(); 1038 NavigationEntry* pending_entry = controller_->GetPendingEntry();
1039 navigation_request->CreateNavigationHandle( 1039 navigation_request->CreateNavigationHandle(
1040 pending_entry ? pending_entry->GetUniqueID() : 0); 1040 pending_entry ? pending_entry->GetUniqueID() : 0);
1041 navigation_request->BeginNavigation(); 1041 navigation_request->BeginNavigation();
1042 } 1042 }
1043 1043
1044 void NavigatorImpl::OnAbortNavigation(FrameTreeNode* frame_tree_node) {
1045 NavigationRequest* ongoing_navigation_request =
1046 frame_tree_node->navigation_request();
1047 if (!ongoing_navigation_request ||
1048 ongoing_navigation_request->browser_initiated()) {
1049 return;
1050 }
1051
1052 // Abort the renderer-initiated navigation request.
1053 CancelNavigation(frame_tree_node, false);
1054 }
1055
1044 // PlzNavigate 1056 // PlzNavigate
1045 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node) { 1057 void NavigatorImpl::CancelNavigation(FrameTreeNode* frame_tree_node,
1058 bool inform_renderer) {
1046 CHECK(IsBrowserSideNavigationEnabled()); 1059 CHECK(IsBrowserSideNavigationEnabled());
1047 frame_tree_node->ResetNavigationRequest(false); 1060 frame_tree_node->ResetNavigationRequest(false, inform_renderer);
1048 if (frame_tree_node->IsMainFrame()) 1061 if (frame_tree_node->IsMainFrame())
1049 navigation_data_.reset(); 1062 navigation_data_.reset();
1050 } 1063 }
1051 1064
1052 void NavigatorImpl::LogResourceRequestTime( 1065 void NavigatorImpl::LogResourceRequestTime(
1053 base::TimeTicks timestamp, const GURL& url) { 1066 base::TimeTicks timestamp, const GURL& url) {
1054 if (navigation_data_ && navigation_data_->url_ == url) { 1067 if (navigation_data_ && navigation_data_->url_ == url) {
1055 navigation_data_->url_job_start_time_ = timestamp; 1068 navigation_data_->url_job_start_time_ = timestamp;
1056 UMA_HISTOGRAM_TIMES( 1069 UMA_HISTOGRAM_TIMES(
1057 "Navigation.TimeToURLJobStart", 1070 "Navigation.TimeToURLJobStart",
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 if (navigation_handle) 1302 if (navigation_handle)
1290 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); 1303 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID());
1291 1304
1292 controller_->SetPendingEntry(std::move(entry)); 1305 controller_->SetPendingEntry(std::move(entry));
1293 if (delegate_) 1306 if (delegate_)
1294 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 1307 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
1295 } 1308 }
1296 } 1309 }
1297 1310
1298 } // namespace content 1311 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl.h ('k') | content/browser/frame_host/render_frame_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698