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

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

Issue 2719133002: A page can't fire dialogs in unload handlers; remove code that handles that case. (Closed)
Patch Set: IPCs when closing? Created 3 years, 10 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 f541c6b760e24ca65c3ab75b3afba37c456d998c..f64e3d03eb47044372c896080a4635eea3c9b3fe 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -1668,10 +1668,8 @@ void RenderFrameHostImpl::OnRunJavaScriptDialog(
const GURL& frame_url,
JavaScriptDialogType dialog_type,
IPC::Message* reply_msg) {
- if (!is_active()) {
- JavaScriptDialogClosed(reply_msg, true, base::string16(),
- /*is_before_unload_dialog=*/false,
- /*dialog_was_suppressed=*/true);
+ if (IsWaitingForUnloadACK()) {
Charlie Reis 2017/02/28 04:59:21 Interesting. Yes, I think this is safer, since it
Avi (use Gerrit) 2017/02/28 05:12:42 Yep. I realized that we already were handling the
+ SendJavaScriptDialogReply(reply_msg, true, base::string16());
return;
}
@@ -2610,20 +2608,15 @@ void RenderFrameHostImpl::JavaScriptDialogClosed(
bool is_before_unload_dialog,
bool dialog_was_suppressed) {
GetProcess()->SetIgnoreInputEvents(false);
- bool is_waiting = is_before_unload_dialog || IsWaitingForUnloadACK();
- // If we are executing as part of (before)unload event handling, we don't
+ // If we are executing as part of beforeunload event handling, we don't
// want to use the regular hung_renderer_delay_ms_ if the user has agreed to
// leave the current page. In this case, use the regular timeout value used
- // during the (before)unload handling.
- if (is_waiting) {
+ // during the beforeunload handling.
+ if (is_before_unload_dialog) {
RendererUnresponsiveType type =
- RendererUnresponsiveType::RENDERER_UNRESPONSIVE_DIALOG_CLOSED;
- if (success) {
- type = is_before_unload_dialog
- ? RendererUnresponsiveType::RENDERER_UNRESPONSIVE_BEFORE_UNLOAD
- : RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNLOAD;
- }
+ success ? RendererUnresponsiveType::RENDERER_UNRESPONSIVE_BEFORE_UNLOAD
clamy 2017/03/01 16:11:00 If we are in the before unload dialog, shouldn't t
Avi (use Gerrit) 2017/03/01 16:17:38 This metric is yours, so I'm trying to preserve ex
clamy 2017/03/01 16:25:56 Well I don't quite remember the choices behind the
+ : RendererUnresponsiveType::RENDERER_UNRESPONSIVE_DIALOG_CLOSED;
render_view_host_->GetWidget()->StartHangMonitorTimeout(
success
? TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS)
@@ -2631,23 +2624,30 @@ void RenderFrameHostImpl::JavaScriptDialogClosed(
blink::WebInputEvent::Undefined, type);
}
- FrameHostMsg_RunJavaScriptDialog::WriteReplyParams(reply_msg, success,
- user_input);
- Send(reply_msg);
+ SendJavaScriptDialogReply(reply_msg, success, user_input);
- // 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 && dialog_was_suppressed) {
+ // If we are waiting for a 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_before_unload_dialog && dialog_was_suppressed) {
render_view_host_->GetWidget()->delegate()->RendererUnresponsive(
render_view_host_->GetWidget(),
RendererUnresponsiveType::RENDERER_UNRESPONSIVE_DIALOG_SUPPRESSED);
}
}
+void RenderFrameHostImpl::SendJavaScriptDialogReply(
+ IPC::Message* reply_msg,
+ bool success,
+ const base::string16& user_input) {
+ FrameHostMsg_RunJavaScriptDialog::WriteReplyParams(reply_msg, success,
+ user_input);
+ Send(reply_msg);
+}
+
// PlzNavigate
void RenderFrameHostImpl::CommitNavigation(
ResourceResponse* response,
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.h ('k') | content/public/browser/renderer_unresponsive_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698