Index: content/browser/renderer_host/render_view_host.cc |
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc |
index 40792b1a501f8cc9287fbb36dfc559b3ddb4a089..df5f1e1990cd804ae3f62cb1573fe860468296ea 100644 |
--- a/content/browser/renderer_host/render_view_host.cc |
+++ b/content/browser/renderer_host/render_view_host.cc |
@@ -293,8 +293,9 @@ void RenderViewHost::FirePageBeforeUnload(bool for_cross_site_transition) { |
void RenderViewHost::ClosePage(bool for_cross_site_transition, |
int new_render_process_host_id, |
int new_request_id) { |
- // In most cases, this will not be set to false afterward. Either the tab |
- // will be closed, or a pending RenderViewHost will replace this one. |
+ // This will be set back to false in OnClosePageACK, just before we close the |
+ // tab or replace it with a pending RVH. There are some cases (such as 204 |
+ // errors) where we'll continue to show this RVH. |
is_waiting_for_unload_ack_ = true; |
// Start the hang monitor in case the renderer hangs in the unload handler. |
StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
@@ -320,6 +321,18 @@ void RenderViewHost::ClosePage(bool for_cross_site_transition, |
} |
} |
+void RenderViewHost::OnClosePageACK(bool for_cross_site_transition) { |
+ StopHangMonitorTimeout(); |
+ is_waiting_for_unload_ack_ = false; |
+ |
+ // If this ClosePageACK is not for a cross-site transition, then it is for an |
+ // attempt to close the tab. We have now finished the unload handler and can |
+ // proceed with closing the tab. |
+ if (!for_cross_site_transition) { |
+ ClosePageIgnoringUnloadEvents(); |
+ } |
+} |
+ |
void RenderViewHost::ClosePageIgnoringUnloadEvents() { |
StopHangMonitorTimeout(); |
is_waiting_for_beforeunload_ack_ = false; |