diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-08 23:02:06 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-08 23:02:06 +0000 |
commit | 1c3f80bd50acda130efa17afbb7cd2dffaca985f (patch) | |
tree | 50f03eedd76b0ab1aedb5f6e1408b9df39cace0c /content/browser/frame_host | |
parent | 2c271bf1db015fa0eff61203e7fab2f07b920c77 (diff) | |
download | chromium_src-1c3f80bd50acda130efa17afbb7cd2dffaca985f.zip chromium_src-1c3f80bd50acda130efa17afbb7cd2dffaca985f.tar.gz chromium_src-1c3f80bd50acda130efa17afbb7cd2dffaca985f.tar.bz2 |
Move DispatchBeforeUnload from RenderFrameHost to WebContents. This is after discussions to move as much stuff as possible to WebContents.
BUG=304341
R=creis@chromium.org
Review URL: https://codereview.chromium.org/228653007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262535 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/frame_host')
-rw-r--r-- | content/browser/frame_host/render_frame_host_impl.cc | 86 | ||||
-rw-r--r-- | content/browser/frame_host/render_frame_host_impl.h | 6 |
2 files changed, 48 insertions, 44 deletions
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc index acad10c..69c0188 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc @@ -133,49 +133,6 @@ gfx::NativeView RenderFrameHostImpl::GetNativeView() { return view->GetNativeView(); } -void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { - // TODO(creis): Support subframes. - DCHECK(!GetParent()); - - if (!render_view_host_->IsRenderViewLive()) { - // We don't have a live renderer, so just skip running beforeunload. - render_view_host_->is_waiting_for_beforeunload_ack_ = true; - render_view_host_->unload_ack_is_for_cross_site_transition_ = - for_cross_site_transition; - base::TimeTicks now = base::TimeTicks::Now(); - OnBeforeUnloadACK(true, now, now); - return; - } - - // This may be called more than once (if the user clicks the tab close button - // several times, or if she clicks the tab close button then the browser close - // button), and we only send the message once. - if (render_view_host_->is_waiting_for_beforeunload_ack_) { - // Some of our close messages could be for the tab, others for cross-site - // transitions. We always want to think it's for closing the tab if any - // of the messages were, since otherwise it might be impossible to close - // (if there was a cross-site "close" request pending when the user clicked - // the close button). We want to keep the "for cross site" flag only if - // both the old and the new ones are also for cross site. - render_view_host_->unload_ack_is_for_cross_site_transition_ = - render_view_host_->unload_ack_is_for_cross_site_transition_ && - for_cross_site_transition; - } else { - // Start the hang monitor in case the renderer hangs in the beforeunload - // handler. - render_view_host_->is_waiting_for_beforeunload_ack_ = true; - render_view_host_->unload_ack_is_for_cross_site_transition_ = - for_cross_site_transition; - // Increment the in-flight event count, to ensure that input events won't - // cancel the timeout timer. - render_view_host_->increment_in_flight_event_count(); - render_view_host_->StartHangMonitorTimeout( - TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); - send_before_unload_start_time_ = base::TimeTicks::Now(); - Send(new FrameMsg_BeforeUnload(routing_id_)); - } -} - void RenderFrameHostImpl::ExecuteJavaScript( const base::string16& javascript) { Send(new FrameMsg_JavaScriptExecuteRequest(routing_id_, @@ -688,6 +645,49 @@ void RenderFrameHostImpl::NavigateToURL(const GURL& url) { Navigate(params); } +void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { + // TODO(creis): Support subframes. + DCHECK(!GetParent()); + + if (!render_view_host_->IsRenderViewLive()) { + // We don't have a live renderer, so just skip running beforeunload. + render_view_host_->is_waiting_for_beforeunload_ack_ = true; + render_view_host_->unload_ack_is_for_cross_site_transition_ = + for_cross_site_transition; + base::TimeTicks now = base::TimeTicks::Now(); + OnBeforeUnloadACK(true, now, now); + return; + } + + // This may be called more than once (if the user clicks the tab close button + // several times, or if she clicks the tab close button then the browser close + // button), and we only send the message once. + if (render_view_host_->is_waiting_for_beforeunload_ack_) { + // Some of our close messages could be for the tab, others for cross-site + // transitions. We always want to think it's for closing the tab if any + // of the messages were, since otherwise it might be impossible to close + // (if there was a cross-site "close" request pending when the user clicked + // the close button). We want to keep the "for cross site" flag only if + // both the old and the new ones are also for cross site. + render_view_host_->unload_ack_is_for_cross_site_transition_ = + render_view_host_->unload_ack_is_for_cross_site_transition_ && + for_cross_site_transition; + } else { + // Start the hang monitor in case the renderer hangs in the beforeunload + // handler. + render_view_host_->is_waiting_for_beforeunload_ack_ = true; + render_view_host_->unload_ack_is_for_cross_site_transition_ = + for_cross_site_transition; + // Increment the in-flight event count, to ensure that input events won't + // cancel the timeout timer. + render_view_host_->increment_in_flight_event_count(); + render_view_host_->StartHangMonitorTimeout( + TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)); + send_before_unload_start_time_ = base::TimeTicks::Now(); + Send(new FrameMsg_BeforeUnload(routing_id_)); + } +} + void RenderFrameHostImpl::ExtendSelectionAndDelete(size_t before, size_t after) { Send(new FrameMsg_ExtendSelectionAndDelete(routing_id_, before, after)); diff --git a/content/browser/frame_host/render_frame_host_impl.h b/content/browser/frame_host/render_frame_host_impl.h index 815afeb..882b9a6 100644 --- a/content/browser/frame_host/render_frame_host_impl.h +++ b/content/browser/frame_host/render_frame_host_impl.h @@ -55,7 +55,6 @@ class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost { virtual bool IsCrossProcessSubframe() OVERRIDE; virtual GURL GetLastCommittedURL() OVERRIDE; virtual gfx::NativeView GetNativeView() OVERRIDE; - virtual void DispatchBeforeUnload(bool for_cross_site_transition) OVERRIDE; virtual void ExecuteJavaScript( const base::string16& javascript) OVERRIDE; virtual void ExecuteJavaScript( @@ -143,6 +142,11 @@ class CONTENT_EXPORT RenderFrameHostImpl : public RenderFrameHost { // Load the specified URL; this is a shortcut for Navigate(). void NavigateToURL(const GURL& url); + // 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. + void DispatchBeforeUnload(bool for_cross_site_transition); + // Deletes the current selection plus the specified number of characters // before and after the selection or caret. void ExtendSelectionAndDelete(size_t before, size_t after); |