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

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

Issue 872473003: PlzNavigate: Remove the RequestNavigation IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nits + fix compilation error Created 5 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
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/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 site_instance_(static_cast<SiteInstanceImpl*>(site_instance)), 137 site_instance_(static_cast<SiteInstanceImpl*>(site_instance)),
138 process_(site_instance->GetProcess()), 138 process_(site_instance->GetProcess()),
139 cross_process_frame_connector_(NULL), 139 cross_process_frame_connector_(NULL),
140 render_frame_proxy_host_(NULL), 140 render_frame_proxy_host_(NULL),
141 frame_tree_(frame_tree), 141 frame_tree_(frame_tree),
142 frame_tree_node_(frame_tree_node), 142 frame_tree_node_(frame_tree_node),
143 routing_id_(routing_id), 143 routing_id_(routing_id),
144 render_frame_created_(false), 144 render_frame_created_(false),
145 navigations_suspended_(false), 145 navigations_suspended_(false),
146 is_waiting_for_beforeunload_ack_(false), 146 is_waiting_for_beforeunload_ack_(false),
147 unload_ack_is_for_cross_site_transition_(false), 147 unload_ack_is_for_navigation_(false),
148 accessibility_reset_token_(0), 148 accessibility_reset_token_(0),
149 accessibility_reset_count_(0), 149 accessibility_reset_count_(0),
150 no_create_browser_accessibility_manager_for_testing_(false), 150 no_create_browser_accessibility_manager_for_testing_(false),
151 weak_ptr_factory_(this) { 151 weak_ptr_factory_(this) {
152 bool is_swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT); 152 bool is_swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT);
153 bool hidden = !!(flags & CREATE_RF_HIDDEN); 153 bool hidden = !!(flags & CREATE_RF_HIDDEN);
154 frame_tree_->RegisterRenderFrameHost(this); 154 frame_tree_->RegisterRenderFrameHost(this);
155 GetProcess()->AddRoute(routing_id_, this); 155 GetProcess()->AddRoute(routing_id_, this);
156 g_routing_id_frame_map.Get().insert(std::make_pair( 156 g_routing_id_frame_map.Get().insert(std::make_pair(
157 RenderFrameHostID(GetProcess()->GetID(), routing_id_), 157 RenderFrameHostID(GetProcess()->GetID(), routing_id_),
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnDidCommitProvisionalLoad", 729 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnDidCommitProvisionalLoad",
730 "url", validated_params.url.possibly_invalid_spec()); 730 "url", validated_params.url.possibly_invalid_spec());
731 731
732 // If we're waiting for a cross-site beforeunload ack from this renderer and 732 // If we're waiting for a cross-site beforeunload ack from this renderer and
733 // we receive a Navigate message from the main frame, then the renderer was 733 // we receive a Navigate message from the main frame, then the renderer was
734 // navigating already and sent it before hearing the FrameMsg_Stop message. 734 // navigating already and sent it before hearing the FrameMsg_Stop message.
735 // We do not want to cancel the pending navigation in this case, since the 735 // We do not want to cancel the pending navigation in this case, since the
736 // old page will soon be stopped. Instead, treat this as a beforeunload ack 736 // old page will soon be stopped. Instead, treat this as a beforeunload ack
737 // to allow the pending navigation to continue. 737 // to allow the pending navigation to continue.
738 if (is_waiting_for_beforeunload_ack_ && 738 if (is_waiting_for_beforeunload_ack_ &&
739 unload_ack_is_for_cross_site_transition_ && 739 unload_ack_is_for_navigation_ &&
740 ui::PageTransitionIsMainFrame(validated_params.transition)) { 740 ui::PageTransitionIsMainFrame(validated_params.transition)) {
741 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; 741 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_;
742 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); 742 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now());
743 return; 743 return;
744 } 744 }
745 745
746 // If we're waiting for an unload ack from this renderer and we receive a 746 // If we're waiting for an unload ack from this renderer and we receive a
747 // Navigate message, then the renderer was navigating before it received the 747 // Navigate message, then the renderer was navigating before it received the
748 // unload request. It will either respond to the unload request soon or our 748 // unload request. It will either respond to the unload request soon or our
749 // timer will expire. Either way, we should ignore this message, because we 749 // timer will expire. Either way, we should ignore this message, because we
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 971
972 frame_tree_node_->navigator()->LogBeforeUnloadTime( 972 frame_tree_node_->navigator()->LogBeforeUnloadTime(
973 renderer_before_unload_start_time, renderer_before_unload_end_time); 973 renderer_before_unload_start_time, renderer_before_unload_end_time);
974 } 974 }
975 // Resets beforeunload waiting state. 975 // Resets beforeunload waiting state.
976 is_waiting_for_beforeunload_ack_ = false; 976 is_waiting_for_beforeunload_ack_ = false;
977 render_view_host_->decrement_in_flight_event_count(); 977 render_view_host_->decrement_in_flight_event_count();
978 render_view_host_->StopHangMonitorTimeout(); 978 render_view_host_->StopHangMonitorTimeout();
979 send_before_unload_start_time_ = base::TimeTicks(); 979 send_before_unload_start_time_ = base::TimeTicks();
980 980
981 frame_tree_node_->render_manager()->OnBeforeUnloadACK( 981 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
982 unload_ack_is_for_cross_site_transition_, proceed, 982 switches::kEnableBrowserSideNavigation)) {
983 before_unload_end_time); 983 // TODO(clamy): see if before_unload_end_time should be transmitted to the
984 // Navigator.
985 frame_tree_node_->navigator()->OnBeforeUnloadACK(
986 frame_tree_node_, proceed);
987 } else {
988 frame_tree_node_->render_manager()->OnBeforeUnloadACK(
989 unload_ack_is_for_navigation_, proceed,
990 before_unload_end_time);
991 }
984 992
985 // If canceled, notify the delegate to cancel its pending navigation entry. 993 // If canceled, notify the delegate to cancel its pending navigation entry.
986 if (!proceed) 994 if (!proceed)
987 render_view_host_->GetDelegate()->DidCancelLoading(); 995 render_view_host_->GetDelegate()->DidCancelLoading();
988 } 996 }
989 997
990 bool RenderFrameHostImpl::IsWaitingForBeforeUnloadACK() const { 998 bool RenderFrameHostImpl::IsWaitingForBeforeUnloadACK() const {
991 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 999 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
992 switches::kEnableBrowserSideNavigation)) { 1000 switches::kEnableBrowserSideNavigation)) {
993 return is_waiting_for_beforeunload_ack_; 1001 return is_waiting_for_beforeunload_ack_;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 title_direction)); 1130 title_direction));
1123 } 1131 }
1124 1132
1125 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { 1133 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) {
1126 // This message is only sent for top-level frames. TODO(avi): when frame tree 1134 // This message is only sent for top-level frames. TODO(avi): when frame tree
1127 // mirroring works correctly, add a check here to enforce it. 1135 // mirroring works correctly, add a check here to enforce it.
1128 delegate_->UpdateEncoding(this, encoding_name); 1136 delegate_->UpdateEncoding(this, encoding_name);
1129 } 1137 }
1130 1138
1131 void RenderFrameHostImpl::OnBeginNavigation( 1139 void RenderFrameHostImpl::OnBeginNavigation(
1132 const FrameHostMsg_BeginNavigation_Params& params, 1140 const CommonNavigationParams& common_params,
1133 const CommonNavigationParams& common_params) { 1141 const BeginNavigationParams& begin_params,
1142 scoped_refptr<ResourceRequestBody> body) {
1134 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 1143 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
1135 switches::kEnableBrowserSideNavigation)); 1144 switches::kEnableBrowserSideNavigation));
1136 frame_tree_node()->navigator()->OnBeginNavigation( 1145 frame_tree_node()->navigator()->OnBeginNavigation(
1137 frame_tree_node(), params, common_params); 1146 frame_tree_node(), common_params, begin_params, body);
1138 } 1147 }
1139 1148
1140 void RenderFrameHostImpl::OnAccessibilityEvents( 1149 void RenderFrameHostImpl::OnAccessibilityEvents(
1141 const std::vector<AccessibilityHostMsg_EventParams>& params, 1150 const std::vector<AccessibilityHostMsg_EventParams>& params,
1142 int reset_token) { 1151 int reset_token) {
1143 // Don't process this IPC if either we're waiting on a reset and this 1152 // Don't process this IPC if either we're waiting on a reset and this
1144 // IPC doesn't have the matching token ID, or if we're not waiting on a 1153 // IPC doesn't have the matching token ID, or if we're not waiting on a
1145 // reset but this message includes a reset token. 1154 // reset but this message includes a reset token.
1146 if (accessibility_reset_token_ != reset_token) { 1155 if (accessibility_reset_token_ != reset_token) {
1147 Send(new AccessibilityMsg_Events_ACK(routing_id_)); 1156 Send(new AccessibilityMsg_Events_ACK(routing_id_));
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 frame_tree_node_->navigator()->RequestOpenURL( 1465 frame_tree_node_->navigator()->RequestOpenURL(
1457 this, validated_url, source_site_instance, params.referrer, 1466 this, validated_url, source_site_instance, params.referrer,
1458 params.disposition, params.should_replace_current_entry, 1467 params.disposition, params.should_replace_current_entry,
1459 params.user_gesture); 1468 params.user_gesture);
1460 } 1469 }
1461 1470
1462 void RenderFrameHostImpl::Stop() { 1471 void RenderFrameHostImpl::Stop() {
1463 Send(new FrameMsg_Stop(routing_id_)); 1472 Send(new FrameMsg_Stop(routing_id_));
1464 } 1473 }
1465 1474
1466 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { 1475 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation) {
1467 // TODO(creis): Support beforeunload on subframes. For now just pretend that 1476 // TODO(creis): Support beforeunload on subframes. For now just pretend that
1468 // the handler ran and allowed the navigation to proceed. 1477 // the handler ran and allowed the navigation to proceed.
1469 if (GetParent() || !IsRenderFrameLive()) { 1478 if (GetParent() || !IsRenderFrameLive()) {
1470 // We don't have a live renderer, so just skip running beforeunload. 1479 // We don't have a live renderer, so just skip running beforeunload.
1471 frame_tree_node_->render_manager()->OnBeforeUnloadACK( 1480 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1472 for_cross_site_transition, true, base::TimeTicks::Now()); 1481 switches::kEnableBrowserSideNavigation)) {
1482 frame_tree_node_->navigator()->OnBeforeUnloadACK(
1483 frame_tree_node_, true);
1484 } else {
1485 frame_tree_node_->render_manager()->OnBeforeUnloadACK(
1486 for_navigation, true, base::TimeTicks::Now());
1487 }
1473 return; 1488 return;
1474 } 1489 }
1475 TRACE_EVENT_ASYNC_BEGIN0( 1490 TRACE_EVENT_ASYNC_BEGIN0(
1476 "navigation", "RenderFrameHostImpl::BeforeUnload", this); 1491 "navigation", "RenderFrameHostImpl::BeforeUnload", this);
1477 1492
1478 // This may be called more than once (if the user clicks the tab close button 1493 // This may be called more than once (if the user clicks the tab close button
1479 // several times, or if she clicks the tab close button then the browser close 1494 // several times, or if she clicks the tab close button then the browser close
1480 // button), and we only send the message once. 1495 // button), and we only send the message once.
1481 if (is_waiting_for_beforeunload_ack_) { 1496 if (is_waiting_for_beforeunload_ack_) {
1482 // Some of our close messages could be for the tab, others for cross-site 1497 // Some of our close messages could be for the tab, others for cross-site
1483 // transitions. We always want to think it's for closing the tab if any 1498 // transitions. We always want to think it's for closing the tab if any
1484 // of the messages were, since otherwise it might be impossible to close 1499 // of the messages were, since otherwise it might be impossible to close
1485 // (if there was a cross-site "close" request pending when the user clicked 1500 // (if there was a cross-site "close" request pending when the user clicked
1486 // the close button). We want to keep the "for cross site" flag only if 1501 // the close button). We want to keep the "for cross site" flag only if
1487 // both the old and the new ones are also for cross site. 1502 // both the old and the new ones are also for cross site.
1488 unload_ack_is_for_cross_site_transition_ = 1503 unload_ack_is_for_navigation_ =
1489 unload_ack_is_for_cross_site_transition_ && for_cross_site_transition; 1504 unload_ack_is_for_navigation_ && for_navigation;
1490 } else { 1505 } else {
1491 // Start the hang monitor in case the renderer hangs in the beforeunload 1506 // Start the hang monitor in case the renderer hangs in the beforeunload
1492 // handler. 1507 // handler.
1493 is_waiting_for_beforeunload_ack_ = true; 1508 is_waiting_for_beforeunload_ack_ = true;
1494 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; 1509 unload_ack_is_for_navigation_ = for_navigation;
1495 // Increment the in-flight event count, to ensure that input events won't 1510 // Increment the in-flight event count, to ensure that input events won't
1496 // cancel the timeout timer. 1511 // cancel the timeout timer.
1497 render_view_host_->increment_in_flight_event_count(); 1512 render_view_host_->increment_in_flight_event_count();
1498 render_view_host_->StartHangMonitorTimeout( 1513 render_view_host_->StartHangMonitorTimeout(
1499 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); 1514 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS));
1500 send_before_unload_start_time_ = base::TimeTicks::Now(); 1515 send_before_unload_start_time_ = base::TimeTicks::Now();
1501 Send(new FrameMsg_BeforeUnload(routing_id_)); 1516 Send(new FrameMsg_BeforeUnload(routing_id_));
1502 } 1517 }
1503 } 1518 }
1504 1519
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 void RenderFrameHostImpl::DidUseGeolocationPermission() { 1800 void RenderFrameHostImpl::DidUseGeolocationPermission() {
1786 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame(); 1801 RenderFrameHost* top_frame = frame_tree_node()->frame_tree()->GetMainFrame();
1787 GetContentClient()->browser()->RegisterPermissionUsage( 1802 GetContentClient()->browser()->RegisterPermissionUsage(
1788 PERMISSION_GEOLOCATION, 1803 PERMISSION_GEOLOCATION,
1789 delegate_->GetAsWebContents(), 1804 delegate_->GetAsWebContents(),
1790 GetLastCommittedURL().GetOrigin(), 1805 GetLastCommittedURL().GetOrigin(),
1791 top_frame->GetLastCommittedURL().GetOrigin()); 1806 top_frame->GetLastCommittedURL().GetOrigin());
1792 } 1807 }
1793 1808
1794 } // namespace content 1809 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/browser/frame_host/render_frame_host_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698