OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 2526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2537 // If there is a JavaScript dialog up, don't bother sending the renderer | 2537 // If there is a JavaScript dialog up, don't bother sending the renderer |
2538 // the unload event because it is known unresponsive, waiting for the | 2538 // the unload event because it is known unresponsive, waiting for the |
2539 // reply from the dialog. | 2539 // reply from the dialog. |
2540 SimulateBeforeUnloadAck(); | 2540 SimulateBeforeUnloadAck(); |
2541 } else { | 2541 } else { |
2542 // Increment the in-flight event count, to ensure that input events won't | 2542 // Increment the in-flight event count, to ensure that input events won't |
2543 // cancel the timeout timer. | 2543 // cancel the timeout timer. |
2544 render_view_host_->GetWidget()->increment_in_flight_event_count(); | 2544 render_view_host_->GetWidget()->increment_in_flight_event_count(); |
2545 render_view_host_->GetWidget()->StartHangMonitorTimeout( | 2545 render_view_host_->GetWidget()->StartHangMonitorTimeout( |
2546 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS), | 2546 TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS), |
2547 blink::WebInputEvent::Undefined, | 2547 blink::WebInputEvent::Undefined); |
2548 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_BEFORE_UNLOAD); | |
2549 send_before_unload_start_time_ = base::TimeTicks::Now(); | 2548 send_before_unload_start_time_ = base::TimeTicks::Now(); |
2550 Send(new FrameMsg_BeforeUnload(routing_id_, is_reload)); | 2549 Send(new FrameMsg_BeforeUnload(routing_id_, is_reload)); |
2551 } | 2550 } |
2552 } | 2551 } |
2553 } | 2552 } |
2554 | 2553 |
2555 void RenderFrameHostImpl::SimulateBeforeUnloadAck() { | 2554 void RenderFrameHostImpl::SimulateBeforeUnloadAck() { |
2556 DCHECK(is_waiting_for_beforeunload_ack_); | 2555 DCHECK(is_waiting_for_beforeunload_ack_); |
2557 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; | 2556 base::TimeTicks approx_renderer_start_time = send_before_unload_start_time_; |
2558 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); | 2557 OnBeforeUnloadACK(true, approx_renderer_start_time, base::TimeTicks::Now()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2612 const base::string16& user_input, | 2611 const base::string16& user_input, |
2613 bool is_before_unload_dialog, | 2612 bool is_before_unload_dialog, |
2614 bool dialog_was_suppressed) { | 2613 bool dialog_was_suppressed) { |
2615 GetProcess()->SetIgnoreInputEvents(false); | 2614 GetProcess()->SetIgnoreInputEvents(false); |
2616 | 2615 |
2617 // If we are executing as part of beforeunload event handling, we don't | 2616 // If we are executing as part of beforeunload event handling, we don't |
2618 // want to use the regular hung_renderer_delay_ms_ if the user has agreed to | 2617 // want to use the regular hung_renderer_delay_ms_ if the user has agreed to |
2619 // leave the current page. In this case, use the regular timeout value used | 2618 // leave the current page. In this case, use the regular timeout value used |
2620 // during the beforeunload handling. | 2619 // during the beforeunload handling. |
2621 if (is_before_unload_dialog) { | 2620 if (is_before_unload_dialog) { |
2622 RendererUnresponsiveType type = | |
2623 success ? RendererUnresponsiveType::RENDERER_UNRESPONSIVE_BEFORE_UNLOAD | |
2624 : RendererUnresponsiveType::RENDERER_UNRESPONSIVE_DIALOG_CLOSED; | |
2625 render_view_host_->GetWidget()->StartHangMonitorTimeout( | 2621 render_view_host_->GetWidget()->StartHangMonitorTimeout( |
2626 success | 2622 success |
2627 ? TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS) | 2623 ? TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS) |
2628 : render_view_host_->GetWidget()->hung_renderer_delay(), | 2624 : render_view_host_->GetWidget()->hung_renderer_delay(), |
2629 blink::WebInputEvent::Undefined, type); | 2625 blink::WebInputEvent::Undefined); |
2630 } | 2626 } |
2631 | 2627 |
2632 SendJavaScriptDialogReply(reply_msg, success, user_input); | 2628 SendJavaScriptDialogReply(reply_msg, success, user_input); |
2633 | 2629 |
2634 // If we are waiting for a beforeunload ack and the user has suppressed | 2630 // If we are waiting for a beforeunload ack and the user has suppressed |
2635 // messages, kill the tab immediately; a page that's spamming alerts in | 2631 // messages, kill the tab immediately; a page that's spamming alerts in |
2636 // onbeforeunload is presumably malicious, so there's no point in continuing | 2632 // onbeforeunload is presumably malicious, so there's no point in continuing |
2637 // to run its script and dragging out the process. This must be done after | 2633 // to run its script and dragging out the process. This must be done after |
2638 // sending the reply since RenderView can't close correctly while waiting for | 2634 // sending the reply since RenderView can't close correctly while waiting for |
2639 // a response. | 2635 // a response. |
2640 if (is_before_unload_dialog && dialog_was_suppressed) { | 2636 if (is_before_unload_dialog && dialog_was_suppressed) { |
2641 render_view_host_->GetWidget()->delegate()->RendererUnresponsive( | 2637 render_view_host_->GetWidget()->delegate()->RendererUnresponsive( |
2642 render_view_host_->GetWidget(), | 2638 render_view_host_->GetWidget()); |
2643 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_DIALOG_SUPPRESSED); | |
2644 } | 2639 } |
2645 } | 2640 } |
2646 | 2641 |
2647 void RenderFrameHostImpl::SendJavaScriptDialogReply( | 2642 void RenderFrameHostImpl::SendJavaScriptDialogReply( |
2648 IPC::Message* reply_msg, | 2643 IPC::Message* reply_msg, |
2649 bool success, | 2644 bool success, |
2650 const base::string16& user_input) { | 2645 const base::string16& user_input) { |
2651 FrameHostMsg_RunJavaScriptDialog::WriteReplyParams(reply_msg, success, | 2646 FrameHostMsg_RunJavaScriptDialog::WriteReplyParams(reply_msg, success, |
2652 user_input); | 2647 user_input); |
2653 Send(reply_msg); | 2648 Send(reply_msg); |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3461 // There is no pending NavigationEntry in these cases, so pass 0 as the | 3456 // There is no pending NavigationEntry in these cases, so pass 0 as the |
3462 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3457 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
3463 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3458 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
3464 return NavigationHandleImpl::Create( | 3459 return NavigationHandleImpl::Create( |
3465 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, | 3460 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, |
3466 params.was_within_same_page, base::TimeTicks::Now(), | 3461 params.was_within_same_page, base::TimeTicks::Now(), |
3467 entry_id_for_data_nav, false); // started_from_context_menu | 3462 entry_id_for_data_nav, false); // started_from_context_menu |
3468 } | 3463 } |
3469 | 3464 |
3470 } // namespace content | 3465 } // namespace content |
OLD | NEW |