OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/render_view_host.h" | 5 #include "chrome/browser/renderer_host/render_view_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 void RenderViewHost::CaptureSnapshot() { | 587 void RenderViewHost::CaptureSnapshot() { |
588 Send(new ViewMsg_CaptureSnapshot(routing_id())); | 588 Send(new ViewMsg_CaptureSnapshot(routing_id())); |
589 } | 589 } |
590 | 590 |
591 void RenderViewHost::JavaScriptMessageBoxClosed(IPC::Message* reply_msg, | 591 void RenderViewHost::JavaScriptMessageBoxClosed(IPC::Message* reply_msg, |
592 bool success, | 592 bool success, |
593 const std::wstring& prompt) { | 593 const std::wstring& prompt) { |
594 process()->set_ignore_input_events(false); | 594 process()->set_ignore_input_events(false); |
595 bool is_waiting = | 595 bool is_waiting = |
596 is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_; | 596 is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_; |
597 if (is_waiting) { | 597 if (is_waiting) |
598 if (are_javascript_messages_suppressed_) { | |
599 delegate_->RendererUnresponsive(this, is_waiting); | |
600 return; | |
601 } | |
602 | |
603 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 598 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
604 } | |
605 | 599 |
606 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg, | 600 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg, |
607 success, prompt); | 601 success, prompt); |
608 Send(reply_msg); | 602 Send(reply_msg); |
| 603 |
| 604 // If we are waiting for an unload or beforeunload ack and the user has |
| 605 // suppressed messages, kill the tab immediately; a page that's spamming |
| 606 // alerts in onbeforeunload is presumably malicious, so there's no point in |
| 607 // continuing to run its script and dragging out the process. |
| 608 // This must be done after sending the reply since RenderView can't close |
| 609 // correctly while waiting for a response. |
| 610 if (is_waiting && are_javascript_messages_suppressed_) |
| 611 delegate_->RendererUnresponsive(this, is_waiting); |
609 } | 612 } |
610 | 613 |
611 void RenderViewHost::ModalHTMLDialogClosed(IPC::Message* reply_msg, | 614 void RenderViewHost::ModalHTMLDialogClosed(IPC::Message* reply_msg, |
612 const std::string& json_retval) { | 615 const std::string& json_retval) { |
613 if (is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_) | 616 if (is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_) |
614 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 617 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
615 | 618 |
616 ViewHostMsg_ShowModalHTMLDialog::WriteReplyParams(reply_msg, json_retval); | 619 ViewHostMsg_ShowModalHTMLDialog::WriteReplyParams(reply_msg, json_retval); |
617 Send(reply_msg); | 620 Send(reply_msg); |
618 } | 621 } |
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2121 } | 2124 } |
2122 | 2125 |
2123 void RenderViewHost::OnScriptEvalResponse(int id, bool result) { | 2126 void RenderViewHost::OnScriptEvalResponse(int id, bool result) { |
2124 scoped_ptr<Value> result_value(Value::CreateBooleanValue(result)); | 2127 scoped_ptr<Value> result_value(Value::CreateBooleanValue(result)); |
2125 std::pair<int, Value*> details(id, result_value.get()); | 2128 std::pair<int, Value*> details(id, result_value.get()); |
2126 NotificationService::current()->Notify( | 2129 NotificationService::current()->Notify( |
2127 NotificationType::EXECUTE_JAVASCRIPT_RESULT, | 2130 NotificationType::EXECUTE_JAVASCRIPT_RESULT, |
2128 Source<RenderViewHost>(this), | 2131 Source<RenderViewHost>(this), |
2129 Details<std::pair<int, Value*> >(&details)); | 2132 Details<std::pair<int, Value*> >(&details)); |
2130 } | 2133 } |
OLD | NEW |