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

Unified Diff: chrome/browser/renderer_host/render_view_host.cc

Issue 3621009: Fix handling of JS dialog suppressino during tab closing (Closed)
Patch Set: Comment fix Created 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/render_view_host.cc
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 143bc1a7f099741711d9f2e8f2a2182b2affed7c..708e77a4b75fe3d1043c7655806159b97fdd64a5 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -594,18 +594,21 @@ void RenderViewHost::JavaScriptMessageBoxClosed(IPC::Message* reply_msg,
process()->set_ignore_input_events(false);
bool is_waiting =
is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_;
- if (is_waiting) {
- if (are_javascript_messages_suppressed_) {
- delegate_->RendererUnresponsive(this, is_waiting);
- return;
- }
-
+ if (is_waiting)
StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
- }
ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg,
success, prompt);
Send(reply_msg);
+
+ // If we are waiting for an unload or beforeunload ack and the user has
+ // suppressed messages, kill the tab immediately; a page that's spamming
+ // alerts in onbeforeunload is presumably malicious, so there's no point in
+ // continuing to run its script and dragging out the process.
+ // This must be done after sending the reply since RenderView can't close
+ // correctly while waiting for a response.
+ if (is_waiting && are_javascript_messages_suppressed_)
+ delegate_->RendererUnresponsive(this, is_waiting);
}
void RenderViewHost::ModalHTMLDialogClosed(IPC::Message* reply_msg,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698