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

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: now a bit on webcontents, no timer fiddling 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 c8b5dcc9fbd8a11090cd2d404fdbcc9cc96cc1bd..3a9303bc76b79f91f78647c8d3779e0a450340c4 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -2388,14 +2388,26 @@ 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 (delegate_->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. Instead, force the page to be in "waiting for
+ // unload ack", and tell the widget's delegate that the renderer is
+ // unresponsive. That will let the page close immediately.
+ render_view_host_->is_waiting_for_close_ack_ = true;
+ render_view_host_->GetWidget()->delegate()->RendererUnresponsive(
+ render_view_host_->GetWidget(),
+ RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_DIALOG_SHOWING);
Charlie Reis 2016/10/07 22:44:23 Could we call OnBeforeUnloadACK(true, ...) here in
Avi (use Gerrit) 2016/10/08 00:13:19 I was hoping to run past both issues with one call
+ } 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));
+ }
}
}
« no previous file with comments | « content/browser/frame_host/render_frame_host_delegate.cc ('k') | content/browser/renderer_host/render_widget_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698