diff options
Diffstat (limited to 'content/browser/frame_host')
4 files changed, 30 insertions, 113 deletions
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc index 832911c..c9125d8 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc @@ -13,7 +13,6 @@ #include "content/browser/accessibility/browser_accessibility_manager.h" #include "content/browser/accessibility/browser_accessibility_state_impl.h" #include "content/browser/child_process_security_policy_impl.h" -#include "content/browser/cross_site_request_manager.h" #include "content/browser/frame_host/cross_process_frame_connector.h" #include "content/browser/frame_host/cross_site_transferring_request.h" #include "content/browser/frame_host/frame_tree.h" @@ -167,7 +166,6 @@ RenderFrameHostImpl::RenderFrameHostImpl(RenderViewHostImpl* render_view_host, routing_id_(routing_id), is_swapped_out_(is_swapped_out), renderer_initialized_(false), - navigations_suspended_(false), weak_ptr_factory_(this) { frame_tree_->RegisterRenderFrameHost(this); GetProcess()->AddRoute(routing_id_, this); @@ -190,10 +188,6 @@ RenderFrameHostImpl::~RenderFrameHostImpl() { GetProcess()->RemoveRoute(routing_id_); g_routing_id_frame_map.Get().erase( RenderFrameHostID(GetProcess()->GetID(), routing_id_)); - // Clean up any leftover state from cross-site requests. - CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( - GetProcess()->GetID(), routing_id_, false); - if (delegate_) delegate_->RenderFrameDeleted(this); @@ -1017,13 +1011,14 @@ void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { // Only send the message if we aren't suspended at the start of a cross-site // request. - if (navigations_suspended_) { + if (render_view_host_->navigations_suspended_) { // Shouldn't be possible to have a second navigation while suspended, since // navigations will only be suspended during a cross-site request. If a // second navigation occurs, RenderFrameHostManager will cancel this pending // RFH and create a new pending RFH. - DCHECK(!suspended_nav_params_.get()); - suspended_nav_params_.reset(new FrameMsg_Navigate_Params(params)); + DCHECK(!render_view_host_->suspended_nav_params_.get()); + render_view_host_->suspended_nav_params_.reset( + new FrameMsg_Navigate_Params(params)); } else { // Get back to a clean state, in case we start a new navigation without // completing a RVH swap or unload handler. @@ -1146,17 +1141,6 @@ void RenderFrameHostImpl::NotificationClosed(int notification_id) { cancel_notification_callbacks_.erase(notification_id); } -bool RenderFrameHostImpl::HasPendingCrossSiteRequest() { - return CrossSiteRequestManager::GetInstance()->HasPendingCrossSiteRequest( - GetProcess()->GetID(), routing_id_); -} - -void RenderFrameHostImpl::SetHasPendingCrossSiteRequest( - bool has_pending_request) { - CrossSiteRequestManager::GetInstance()->SetHasPendingCrossSiteRequest( - GetProcess()->GetID(), routing_id_, has_pending_request); -} - void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( int request_id, blink::WebNotificationPermission permission) { Send(new PlatformNotificationMsg_PermissionRequestComplete( @@ -1214,31 +1198,4 @@ void RenderFrameHostImpl::ClearPendingTransitionRequestData() { routing_id_)); } -void RenderFrameHostImpl::SetNavigationsSuspended( - bool suspend, - const base::TimeTicks& proceed_time) { - // This should only be called to toggle the state. - DCHECK(navigations_suspended_ != suspend); - - navigations_suspended_ = suspend; - if (!suspend && suspended_nav_params_) { - // There's navigation message params waiting to be sent. Now that we're not - // suspended anymore, resume navigation by sending them. If we were swapped - // out, we should also stop filtering out the IPC messages now. - render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); - - DCHECK(!proceed_time.is_null()); - suspended_nav_params_->browser_navigation_start = proceed_time; - Send(new FrameMsg_Navigate(routing_id_, *suspended_nav_params_)); - suspended_nav_params_.reset(); - } -} - -void RenderFrameHostImpl::CancelSuspendedNavigations() { - // Clear any state if a pending navigation is canceled or preempted. - if (suspended_nav_params_) - suspended_nav_params_.reset(); - navigations_suspended_ = false; -} - } // namespace content diff --git a/content/browser/frame_host/render_frame_host_impl.h b/content/browser/frame_host/render_frame_host_impl.h index de6a58e..cb9f60d 100644 --- a/content/browser/frame_host/render_frame_host_impl.h +++ b/content/browser/frame_host/render_frame_host_impl.h @@ -189,30 +189,6 @@ class CONTENT_EXPORT RenderFrameHostImpl // Load the specified URL; this is a shortcut for Navigate(). void NavigateToURL(const GURL& url); - // Returns whether navigation messages are currently suspended for this - // RenderFrameHost. Only true during a cross-site navigation, while waiting - // for the onbeforeunload handler. - bool are_navigations_suspended() const { return navigations_suspended_; } - - // Suspends (or unsuspends) any navigation messages from being sent from this - // RenderFrameHost. This is called when a pending RenderFrameHost is created - // for a cross-site navigation, because we must suspend any navigations until - // we hear back from the old renderer's onbeforeunload handler. Note that it - // is important that only one navigation event happen after calling this - // method with |suspend| equal to true. If |suspend| is false and there is a - // suspended_nav_message_, this will send the message. This function should - // only be called to toggle the state; callers should check - // are_navigations_suspended() first. If |suspend| is false, the time that the - // user decided the navigation should proceed should be passed as - // |proceed_time|. - void SetNavigationsSuspended(bool suspend, - const base::TimeTicks& proceed_time); - - // Clears any suspended navigation state after a cross-site navigation is - // canceled or suspended. This is important if we later return to this - // RenderFrameHost. - void CancelSuspendedNavigations(); - // Runs the beforeunload handler for this frame. |for_cross_site_transition| // indicates whether this call is for the current frame during a cross-process // navigation. False means we're closing the entire tab. @@ -267,17 +243,6 @@ class CONTENT_EXPORT RenderFrameHostImpl gfx::NativeViewAccessible GetParentNativeViewAccessible() const; #endif - // Returns whether this RenderFrameHost has an outstanding cross-site request. - // Cleared when we hear the response and start to swap out the old - // RenderFrameHost, or if we hear a commit here without a network request. - bool HasPendingCrossSiteRequest(); - - // Sets whether this RenderFrameHost has an outstanding cross-site request, - // for which another renderer will need to run an onunload event handler. - // This is called before the first navigation event for this RenderFrameHost, - // and cleared when we hear the response or commit. - void SetHasPendingCrossSiteRequest(bool has_pending_request); - protected: friend class RenderFrameHostFactory; @@ -409,19 +374,6 @@ class CONTENT_EXPORT RenderFrameHostImpl bool is_swapped_out_; bool renderer_initialized_; - // Whether we should buffer outgoing Navigate messages rather than sending - // them. This will be true when a RenderFrameHost is created for a cross-site - // request, until we hear back from the onbeforeunload handler of the old - // RenderFrameHost. - bool navigations_suspended_; - - // We only buffer the params for a suspended navigation while this RFH is the - // pending RenderFrameHost of a RenderFrameHostManager. There will only ever - // be one suspended navigation, because RenderFrameHostManager will destroy - // the pending RenderFrameHost and create a new one if a second navigation - // occurs. - scoped_ptr<FrameMsg_Navigate_Params> suspended_nav_params_; - // When the last BeforeUnload message was sent. base::TimeTicks send_before_unload_start_time_; diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc index b40cc2b..618391f 100644 --- a/content/browser/frame_host/render_frame_host_manager.cc +++ b/content/browser/frame_host/render_frame_host_manager.cc @@ -273,8 +273,9 @@ bool RenderFrameHostManager::ShouldCloseTabOnUnresponsiveRenderer() { // that the beforeunload handler will later finish and possibly return // false (meaning the navigation should not proceed), but we'll ignore it // in this case because it took too long. - if (pending_render_frame_host_->are_navigations_suspended()) { - pending_render_frame_host_->SetNavigationsSuspended( + if (pending_render_frame_host_->render_view_host()-> + are_navigations_suspended()) { + pending_render_frame_host_->render_view_host()->SetNavigationsSuspended( false, base::TimeTicks::Now()); } } @@ -297,9 +298,10 @@ void RenderFrameHostManager::OnBeforeUnloadACK( // already made by ShouldCloseTabOnUnresponsiveRenderer. In that case, it // is ok to do nothing here. if (pending_render_frame_host_ && - pending_render_frame_host_->are_navigations_suspended()) { - pending_render_frame_host_->SetNavigationsSuspended(false, - proceed_time); + pending_render_frame_host_->render_view_host()-> + are_navigations_suspended()) { + pending_render_frame_host_->render_view_host()-> + SetNavigationsSuspended(false, proceed_time); } } else { // Current page says to cancel. @@ -456,7 +458,8 @@ void RenderFrameHostManager::DidNavigateFrame( // then we still need to swap out the old RFH first and run its unload // handler, only if it hasn't happened yet. OK for that to happen in the // background. - if (pending_render_frame_host_->HasPendingCrossSiteRequest() && + if (pending_render_frame_host_->render_view_host()-> + HasPendingCrossSiteRequest() && pending_render_frame_host_->render_view_host()->rvh_state() == RenderViewHostImpl::STATE_DEFAULT) { SwapOutOldPage(); @@ -546,7 +549,8 @@ void RenderFrameHostManager::SwapOutOldPage() { // navigation. Thus, we no longer need to remember that the RenderFrameHost // is part of a pending cross-site request. if (pending_render_frame_host_) { - pending_render_frame_host_->SetHasPendingCrossSiteRequest(false); + pending_render_frame_host_->render_view_host()-> + SetHasPendingCrossSiteRequest(false); } } @@ -1405,7 +1409,8 @@ RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( // Navigate message) until we hear back from the old renderer's // beforeunload handler. If the handler returns false, we'll have to // cancel the request. - DCHECK(!pending_render_frame_host_->are_navigations_suspended()); + DCHECK(!pending_render_frame_host_->render_view_host()-> + are_navigations_suspended()); bool is_transfer = entry.transferred_global_request_id() != GlobalRequestID(); if (is_transfer) { @@ -1420,13 +1425,15 @@ RenderFrameHostImpl* RenderFrameHostManager::UpdateStateForNavigate( render_frame_host_->render_view_host()->Send(new ViewMsg_Stop( render_frame_host_->render_view_host()->GetRoutingID())); - pending_render_frame_host_->SetNavigationsSuspended(true, - base::TimeTicks()); + pending_render_frame_host_->render_view_host()->SetNavigationsSuspended( + true, base::TimeTicks()); - // Tell the CrossSiteRequestManager that this RFH has a pending cross-site + // Tell the CrossSiteRequestManager that this RVH has a pending cross-site // request, so that ResourceDispatcherHost will know to tell us to run the // old page's unload handler before it sends the response. - pending_render_frame_host_->SetHasPendingCrossSiteRequest(true); + // TODO(creis): This needs to be on the RFH. + pending_render_frame_host_->render_view_host()-> + SetHasPendingCrossSiteRequest(true); } // We now have a pending RFH. @@ -1501,7 +1508,7 @@ void RenderFrameHostManager::CancelPending() { pending_render_frame_host->GetSiteInstance()); if (site_instance->active_view_count() > 1) { // Any currently suspended navigations are no longer needed. - pending_render_frame_host->CancelSuspendedNavigations(); + pending_render_frame_host->render_view_host()->CancelSuspendedNavigations(); RenderFrameProxyHost* proxy = new RenderFrameProxyHost(site_instance, frame_tree_node_); diff --git a/content/browser/frame_host/render_frame_host_manager_unittest.cc b/content/browser/frame_host/render_frame_host_manager_unittest.cc index e8db0e1..1a76c36 100644 --- a/content/browser/frame_host/render_frame_host_manager_unittest.cc +++ b/content/browser/frame_host/render_frame_host_manager_unittest.cc @@ -925,7 +925,7 @@ TEST_F(RenderFrameHostManagerTest, NavigateWithEarlyReNavigation) { // Check that the navigation is still suspended because the old RVH // is not swapped out, yet. - EXPECT_TRUE(host2->are_navigations_suspended()); + EXPECT_TRUE(host2->render_view_host()->are_navigations_suspended()); MockRenderProcessHost* test_process_host2 = static_cast<MockRenderProcessHost*>(host2->GetProcess()); test_process_host2->sink().ClearMessages(); @@ -976,7 +976,8 @@ TEST_F(RenderFrameHostManagerTest, NavigateWithEarlyReNavigation) { EXPECT_NE(host3->GetProcess()->GetID(), host2_process_id); // Navigations in the new RVH should be suspended. - EXPECT_TRUE(host3->are_navigations_suspended()); + EXPECT_TRUE(static_cast<RenderViewHostImpl*>( + host3->render_view_host())->are_navigations_suspended()); EXPECT_EQ(host, manager->current_frame_host()); EXPECT_FALSE(manager->current_frame_host()->is_swapped_out()); @@ -1047,10 +1048,10 @@ TEST_F(RenderFrameHostManagerTest, NewCrossNavigationBetweenSwapOutAndCommit) { // Pending rvh2 is already deleted. contents()->ProceedWithCrossSiteNavigation(); - TestRenderFrameHost* rfh3 = pending_main_test_rfh(); - EXPECT_TRUE(rfh3); + TestRenderViewHost* rvh3 = pending_test_rvh(); + EXPECT_TRUE(rvh3); // Navigation should be already unblocked by rvh1. - EXPECT_FALSE(rfh3->are_navigations_suspended()); + EXPECT_FALSE(rvh3->are_navigations_suspended()); } // Tests WebUI creation. |