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

Side by Side Diff: chrome/browser/renderer_host/render_view_host.cc

Issue 160494: Disable input events when a JS dialog is showing. (Closed)
Patch Set: beforeunload Created 11 years, 4 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <vector> 8 #include <vector>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 Send(new ViewMsg_GetApplicationInfo(routing_id(), page_id)); 554 Send(new ViewMsg_GetApplicationInfo(routing_id(), page_id));
555 } 555 }
556 556
557 void RenderViewHost::CaptureThumbnail() { 557 void RenderViewHost::CaptureThumbnail() {
558 Send(new ViewMsg_CaptureThumbnail(routing_id())); 558 Send(new ViewMsg_CaptureThumbnail(routing_id()));
559 } 559 }
560 560
561 void RenderViewHost::JavaScriptMessageBoxClosed(IPC::Message* reply_msg, 561 void RenderViewHost::JavaScriptMessageBoxClosed(IPC::Message* reply_msg,
562 bool success, 562 bool success,
563 const std::wstring& prompt) { 563 const std::wstring& prompt) {
564 process()->set_ignore_input_events(false);
564 if (is_waiting_for_unload_ack_) { 565 if (is_waiting_for_unload_ack_) {
565 if (are_javascript_messages_suppressed_) { 566 if (are_javascript_messages_suppressed_) {
566 delegate_->RendererUnresponsive(this, is_waiting_for_unload_ack_); 567 delegate_->RendererUnresponsive(this, is_waiting_for_unload_ack_);
567 return; 568 return;
568 } 569 }
569 570
570 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 571 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
571 } 572 }
572 573
573 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg, 574 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg,
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 const FilePath& default_file) { 1260 const FilePath& default_file) {
1260 delegate_->RunFileChooser(multiple_files, title, default_file); 1261 delegate_->RunFileChooser(multiple_files, title, default_file);
1261 } 1262 }
1262 1263
1263 void RenderViewHost::OnMsgRunJavaScriptMessage( 1264 void RenderViewHost::OnMsgRunJavaScriptMessage(
1264 const std::wstring& message, 1265 const std::wstring& message,
1265 const std::wstring& default_prompt, 1266 const std::wstring& default_prompt,
1266 const GURL& frame_url, 1267 const GURL& frame_url,
1267 const int flags, 1268 const int flags,
1268 IPC::Message* reply_msg) { 1269 IPC::Message* reply_msg) {
1270 // While a JS message dialog is showing, tabs in the same process shouldn't
1271 // process input events.
1272 process()->set_ignore_input_events(true);
1269 StopHangMonitorTimeout(); 1273 StopHangMonitorTimeout();
1270 SignalModalDialogEvent(); 1274 SignalModalDialogEvent();
1271 delegate_->RunJavaScriptMessage(message, default_prompt, frame_url, flags, 1275 delegate_->RunJavaScriptMessage(message, default_prompt, frame_url, flags,
1272 reply_msg, 1276 reply_msg,
1273 &are_javascript_messages_suppressed_); 1277 &are_javascript_messages_suppressed_);
1274 } 1278 }
1275 1279
1276 void RenderViewHost::OnMsgRunBeforeUnloadConfirm(const GURL& frame_url, 1280 void RenderViewHost::OnMsgRunBeforeUnloadConfirm(const GURL& frame_url,
1277 const std::wstring& message, 1281 const std::wstring& message,
1278 IPC::Message* reply_msg) { 1282 IPC::Message* reply_msg) {
1283 // While a JS before unload dialog is showing, tabs in the same process
1284 // shouldn't process input events.
1285 process()->set_ignore_input_events(true);
1279 StopHangMonitorTimeout(); 1286 StopHangMonitorTimeout();
1280 SignalModalDialogEvent(); 1287 SignalModalDialogEvent();
1281 delegate_->RunBeforeUnloadConfirm(message, reply_msg); 1288 delegate_->RunBeforeUnloadConfirm(message, reply_msg);
1282 } 1289 }
1283 1290
1284 void RenderViewHost::OnMsgShowModalHTMLDialog( 1291 void RenderViewHost::OnMsgShowModalHTMLDialog(
1285 const GURL& url, int width, int height, const std::string& json_arguments, 1292 const GURL& url, int width, int height, const std::string& json_arguments,
1286 IPC::Message* reply_msg) { 1293 IPC::Message* reply_msg) {
1287 StopHangMonitorTimeout(); 1294 StopHangMonitorTimeout();
1288 SignalModalDialogEvent(); 1295 SignalModalDialogEvent();
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 1633
1627 void RenderViewHost::SignalModalDialogEvent() { 1634 void RenderViewHost::SignalModalDialogEvent() {
1628 if (modal_dialog_count_++ == 0) 1635 if (modal_dialog_count_++ == 0)
1629 modal_dialog_event_->Signal(); 1636 modal_dialog_event_->Signal();
1630 } 1637 }
1631 1638
1632 void RenderViewHost::ResetModalDialogEvent() { 1639 void RenderViewHost::ResetModalDialogEvent() {
1633 if (--modal_dialog_count_ == 0) 1640 if (--modal_dialog_count_ == 0)
1634 modal_dialog_event_->Reset(); 1641 modal_dialog_event_->Reset();
1635 } 1642 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_process_host.cc ('k') | chrome/browser/renderer_host/render_widget_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698