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 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1662 } | 1662 } |
1663 } | 1663 } |
1664 | 1664 |
1665 void RenderFrameHostImpl::OnRunJavaScriptDialog( | 1665 void RenderFrameHostImpl::OnRunJavaScriptDialog( |
1666 const base::string16& message, | 1666 const base::string16& message, |
1667 const base::string16& default_prompt, | 1667 const base::string16& default_prompt, |
1668 const GURL& frame_url, | 1668 const GURL& frame_url, |
1669 JavaScriptDialogType dialog_type, | 1669 JavaScriptDialogType dialog_type, |
1670 IPC::Message* reply_msg) { | 1670 IPC::Message* reply_msg) { |
1671 if (!is_active()) { | 1671 if (!is_active()) { |
1672 JavaScriptDialogClosed(reply_msg, true, base::string16(), | 1672 SendJavaScriptDialogReply(reply_msg, true, base::string16()); |
1673 /*is_before_unload_dialog=*/false, | |
1674 /*dialog_was_suppressed=*/true); | |
1675 return; | 1673 return; |
1676 } | 1674 } |
1677 | 1675 |
1676 // Dialogs are not allowed to run during unload. | |
1677 DCHECK(!IsWaitingForUnloadACK()); | |
Charlie Reis
2017/02/27 22:26:17
Can you double check what happens when closing a t
Avi (use Gerrit)
2017/02/27 22:38:58
But we already keep track of beforeunload and unlo
Charlie Reis
2017/02/27 22:41:14
Does the browser process send a separate beforeunl
Charlie Reis
2017/02/28 04:59:21
Great! That simplifies things.
| |
1678 | |
1678 int32_t message_length = static_cast<int32_t>(message.length()); | 1679 int32_t message_length = static_cast<int32_t>(message.length()); |
1679 if (GetParent()) { | 1680 if (GetParent()) { |
1680 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.Subframe", message_length); | 1681 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.Subframe", message_length); |
1681 } else { | 1682 } else { |
1682 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.MainFrame", message_length); | 1683 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.MainFrame", message_length); |
1683 } | 1684 } |
1684 | 1685 |
1685 // While a JS message dialog is showing, tabs in the same process shouldn't | 1686 // While a JS message dialog is showing, tabs in the same process shouldn't |
1686 // process input events. | 1687 // process input events. |
1687 GetProcess()->SetIgnoreInputEvents(true); | 1688 GetProcess()->SetIgnoreInputEvents(true); |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2603 Send(new InputMsg_DeleteSurroundingText(routing_id_, before, after)); | 2604 Send(new InputMsg_DeleteSurroundingText(routing_id_, before, after)); |
2604 } | 2605 } |
2605 | 2606 |
2606 void RenderFrameHostImpl::JavaScriptDialogClosed( | 2607 void RenderFrameHostImpl::JavaScriptDialogClosed( |
2607 IPC::Message* reply_msg, | 2608 IPC::Message* reply_msg, |
2608 bool success, | 2609 bool success, |
2609 const base::string16& user_input, | 2610 const base::string16& user_input, |
2610 bool is_before_unload_dialog, | 2611 bool is_before_unload_dialog, |
2611 bool dialog_was_suppressed) { | 2612 bool dialog_was_suppressed) { |
2612 GetProcess()->SetIgnoreInputEvents(false); | 2613 GetProcess()->SetIgnoreInputEvents(false); |
2613 bool is_waiting = is_before_unload_dialog || IsWaitingForUnloadACK(); | |
2614 | 2614 |
2615 // If we are executing as part of (before)unload event handling, we don't | 2615 // If we are executing as part of beforeunload event handling, we don't |
2616 // want to use the regular hung_renderer_delay_ms_ if the user has agreed to | 2616 // want to use the regular hung_renderer_delay_ms_ if the user has agreed to |
2617 // leave the current page. In this case, use the regular timeout value used | 2617 // leave the current page. In this case, use the regular timeout value used |
2618 // during the (before)unload handling. | 2618 // during the beforeunload handling. |
2619 if (is_waiting) { | 2619 if (is_before_unload_dialog) { |
2620 RendererUnresponsiveType type = | 2620 RendererUnresponsiveType type = |
2621 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_DIALOG_CLOSED; | 2621 success ? RendererUnresponsiveType::RENDERER_UNRESPONSIVE_BEFORE_UNLOAD |
2622 if (success) { | 2622 : RendererUnresponsiveType::RENDERER_UNRESPONSIVE_DIALOG_CLOSED; |
2623 type = is_before_unload_dialog | |
2624 ? RendererUnresponsiveType::RENDERER_UNRESPONSIVE_BEFORE_UNLOAD | |
2625 : RendererUnresponsiveType::RENDERER_UNRESPONSIVE_UNLOAD; | |
2626 } | |
2627 render_view_host_->GetWidget()->StartHangMonitorTimeout( | 2623 render_view_host_->GetWidget()->StartHangMonitorTimeout( |
2628 success | 2624 success |
2629 ? TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS) | 2625 ? TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS) |
2630 : render_view_host_->GetWidget()->hung_renderer_delay(), | 2626 : render_view_host_->GetWidget()->hung_renderer_delay(), |
2631 blink::WebInputEvent::Undefined, type); | 2627 blink::WebInputEvent::Undefined, type); |
2632 } | 2628 } |
2633 | 2629 |
2634 FrameHostMsg_RunJavaScriptDialog::WriteReplyParams(reply_msg, success, | 2630 SendJavaScriptDialogReply(reply_msg, success, user_input); |
2635 user_input); | |
2636 Send(reply_msg); | |
2637 | 2631 |
2638 // If we are waiting for an unload or beforeunload ack and the user has | 2632 // If we are waiting for a beforeunload ack and the user has suppressed |
2639 // suppressed messages, kill the tab immediately; a page that's spamming | 2633 // messages, kill the tab immediately; a page that's spamming alerts in |
2640 // alerts in onbeforeunload is presumably malicious, so there's no point in | 2634 // onbeforeunload is presumably malicious, so there's no point in continuing |
2641 // continuing to run its script and dragging out the process. | 2635 // to run its script and dragging out the process. This must be done after |
2642 // This must be done after sending the reply since RenderView can't close | 2636 // sending the reply since RenderView can't close correctly while waiting for |
2643 // correctly while waiting for a response. | 2637 // a response. |
2644 if (is_waiting && dialog_was_suppressed) { | 2638 if (is_before_unload_dialog && dialog_was_suppressed) { |
2645 render_view_host_->GetWidget()->delegate()->RendererUnresponsive( | 2639 render_view_host_->GetWidget()->delegate()->RendererUnresponsive( |
2646 render_view_host_->GetWidget(), | 2640 render_view_host_->GetWidget(), |
2647 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_DIALOG_SUPPRESSED); | 2641 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_DIALOG_SUPPRESSED); |
2648 } | 2642 } |
2649 } | 2643 } |
2650 | 2644 |
2645 void RenderFrameHostImpl::SendJavaScriptDialogReply( | |
2646 IPC::Message* reply_msg, | |
2647 bool success, | |
2648 const base::string16& user_input) { | |
2649 FrameHostMsg_RunJavaScriptDialog::WriteReplyParams(reply_msg, success, | |
2650 user_input); | |
2651 Send(reply_msg); | |
2652 } | |
2653 | |
2651 // PlzNavigate | 2654 // PlzNavigate |
2652 void RenderFrameHostImpl::CommitNavigation( | 2655 void RenderFrameHostImpl::CommitNavigation( |
2653 ResourceResponse* response, | 2656 ResourceResponse* response, |
2654 std::unique_ptr<StreamHandle> body, | 2657 std::unique_ptr<StreamHandle> body, |
2655 const CommonNavigationParams& common_params, | 2658 const CommonNavigationParams& common_params, |
2656 const RequestNavigationParams& request_params, | 2659 const RequestNavigationParams& request_params, |
2657 bool is_view_source) { | 2660 bool is_view_source) { |
2658 DCHECK( | 2661 DCHECK( |
2659 (response && body.get()) || | 2662 (response && body.get()) || |
2660 common_params.url.SchemeIs(url::kDataScheme) || | 2663 common_params.url.SchemeIs(url::kDataScheme) || |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3450 // There is no pending NavigationEntry in these cases, so pass 0 as the | 3453 // There is no pending NavigationEntry in these cases, so pass 0 as the |
3451 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3454 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
3452 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3455 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
3453 return NavigationHandleImpl::Create( | 3456 return NavigationHandleImpl::Create( |
3454 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, | 3457 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, |
3455 params.was_within_same_page, base::TimeTicks::Now(), | 3458 params.was_within_same_page, base::TimeTicks::Now(), |
3456 entry_id_for_data_nav, false); // started_from_context_menu | 3459 entry_id_for_data_nav, false); // started_from_context_menu |
3457 } | 3460 } |
3458 | 3461 |
3459 } // namespace content | 3462 } // namespace content |
OLD | NEW |