Chromium Code Reviews| 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 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1661 NOTREACHED() << "Received script response for unknown request"; | 1661 NOTREACHED() << "Received script response for unknown request"; |
| 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 (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
| |
| 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 |
| 1678 int32_t message_length = static_cast<int32_t>(message.length()); | 1676 int32_t message_length = static_cast<int32_t>(message.length()); |
| 1679 if (GetParent()) { | 1677 if (GetParent()) { |
| 1680 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.Subframe", message_length); | 1678 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.Subframe", message_length); |
| 1681 } else { | 1679 } else { |
| 1682 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.MainFrame", message_length); | 1680 UMA_HISTOGRAM_COUNTS("JSDialogs.CharacterCount.MainFrame", message_length); |
| 1683 } | 1681 } |
| 1684 | 1682 |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2603 Send(new InputMsg_DeleteSurroundingText(routing_id_, before, after)); | 2601 Send(new InputMsg_DeleteSurroundingText(routing_id_, before, after)); |
| 2604 } | 2602 } |
| 2605 | 2603 |
| 2606 void RenderFrameHostImpl::JavaScriptDialogClosed( | 2604 void RenderFrameHostImpl::JavaScriptDialogClosed( |
| 2607 IPC::Message* reply_msg, | 2605 IPC::Message* reply_msg, |
| 2608 bool success, | 2606 bool success, |
| 2609 const base::string16& user_input, | 2607 const base::string16& user_input, |
| 2610 bool is_before_unload_dialog, | 2608 bool is_before_unload_dialog, |
| 2611 bool dialog_was_suppressed) { | 2609 bool dialog_was_suppressed) { |
| 2612 GetProcess()->SetIgnoreInputEvents(false); | 2610 GetProcess()->SetIgnoreInputEvents(false); |
| 2613 bool is_waiting = is_before_unload_dialog || IsWaitingForUnloadACK(); | |
| 2614 | 2611 |
| 2615 // If we are executing as part of (before)unload event handling, we don't | 2612 // 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 | 2613 // 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 | 2614 // leave the current page. In this case, use the regular timeout value used |
| 2618 // during the (before)unload handling. | 2615 // during the beforeunload handling. |
| 2619 if (is_waiting) { | 2616 if (is_before_unload_dialog) { |
| 2620 RendererUnresponsiveType type = | 2617 RendererUnresponsiveType type = |
| 2621 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_DIALOG_CLOSED; | 2618 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
| |
| 2622 if (success) { | 2619 : 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( | 2620 render_view_host_->GetWidget()->StartHangMonitorTimeout( |
| 2628 success | 2621 success |
| 2629 ? TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS) | 2622 ? TimeDelta::FromMilliseconds(RenderViewHostImpl::kUnloadTimeoutMS) |
| 2630 : render_view_host_->GetWidget()->hung_renderer_delay(), | 2623 : render_view_host_->GetWidget()->hung_renderer_delay(), |
| 2631 blink::WebInputEvent::Undefined, type); | 2624 blink::WebInputEvent::Undefined, type); |
| 2632 } | 2625 } |
| 2633 | 2626 |
| 2634 FrameHostMsg_RunJavaScriptDialog::WriteReplyParams(reply_msg, success, | 2627 SendJavaScriptDialogReply(reply_msg, success, user_input); |
| 2635 user_input); | |
| 2636 Send(reply_msg); | |
| 2637 | 2628 |
| 2638 // If we are waiting for an unload or beforeunload ack and the user has | 2629 // 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 | 2630 // 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 | 2631 // onbeforeunload is presumably malicious, so there's no point in continuing |
| 2641 // continuing to run its script and dragging out the process. | 2632 // 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 | 2633 // sending the reply since RenderView can't close correctly while waiting for |
| 2643 // correctly while waiting for a response. | 2634 // a response. |
| 2644 if (is_waiting && dialog_was_suppressed) { | 2635 if (is_before_unload_dialog && dialog_was_suppressed) { |
| 2645 render_view_host_->GetWidget()->delegate()->RendererUnresponsive( | 2636 render_view_host_->GetWidget()->delegate()->RendererUnresponsive( |
| 2646 render_view_host_->GetWidget(), | 2637 render_view_host_->GetWidget(), |
| 2647 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_DIALOG_SUPPRESSED); | 2638 RendererUnresponsiveType::RENDERER_UNRESPONSIVE_DIALOG_SUPPRESSED); |
| 2648 } | 2639 } |
| 2649 } | 2640 } |
| 2650 | 2641 |
| 2642 void RenderFrameHostImpl::SendJavaScriptDialogReply( | |
| 2643 IPC::Message* reply_msg, | |
| 2644 bool success, | |
| 2645 const base::string16& user_input) { | |
| 2646 FrameHostMsg_RunJavaScriptDialog::WriteReplyParams(reply_msg, success, | |
| 2647 user_input); | |
| 2648 Send(reply_msg); | |
| 2649 } | |
| 2650 | |
| 2651 // PlzNavigate | 2651 // PlzNavigate |
| 2652 void RenderFrameHostImpl::CommitNavigation( | 2652 void RenderFrameHostImpl::CommitNavigation( |
| 2653 ResourceResponse* response, | 2653 ResourceResponse* response, |
| 2654 std::unique_ptr<StreamHandle> body, | 2654 std::unique_ptr<StreamHandle> body, |
| 2655 const CommonNavigationParams& common_params, | 2655 const CommonNavigationParams& common_params, |
| 2656 const RequestNavigationParams& request_params, | 2656 const RequestNavigationParams& request_params, |
| 2657 bool is_view_source) { | 2657 bool is_view_source) { |
| 2658 DCHECK( | 2658 DCHECK( |
| 2659 (response && body.get()) || | 2659 (response && body.get()) || |
| 2660 common_params.url.SchemeIs(url::kDataScheme) || | 2660 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 | 3450 // 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 | 3451 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
| 3452 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3452 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
| 3453 return NavigationHandleImpl::Create( | 3453 return NavigationHandleImpl::Create( |
| 3454 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, | 3454 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, |
| 3455 params.was_within_same_page, base::TimeTicks::Now(), | 3455 params.was_within_same_page, base::TimeTicks::Now(), |
| 3456 entry_id_for_data_nav, false); // started_from_context_menu | 3456 entry_id_for_data_nav, false); // started_from_context_menu |
| 3457 } | 3457 } |
| 3458 | 3458 |
| 3459 } // namespace content | 3459 } // namespace content |
| OLD | NEW |