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

Side by Side Diff: content/browser/renderer_host/render_view_host_impl.cc

Issue 226503002: Move modal dialogs from WebViewClient to WebFrameClient, part 1/3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: last nits Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer_host/render_view_host_impl.h" 5 #include "content/browser/renderer_host/render_view_host_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 instance_(static_cast<SiteInstanceImpl*>(instance)), 203 instance_(static_cast<SiteInstanceImpl*>(instance)),
204 waiting_for_drag_context_response_(false), 204 waiting_for_drag_context_response_(false),
205 enabled_bindings_(0), 205 enabled_bindings_(0),
206 navigations_suspended_(false), 206 navigations_suspended_(false),
207 has_accessed_initial_document_(false), 207 has_accessed_initial_document_(false),
208 main_frame_routing_id_(main_frame_routing_id), 208 main_frame_routing_id_(main_frame_routing_id),
209 run_modal_reply_msg_(NULL), 209 run_modal_reply_msg_(NULL),
210 run_modal_opener_id_(MSG_ROUTING_NONE), 210 run_modal_opener_id_(MSG_ROUTING_NONE),
211 is_waiting_for_beforeunload_ack_(false), 211 is_waiting_for_beforeunload_ack_(false),
212 unload_ack_is_for_cross_site_transition_(false), 212 unload_ack_is_for_cross_site_transition_(false),
213 are_javascript_messages_suppressed_(false),
214 sudden_termination_allowed_(false), 213 sudden_termination_allowed_(false),
215 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), 214 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING),
216 virtual_keyboard_requested_(false), 215 virtual_keyboard_requested_(false),
217 weak_factory_(this) { 216 weak_factory_(this) {
218 DCHECK(instance_.get()); 217 DCHECK(instance_.get());
219 CHECK(delegate_); // http://crbug.com/82827 218 CHECK(delegate_); // http://crbug.com/82827
220 219
221 GetProcess()->EnableSendQueue(); 220 GetProcess()->EnableSendQueue();
222 221
223 if (swapped_out) { 222 if (swapped_out) {
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 void RenderViewHostImpl::DesktopNotificationPostClose(int notification_id, 842 void RenderViewHostImpl::DesktopNotificationPostClose(int notification_id,
844 bool by_user) { 843 bool by_user) {
845 Send(new DesktopNotificationMsg_PostClose( 844 Send(new DesktopNotificationMsg_PostClose(
846 GetRoutingID(), notification_id, by_user)); 845 GetRoutingID(), notification_id, by_user));
847 } 846 }
848 847
849 void RenderViewHostImpl::DesktopNotificationPostClick(int notification_id) { 848 void RenderViewHostImpl::DesktopNotificationPostClick(int notification_id) {
850 Send(new DesktopNotificationMsg_PostClick(GetRoutingID(), notification_id)); 849 Send(new DesktopNotificationMsg_PostClick(GetRoutingID(), notification_id));
851 } 850 }
852 851
853 void RenderViewHostImpl::JavaScriptDialogClosed(
854 IPC::Message* reply_msg,
855 bool success,
856 const base::string16& user_input) {
857 GetProcess()->SetIgnoreInputEvents(false);
858 bool is_waiting = is_waiting_for_beforeunload_ack_ || IsWaitingForUnloadACK();
859
860 // If we are executing as part of (before)unload event handling, we don't
861 // want to use the regular hung_renderer_delay_ms_ if the user has agreed to
862 // leave the current page. In this case, use the regular timeout value used
863 // during the (before)unload handling.
864 if (is_waiting) {
865 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(
866 success ? kUnloadTimeoutMS : hung_renderer_delay_ms_));
867 }
868
869 ViewHostMsg_RunJavaScriptMessage::WriteReplyParams(reply_msg,
870 success, user_input);
871 Send(reply_msg);
872
873 // If we are waiting for an unload or beforeunload ack and the user has
874 // suppressed messages, kill the tab immediately; a page that's spamming
875 // alerts in onbeforeunload is presumably malicious, so there's no point in
876 // continuing to run its script and dragging out the process.
877 // This must be done after sending the reply since RenderView can't close
878 // correctly while waiting for a response.
879 if (is_waiting && are_javascript_messages_suppressed_)
880 delegate_->RendererUnresponsive(
881 this, is_waiting_for_beforeunload_ack_, IsWaitingForUnloadACK());
882 }
883
884 void RenderViewHostImpl::DragSourceEndedAt( 852 void RenderViewHostImpl::DragSourceEndedAt(
885 int client_x, int client_y, int screen_x, int screen_y, 853 int client_x, int client_y, int screen_x, int screen_y,
886 WebDragOperation operation) { 854 WebDragOperation operation) {
887 Send(new DragMsg_SourceEnded(GetRoutingID(), 855 Send(new DragMsg_SourceEnded(GetRoutingID(),
888 gfx::Point(client_x, client_y), 856 gfx::Point(client_x, client_y),
889 gfx::Point(screen_x, screen_y), 857 gfx::Point(screen_x, screen_y),
890 operation)); 858 operation));
891 } 859 }
892 860
893 void RenderViewHostImpl::DragSourceSystemDragEnded() { 861 void RenderViewHostImpl::DragSourceSystemDragEnded() {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 OnDidChangeScrollOffset) 1042 OnDidChangeScrollOffset)
1075 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeScrollbarsForMainFrame, 1043 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeScrollbarsForMainFrame,
1076 OnDidChangeScrollbarsForMainFrame) 1044 OnDidChangeScrollbarsForMainFrame)
1077 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeScrollOffsetPinningForMainFrame, 1045 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeScrollOffsetPinningForMainFrame,
1078 OnDidChangeScrollOffsetPinningForMainFrame) 1046 OnDidChangeScrollOffsetPinningForMainFrame)
1079 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeNumWheelEvents, 1047 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeNumWheelEvents,
1080 OnDidChangeNumWheelEvents) 1048 OnDidChangeNumWheelEvents)
1081 IPC_MESSAGE_HANDLER(ViewHostMsg_RouteCloseEvent, 1049 IPC_MESSAGE_HANDLER(ViewHostMsg_RouteCloseEvent,
1082 OnRouteCloseEvent) 1050 OnRouteCloseEvent)
1083 IPC_MESSAGE_HANDLER(ViewHostMsg_RouteMessageEvent, OnRouteMessageEvent) 1051 IPC_MESSAGE_HANDLER(ViewHostMsg_RouteMessageEvent, OnRouteMessageEvent)
1084 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage,
1085 OnRunJavaScriptMessage)
1086 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm,
1087 OnRunBeforeUnloadConfirm)
1088 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnStartDragging) 1052 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnStartDragging)
1089 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) 1053 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor)
1090 IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK) 1054 IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK)
1091 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) 1055 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
1092 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) 1056 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged)
1093 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) 1057 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK)
1094 #if defined(OS_ANDROID) 1058 #if defined(OS_ANDROID)
1095 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionRootBoundsChanged, 1059 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionRootBoundsChanged,
1096 OnSelectionRootBoundsChanged) 1060 OnSelectionRootBoundsChanged)
1097 #endif 1061 #endif
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 // Have the delegate route this to the active RenderViewHost. 1334 // Have the delegate route this to the active RenderViewHost.
1371 delegate_->RouteCloseEvent(this); 1335 delegate_->RouteCloseEvent(this);
1372 } 1336 }
1373 1337
1374 void RenderViewHostImpl::OnRouteMessageEvent( 1338 void RenderViewHostImpl::OnRouteMessageEvent(
1375 const ViewMsg_PostMessage_Params& params) { 1339 const ViewMsg_PostMessage_Params& params) {
1376 // Give to the delegate to route to the active RenderViewHost. 1340 // Give to the delegate to route to the active RenderViewHost.
1377 delegate_->RouteMessageEvent(this, params); 1341 delegate_->RouteMessageEvent(this, params);
1378 } 1342 }
1379 1343
1380 void RenderViewHostImpl::OnRunJavaScriptMessage(
1381 const base::string16& message,
1382 const base::string16& default_prompt,
1383 const GURL& frame_url,
1384 JavaScriptMessageType type,
1385 IPC::Message* reply_msg) {
1386 // While a JS message dialog is showing, tabs in the same process shouldn't
1387 // process input events.
1388 GetProcess()->SetIgnoreInputEvents(true);
1389 StopHangMonitorTimeout();
1390 delegate_->RunJavaScriptMessage(this, message, default_prompt, frame_url,
1391 type, reply_msg,
1392 &are_javascript_messages_suppressed_);
1393 }
1394
1395 void RenderViewHostImpl::OnRunBeforeUnloadConfirm(const GURL& frame_url,
1396 const base::string16& message,
1397 bool is_reload,
1398 IPC::Message* reply_msg) {
1399 // While a JS before unload dialog is showing, tabs in the same process
1400 // shouldn't process input events.
1401 GetProcess()->SetIgnoreInputEvents(true);
1402 StopHangMonitorTimeout();
1403 delegate_->RunBeforeUnloadConfirm(this, message, is_reload, reply_msg);
1404 }
1405
1406 void RenderViewHostImpl::OnStartDragging( 1344 void RenderViewHostImpl::OnStartDragging(
1407 const DropData& drop_data, 1345 const DropData& drop_data,
1408 WebDragOperationsMask drag_operations_mask, 1346 WebDragOperationsMask drag_operations_mask,
1409 const SkBitmap& bitmap, 1347 const SkBitmap& bitmap,
1410 const gfx::Vector2d& bitmap_offset_in_dip, 1348 const gfx::Vector2d& bitmap_offset_in_dip,
1411 const DragEventSourceInfo& event_info) { 1349 const DragEventSourceInfo& event_info) {
1412 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); 1350 RenderViewHostDelegateView* view = delegate_->GetDelegateView();
1413 if (!view) 1351 if (!view)
1414 return; 1352 return;
1415 1353
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 return true; 1788 return true;
1851 } 1789 }
1852 1790
1853 void RenderViewHostImpl::AttachToFrameTree() { 1791 void RenderViewHostImpl::AttachToFrameTree() {
1854 FrameTree* frame_tree = delegate_->GetFrameTree(); 1792 FrameTree* frame_tree = delegate_->GetFrameTree();
1855 1793
1856 frame_tree->ResetForMainFrameSwap(); 1794 frame_tree->ResetForMainFrameSwap();
1857 } 1795 }
1858 1796
1859 } // namespace content 1797 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698