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

Unified Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2384813002: Don't wait to close tabs waiting for JavaScript dialogs. (Closed)
Patch Set: better Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
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 bec107a0310158510676507e8e07a6a9e10b3284..c2e3b61bb2443d90f5a5f1c2a0d0d04035b7633b 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -2384,14 +2384,21 @@ void RenderFrameHostImpl::DispatchBeforeUnload(bool for_navigation,
// handler.
is_waiting_for_beforeunload_ack_ = true;
unload_ack_is_for_navigation_ = for_navigation;
- // Increment the in-flight event count, to ensure that input events won't
- // cancel the timeout timer.
- render_view_host_->GetWidget()->increment_in_flight_event_count();
- render_view_host_->GetWidget()->StartHangMonitorTimeout(
- TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS),
- RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_BEFORE_UNLOAD);
- send_before_unload_start_time_ = base::TimeTicks::Now();
- Send(new FrameMsg_BeforeUnload(routing_id_, is_reload));
+ if (render_view_host_->GetDelegate()->IsJavaScriptDialogShowing()) {
+ // If there is a JavaScript dialog up, don't bother sending the renderer
+ // the unload event because it is known unresponsive, waiting for the
+ // reply from the dialog.
+ SimulateBeforeUnloadAck();
+ } else {
+ // Increment the in-flight event count, to ensure that input events won't
+ // cancel the timeout timer.
+ render_view_host_->GetWidget()->increment_in_flight_event_count();
+ render_view_host_->GetWidget()->StartHangMonitorTimeout(
+ TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS),
+ RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_BEFORE_UNLOAD);
+ send_before_unload_start_time_ = base::TimeTicks::Now();
+ Send(new FrameMsg_BeforeUnload(routing_id_, is_reload));
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698