Chromium Code Reviews| Index: content/browser/frame_host/render_frame_host_impl.cc |
| diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc |
| index 0f5b5ce80f5c5d90e1363b53e76ea2395815b71d..3b980a40e7e18067e201a1f123019abb45b9dd14 100644 |
| --- a/content/browser/frame_host/render_frame_host_impl.cc |
| +++ b/content/browser/frame_host/render_frame_host_impl.cc |
| @@ -1678,16 +1678,13 @@ void RenderFrameHostImpl::Stop() { |
| void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation) { |
| // TODO(creis): Support beforeunload on subframes. For now just pretend that |
| // the handler ran and allowed the navigation to proceed. |
| - if (GetParent() || !IsRenderFrameLive()) { |
| - // We don't have a live renderer, so just skip running beforeunload. |
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kEnableBrowserSideNavigation)) { |
| - frame_tree_node_->navigator()->OnBeforeUnloadACK( |
| - frame_tree_node_, true); |
| - } else { |
| - frame_tree_node_->render_manager()->OnBeforeUnloadACK( |
| - for_navigation, true, base::TimeTicks::Now()); |
| - } |
| + if (!ShouldDispatchBeforeUnload()) { |
| + // There's no live renderer or this is a subframe, so just skip running |
| + // BeforeUnload. |
| + DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableBrowserSideNavigation)); |
|
clamy
2015/06/10 12:30:27
The check should be:
!base::CommandLine::ForCurren
carlosk
2015/06/10 13:15:05
Done. I missed that part from the previous comment
|
| + frame_tree_node_->render_manager()->OnBeforeUnloadACK( |
| + for_navigation, true, base::TimeTicks::Now()); |
| return; |
| } |
| TRACE_EVENT_ASYNC_BEGIN0( |
| @@ -1720,6 +1717,12 @@ void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation) { |
| } |
| } |
| +bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() { |
| + // TODO(creis): Support beforeunload on subframes. For now just pretend that |
|
clamy
2015/06/10 12:30:27
Remove the sentence starting with "For now..."
carlosk
2015/06/10 13:15:05
Done.
|
| + // the handler ran and allowed the navigation to proceed. |
| + return !GetParent() && IsRenderFrameLive(); |
| +} |
| + |
| void RenderFrameHostImpl::DisownOpener() { |
| Send(new FrameMsg_DisownOpener(GetRoutingID())); |
| } |