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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 2370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2381 // (if there was a cross-site "close" request pending when the user clicked 2381 // (if there was a cross-site "close" request pending when the user clicked
2382 // the close button). We want to keep the "for cross site" flag only if 2382 // the close button). We want to keep the "for cross site" flag only if
2383 // both the old and the new ones are also for cross site. 2383 // both the old and the new ones are also for cross site.
2384 unload_ack_is_for_navigation_ = 2384 unload_ack_is_for_navigation_ =
2385 unload_ack_is_for_navigation_ && for_navigation; 2385 unload_ack_is_for_navigation_ && for_navigation;
2386 } else { 2386 } else {
2387 // Start the hang monitor in case the renderer hangs in the beforeunload 2387 // Start the hang monitor in case the renderer hangs in the beforeunload
2388 // handler. 2388 // handler.
2389 is_waiting_for_beforeunload_ack_ = true; 2389 is_waiting_for_beforeunload_ack_ = true;
2390 unload_ack_is_for_navigation_ = for_navigation; 2390 unload_ack_is_for_navigation_ = for_navigation;
2391 // Increment the in-flight event count, to ensure that input events won't 2391 if (delegate_->IsJavaScriptDialogShowing()) {
2392 // cancel the timeout timer. 2392 // If there is a JavaScript dialog up, don't bother sending the renderer
2393 render_view_host_->GetWidget()->increment_in_flight_event_count(); 2393 // the unload event because it is known unresponsive, waiting for the
2394 render_view_host_->GetWidget()->StartHangMonitorTimeout( 2394 // reply from the dialog. Instead, force the page to be in "waiting for
2395 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS), 2395 // unload ack", and tell the widget's delegate that the renderer is
2396 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_BEFORE_UNLOAD); 2396 // unresponsive. That will let the page close immediately.
2397 send_before_unload_start_time_ = base::TimeTicks::Now(); 2397 render_view_host_->is_waiting_for_close_ack_ = true;
2398 Send(new FrameMsg_BeforeUnload(routing_id_, is_reload)); 2398 render_view_host_->GetWidget()->delegate()->RendererUnresponsive(
2399 render_view_host_->GetWidget(),
2400 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
2401 } else {
2402 // Increment the in-flight event count, to ensure that input events won't
2403 // cancel the timeout timer.
2404 render_view_host_->GetWidget()->increment_in_flight_event_count();
2405 render_view_host_->GetWidget()->StartHangMonitorTimeout(
2406 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS),
2407 RenderWidgetHostDelegate::RENDERER_UNRESPONSIVE_BEFORE_UNLOAD);
2408 send_before_unload_start_time_ = base::TimeTicks::Now();
2409 Send(new FrameMsg_BeforeUnload(routing_id_, is_reload));
2410 }
2399 } 2411 }
2400 } 2412 }
2401 2413
2402 void RenderFrameHostImpl::SimulateBeforeUnloadAck() { 2414 void RenderFrameHostImpl::SimulateBeforeUnloadAck() {
2403 DCHECK(is_waiting_for_beforeunload_ack_); 2415 DCHECK(is_waiting_for_beforeunload_ack_);
2404 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; 2416 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_;
2405 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); 2417 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now());
2406 } 2418 }
2407 2419
2408 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() { 2420 bool RenderFrameHostImpl::ShouldDispatchBeforeUnload() {
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
3114 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( 3126 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind(
3115 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); 3127 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this)));
3116 return web_bluetooth_service_.get(); 3128 return web_bluetooth_service_.get();
3117 } 3129 }
3118 3130
3119 void RenderFrameHostImpl::DeleteWebBluetoothService() { 3131 void RenderFrameHostImpl::DeleteWebBluetoothService() {
3120 web_bluetooth_service_.reset(); 3132 web_bluetooth_service_.reset();
3121 } 3133 }
3122 3134
3123 } // namespace content 3135 } // namespace content
OLDNEW
« 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