OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "content/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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 RenderViewHost::RenderViewHost(SiteInstance* instance, | 86 RenderViewHost::RenderViewHost(SiteInstance* instance, |
87 RenderViewHostDelegate* delegate, | 87 RenderViewHostDelegate* delegate, |
88 int routing_id, | 88 int routing_id, |
89 SessionStorageNamespace* session_storage) | 89 SessionStorageNamespace* session_storage) |
90 : RenderWidgetHost(instance->GetProcess(), routing_id), | 90 : RenderWidgetHost(instance->GetProcess(), routing_id), |
91 instance_(instance), | 91 instance_(instance), |
92 delegate_(delegate), | 92 delegate_(delegate), |
93 waiting_for_drag_context_response_(false), | 93 waiting_for_drag_context_response_(false), |
94 enabled_bindings_(0), | 94 enabled_bindings_(0), |
95 pending_request_id_(0), | 95 pending_request_id_(-1), |
96 navigations_suspended_(false), | 96 navigations_suspended_(false), |
97 suspended_nav_message_(NULL), | 97 suspended_nav_message_(NULL), |
| 98 is_swapped_out_(false), |
98 run_modal_reply_msg_(NULL), | 99 run_modal_reply_msg_(NULL), |
99 is_waiting_for_beforeunload_ack_(false), | 100 is_waiting_for_beforeunload_ack_(false), |
100 is_waiting_for_unload_ack_(false), | 101 is_waiting_for_unload_ack_(false), |
101 unload_ack_is_for_cross_site_transition_(false), | 102 unload_ack_is_for_cross_site_transition_(false), |
102 are_javascript_messages_suppressed_(false), | 103 are_javascript_messages_suppressed_(false), |
103 sudden_termination_allowed_(false), | 104 sudden_termination_allowed_(false), |
104 session_storage_namespace_(session_storage), | 105 session_storage_namespace_(session_storage), |
105 is_extension_process_(false), | 106 is_extension_process_(false), |
106 save_accessibility_tree_for_testing_(false), | 107 save_accessibility_tree_for_testing_(false), |
107 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING) { | 108 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING) { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 Navigate(params); | 252 Navigate(params); |
252 } | 253 } |
253 | 254 |
254 void RenderViewHost::SetNavigationsSuspended(bool suspend) { | 255 void RenderViewHost::SetNavigationsSuspended(bool suspend) { |
255 // This should only be called to toggle the state. | 256 // This should only be called to toggle the state. |
256 DCHECK(navigations_suspended_ != suspend); | 257 DCHECK(navigations_suspended_ != suspend); |
257 | 258 |
258 navigations_suspended_ = suspend; | 259 navigations_suspended_ = suspend; |
259 if (!suspend && suspended_nav_message_.get()) { | 260 if (!suspend && suspended_nav_message_.get()) { |
260 // There's a navigation message waiting to be sent. Now that we're not | 261 // There's a navigation message waiting to be sent. Now that we're not |
261 // suspended anymore, resume navigation by sending it. | 262 // suspended anymore, resume navigation by sending it. If we were swapped |
| 263 // out, we should also stop filtering out the IPC messages now. |
| 264 is_swapped_out_ = false; |
262 Send(suspended_nav_message_.release()); | 265 Send(suspended_nav_message_.release()); |
263 } | 266 } |
264 } | 267 } |
265 | 268 |
| 269 void RenderViewHost::CancelSuspendedNavigations() { |
| 270 // Clear any state if a pending navigation is canceled or pre-empted. |
| 271 if (suspended_nav_message_.get()) |
| 272 suspended_nav_message_.reset(); |
| 273 navigations_suspended_ = false; |
| 274 } |
| 275 |
266 void RenderViewHost::FirePageBeforeUnload(bool for_cross_site_transition) { | 276 void RenderViewHost::FirePageBeforeUnload(bool for_cross_site_transition) { |
267 if (!IsRenderViewLive()) { | 277 if (!IsRenderViewLive()) { |
268 // This RenderViewHost doesn't have a live renderer, so just skip running | 278 // This RenderViewHost doesn't have a live renderer, so just skip running |
269 // the onbeforeunload handler. | 279 // the onbeforeunload handler. |
270 is_waiting_for_beforeunload_ack_ = true; // Checked by OnMsgShouldCloseACK. | 280 is_waiting_for_beforeunload_ack_ = true; // Checked by OnMsgShouldCloseACK. |
271 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; | 281 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; |
272 OnMsgShouldCloseACK(true); | 282 OnMsgShouldCloseACK(true); |
273 return; | 283 return; |
274 } | 284 } |
275 | 285 |
(...skipping 12 matching lines...) Expand all Loading... |
288 } else { | 298 } else { |
289 // Start the hang monitor in case the renderer hangs in the beforeunload | 299 // Start the hang monitor in case the renderer hangs in the beforeunload |
290 // handler. | 300 // handler. |
291 is_waiting_for_beforeunload_ack_ = true; | 301 is_waiting_for_beforeunload_ack_ = true; |
292 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; | 302 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; |
293 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 303 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
294 Send(new ViewMsg_ShouldClose(routing_id())); | 304 Send(new ViewMsg_ShouldClose(routing_id())); |
295 } | 305 } |
296 } | 306 } |
297 | 307 |
298 void RenderViewHost::ClosePage(bool for_cross_site_transition, | 308 void RenderViewHost::SwapOut(int new_render_process_host_id, |
299 int new_render_process_host_id, | 309 int new_request_id) { |
300 int new_request_id) { | 310 // Start filtering IPC messages to avoid confusing the delegate. This will |
301 // This will be set back to false in OnClosePageACK, just before we close the | 311 // prevent any dialogs from appearing during unload handlers, but we've |
302 // tab or replace it with a pending RVH. There are some cases (such as 204 | 312 // already decided to silence them in crbug.com/68780. We will set it back |
303 // errors) where we'll continue to show this RVH. | 313 // to false in SetNavigationsSuspended if we swap back in. |
| 314 is_swapped_out_ = true; |
| 315 |
| 316 // This will be set back to false in OnSwapOutACK, just before we replace |
| 317 // this RVH with the pending RVH. |
304 is_waiting_for_unload_ack_ = true; | 318 is_waiting_for_unload_ack_ = true; |
305 // Start the hang monitor in case the renderer hangs in the unload handler. | 319 // Start the hang monitor in case the renderer hangs in the unload handler. |
306 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 320 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
307 | 321 |
308 ViewMsg_ClosePage_Params params; | 322 ViewMsg_SwapOut_Params params; |
309 params.closing_process_id = process()->id(); | 323 params.closing_process_id = process()->id(); |
310 params.closing_route_id = routing_id(); | 324 params.closing_route_id = routing_id(); |
311 params.for_cross_site_transition = for_cross_site_transition; | |
312 params.new_render_process_host_id = new_render_process_host_id; | 325 params.new_render_process_host_id = new_render_process_host_id; |
313 params.new_request_id = new_request_id; | 326 params.new_request_id = new_request_id; |
314 if (IsRenderViewLive()) { | 327 if (IsRenderViewLive()) { |
| 328 Send(new ViewMsg_SwapOut(routing_id(), params)); |
| 329 } else { |
| 330 // This RenderViewHost doesn't have a live renderer, so just skip the unload |
| 331 // event. We must notify the ResourceDispatcherHost on the IO thread, |
| 332 // which we will do through the RenderProcessHost's widget helper. |
| 333 process()->CrossSiteSwapOutACK(params); |
| 334 } |
| 335 } |
| 336 |
| 337 void RenderViewHost::OnSwapOutACK() { |
| 338 // Stop the hang monitor now that the unload handler has finished. |
| 339 StopHangMonitorTimeout(); |
| 340 is_waiting_for_unload_ack_ = false; |
| 341 } |
| 342 |
| 343 void RenderViewHost::WasSwappedOut() { |
| 344 // Don't bother reporting hung state anymore. |
| 345 StopHangMonitorTimeout(); |
| 346 |
| 347 // Inform the renderer that it can exit if no one else is using it. |
| 348 Send(new ViewMsg_WasSwappedOut(routing_id())); |
| 349 } |
| 350 |
| 351 void RenderViewHost::ClosePage() { |
| 352 // Start the hang monitor in case the renderer hangs in the unload handler. |
| 353 is_waiting_for_unload_ack_ = true; |
| 354 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
| 355 |
| 356 if (IsRenderViewLive()) { |
| 357 // TODO(creis): Should this be moved to Shutdown? It may not be called for |
| 358 // RenderViewHosts that have been swapped out. |
315 NotificationService::current()->Notify( | 359 NotificationService::current()->Notify( |
316 NotificationType::RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, | 360 NotificationType::RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, |
317 Source<RenderViewHost>(this), | 361 Source<RenderViewHost>(this), |
318 NotificationService::NoDetails()); | 362 NotificationService::NoDetails()); |
319 | 363 |
320 Send(new ViewMsg_ClosePage(routing_id(), params)); | 364 Send(new ViewMsg_ClosePage(routing_id())); |
321 } else { | 365 } else { |
322 // This RenderViewHost doesn't have a live renderer, so just skip closing | 366 // This RenderViewHost doesn't have a live renderer, so just skip the unload |
323 // the page. We must notify the ResourceDispatcherHost on the IO thread, | 367 // event and close the page. |
324 // which we will do through the RenderProcessHost's widget helper. | |
325 process()->CrossSiteClosePageACK(params); | |
326 } | |
327 } | |
328 | |
329 void RenderViewHost::OnClosePageACK(bool for_cross_site_transition) { | |
330 StopHangMonitorTimeout(); | |
331 is_waiting_for_unload_ack_ = false; | |
332 | |
333 // If this ClosePageACK is not for a cross-site transition, then it is for an | |
334 // attempt to close the tab. We have now finished the unload handler and can | |
335 // proceed with closing the tab. | |
336 if (!for_cross_site_transition) { | |
337 ClosePageIgnoringUnloadEvents(); | 368 ClosePageIgnoringUnloadEvents(); |
338 } | 369 } |
339 } | 370 } |
340 | 371 |
341 void RenderViewHost::ClosePageIgnoringUnloadEvents() { | 372 void RenderViewHost::ClosePageIgnoringUnloadEvents() { |
342 StopHangMonitorTimeout(); | 373 StopHangMonitorTimeout(); |
343 is_waiting_for_beforeunload_ack_ = false; | 374 is_waiting_for_beforeunload_ack_ = false; |
344 is_waiting_for_unload_ack_ = false; | 375 is_waiting_for_unload_ack_ = false; |
345 | 376 |
346 sudden_termination_allowed_ = true; | 377 sudden_termination_allowed_ = true; |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 return sudden_termination_allowed_ || process()->sudden_termination_allowed(); | 695 return sudden_termination_allowed_ || process()->sudden_termination_allowed(); |
665 } | 696 } |
666 | 697 |
667 /////////////////////////////////////////////////////////////////////////////// | 698 /////////////////////////////////////////////////////////////////////////////// |
668 // RenderViewHost, IPC message handlers: | 699 // RenderViewHost, IPC message handlers: |
669 | 700 |
670 bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { | 701 bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { |
671 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) | 702 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) |
672 return true; | 703 return true; |
673 | 704 |
| 705 // Filter out most IPC messages if this renderer is swapped out. |
| 706 // We still want to certain ACKs to keep our state consistent. |
| 707 if (is_swapped_out_) |
| 708 if (!CanHandleWhileSwappedOut(msg)) |
| 709 return true; |
| 710 |
674 { | 711 { |
675 // delegate_->OnMessageReceived can end up deleting |this|, in which case | 712 // delegate_->OnMessageReceived can end up deleting |this|, in which case |
676 // the destructor for ObserverListBase::Iterator would access the deleted | 713 // the destructor for ObserverListBase::Iterator would access the deleted |
677 // observers_. | 714 // observers_. |
678 ObserverListBase<RenderViewHostObserver>::Iterator it(observers_); | 715 ObserverListBase<RenderViewHostObserver>::Iterator it(observers_); |
679 RenderViewHostObserver* observer; | 716 RenderViewHostObserver* observer; |
680 while ((observer = it.GetNext()) != NULL) | 717 while ((observer = it.GetNext()) != NULL) |
681 if (observer->OnMessageReceived(msg)) | 718 if (observer->OnMessageReceived(msg)) |
682 return true; | 719 return true; |
683 } | 720 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) | 758 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) |
722 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, | 759 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, |
723 OnMsgRunJavaScriptMessage) | 760 OnMsgRunJavaScriptMessage) |
724 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, | 761 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, |
725 OnMsgRunBeforeUnloadConfirm) | 762 OnMsgRunBeforeUnloadConfirm) |
726 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnMsgStartDragging) | 763 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnMsgStartDragging) |
727 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) | 764 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) |
728 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | 765 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
729 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) | 766 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) |
730 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) | 767 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) |
| 768 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnMsgClosePageACK) |
731 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged) | 769 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged) |
732 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications, | 770 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications, |
733 OnAccessibilityNotifications) | 771 OnAccessibilityNotifications) |
734 IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted) | 772 IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted) |
735 IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked) | 773 IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked) |
736 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | 774 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
737 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) | 775 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) |
738 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) | 776 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) |
739 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) | 777 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) |
740 #if defined(OS_MACOSX) | 778 #if defined(OS_MACOSX) |
741 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) | 779 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) |
742 #endif | 780 #endif |
743 // Have the super handle all other messages. | 781 // Have the super handle all other messages. |
744 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) | 782 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) |
745 IPC_END_MESSAGE_MAP_EX() | 783 IPC_END_MESSAGE_MAP_EX() |
746 | 784 |
747 if (!msg_is_ok) { | 785 if (!msg_is_ok) { |
748 // The message had a handler, but its de-serialization failed. | 786 // The message had a handler, but its de-serialization failed. |
749 // Kill the renderer. | 787 // Kill the renderer. |
750 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); | 788 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); |
751 process()->ReceivedBadMessage(); | 789 process()->ReceivedBadMessage(); |
752 } | 790 } |
753 | 791 |
754 return handled; | 792 return handled; |
755 } | 793 } |
756 | 794 |
| 795 bool RenderViewHost::CanHandleWhileSwappedOut(const IPC::Message& msg) { |
| 796 // We drop most messages that arrive from a swapped out renderer. However, |
| 797 // some are important (e.g., ACKs) for keeping the browser and renderer state |
| 798 // consistent in case we later return to the renderer. |
| 799 switch (msg.type()) { |
| 800 // Sends an ACK. |
| 801 case ViewHostMsg_ShowView::ID: |
| 802 // Sends an ACK. |
| 803 case ViewHostMsg_ShowWidget::ID: |
| 804 // Sends an ACK. |
| 805 case ViewHostMsg_ShowFullscreenWidget::ID: |
| 806 // Updates browser state. |
| 807 case ViewHostMsg_RenderViewReady::ID: |
| 808 // Updates browser state. |
| 809 case ViewHostMsg_RenderViewGone::ID: |
| 810 // Updates the previous navigation entry. |
| 811 case ViewHostMsg_UpdateState::ID: |
| 812 // Sends an ACK. |
| 813 case ViewHostMsg_UpdateTargetURL::ID: |
| 814 // Updates browser state. |
| 815 case ViewHostMsg_Snapshot::ID: |
| 816 // We allow closing even if we are in the process of swapping out. |
| 817 case ViewHostMsg_Close::ID: |
| 818 // Sends an ACK. |
| 819 case ViewHostMsg_RequestMove::ID: |
| 820 // Updates browser state, and important for tests. |
| 821 case ViewHostMsg_DomOperationResponse::ID: |
| 822 // Suppresses dialog and sends an ACK. |
| 823 case ViewHostMsg_RunJavaScriptMessage::ID: |
| 824 // Suppresses dialog and sends an ACK. |
| 825 case ViewHostMsg_RunBeforeUnloadConfirm::ID: |
| 826 // Stops hang monitor. |
| 827 case ViewHostMsg_ShouldClose_ACK::ID: |
| 828 // We allow closing even if we are in the process of swapping out. |
| 829 case ViewHostMsg_ClosePage_ACK::ID: |
| 830 // Sends an ACK. |
| 831 case ViewHostMsg_AccessibilityNotifications::ID: |
| 832 // Updates browser state. |
| 833 case ViewHostMsg_PaintAtSize_ACK::ID: |
| 834 // Updates browser state. |
| 835 case ViewHostMsg_HandleInputEvent_ACK::ID: |
| 836 // Updates browser state. |
| 837 case ViewHostMsg_UpdateRect::ID: |
| 838 return true; |
| 839 default: |
| 840 break; |
| 841 } |
| 842 return false; |
| 843 } |
| 844 |
757 void RenderViewHost::Shutdown() { | 845 void RenderViewHost::Shutdown() { |
758 // If we are being run modally (see RunModal), then we need to cleanup. | 846 // If we are being run modally (see RunModal), then we need to cleanup. |
759 if (run_modal_reply_msg_) { | 847 if (run_modal_reply_msg_) { |
760 Send(run_modal_reply_msg_); | 848 Send(run_modal_reply_msg_); |
761 run_modal_reply_msg_ = NULL; | 849 run_modal_reply_msg_ = NULL; |
762 } | 850 } |
763 | 851 |
764 RenderWidgetHost::Shutdown(); | 852 RenderWidgetHost::Shutdown(); |
765 } | 853 } |
766 | 854 |
(...skipping 23 matching lines...) Expand all Loading... |
790 if (view) | 878 if (view) |
791 view->CreateNewFullscreenWidget(route_id); | 879 view->CreateNewFullscreenWidget(route_id); |
792 } | 880 } |
793 | 881 |
794 void RenderViewHost::OnMsgShowView(int route_id, | 882 void RenderViewHost::OnMsgShowView(int route_id, |
795 WindowOpenDisposition disposition, | 883 WindowOpenDisposition disposition, |
796 const gfx::Rect& initial_pos, | 884 const gfx::Rect& initial_pos, |
797 bool user_gesture) { | 885 bool user_gesture) { |
798 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 886 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
799 if (view) { | 887 if (view) { |
800 view->ShowCreatedWindow(route_id, disposition, initial_pos, user_gesture); | 888 if (!is_swapped_out_) |
| 889 view->ShowCreatedWindow(route_id, disposition, initial_pos, user_gesture); |
801 Send(new ViewMsg_Move_ACK(route_id)); | 890 Send(new ViewMsg_Move_ACK(route_id)); |
802 } | 891 } |
803 } | 892 } |
804 | 893 |
805 void RenderViewHost::OnMsgShowWidget(int route_id, | 894 void RenderViewHost::OnMsgShowWidget(int route_id, |
806 const gfx::Rect& initial_pos) { | 895 const gfx::Rect& initial_pos) { |
807 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 896 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
808 if (view) { | 897 if (view) { |
809 view->ShowCreatedWidget(route_id, initial_pos); | 898 if (!is_swapped_out_) |
| 899 view->ShowCreatedWidget(route_id, initial_pos); |
810 Send(new ViewMsg_Move_ACK(route_id)); | 900 Send(new ViewMsg_Move_ACK(route_id)); |
811 } | 901 } |
812 } | 902 } |
813 | 903 |
814 void RenderViewHost::OnMsgShowFullscreenWidget(int route_id) { | 904 void RenderViewHost::OnMsgShowFullscreenWidget(int route_id) { |
815 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 905 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
816 if (view) { | 906 if (view) { |
817 view->ShowCreatedFullscreenWidget(route_id); | 907 if (!is_swapped_out_) |
| 908 view->ShowCreatedFullscreenWidget(route_id); |
818 Send(new ViewMsg_Move_ACK(route_id)); | 909 Send(new ViewMsg_Move_ACK(route_id)); |
819 } | 910 } |
820 } | 911 } |
821 | 912 |
822 void RenderViewHost::OnMsgRunModal(IPC::Message* reply_msg) { | 913 void RenderViewHost::OnMsgRunModal(IPC::Message* reply_msg) { |
823 DCHECK(!run_modal_reply_msg_); | 914 DCHECK(!run_modal_reply_msg_); |
824 run_modal_reply_msg_ = reply_msg; | 915 run_modal_reply_msg_ = reply_msg; |
825 | 916 |
826 // TODO(darin): Bug 1107929: Need to inform our delegate to show this view in | 917 // TODO(darin): Bug 1107929: Need to inform our delegate to show this view in |
827 // an app-modal fashion. | 918 // an app-modal fashion. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 } | 1020 } |
930 delegate_->UpdateTitle(this, page_id, title); | 1021 delegate_->UpdateTitle(this, page_id, title); |
931 } | 1022 } |
932 | 1023 |
933 void RenderViewHost::OnMsgUpdateEncoding(const std::string& encoding_name) { | 1024 void RenderViewHost::OnMsgUpdateEncoding(const std::string& encoding_name) { |
934 delegate_->UpdateEncoding(this, encoding_name); | 1025 delegate_->UpdateEncoding(this, encoding_name); |
935 } | 1026 } |
936 | 1027 |
937 void RenderViewHost::OnMsgUpdateTargetURL(int32 page_id, | 1028 void RenderViewHost::OnMsgUpdateTargetURL(int32 page_id, |
938 const GURL& url) { | 1029 const GURL& url) { |
939 delegate_->UpdateTargetURL(page_id, url); | 1030 if (!is_swapped_out_) |
| 1031 delegate_->UpdateTargetURL(page_id, url); |
940 | 1032 |
941 // Send a notification back to the renderer that we are ready to | 1033 // Send a notification back to the renderer that we are ready to |
942 // receive more target urls. | 1034 // receive more target urls. |
943 Send(new ViewMsg_UpdateTargetURL_ACK(routing_id())); | 1035 Send(new ViewMsg_UpdateTargetURL_ACK(routing_id())); |
944 } | 1036 } |
945 | 1037 |
946 void RenderViewHost::OnUpdateInspectorSetting( | 1038 void RenderViewHost::OnUpdateInspectorSetting( |
947 const std::string& key, const std::string& value) { | 1039 const std::string& key, const std::string& value) { |
948 delegate_->UpdateInspectorSetting(key, value); | 1040 delegate_->UpdateInspectorSetting(key, value); |
949 } | 1041 } |
950 | 1042 |
951 void RenderViewHost::OnMsgClose() { | 1043 void RenderViewHost::OnMsgClose() { |
952 // If the renderer is telling us to close, it has already run the unload | 1044 // If the renderer is telling us to close, it has already run the unload |
953 // events, and we can take the fast path. | 1045 // events, and we can take the fast path. |
954 ClosePageIgnoringUnloadEvents(); | 1046 ClosePageIgnoringUnloadEvents(); |
955 } | 1047 } |
956 | 1048 |
957 void RenderViewHost::OnMsgRequestMove(const gfx::Rect& pos) { | 1049 void RenderViewHost::OnMsgRequestMove(const gfx::Rect& pos) { |
958 delegate_->RequestMove(pos); | 1050 if (!is_swapped_out_) |
| 1051 delegate_->RequestMove(pos); |
959 Send(new ViewMsg_Move_ACK(routing_id())); | 1052 Send(new ViewMsg_Move_ACK(routing_id())); |
960 } | 1053 } |
961 | 1054 |
962 void RenderViewHost::OnMsgDidStartLoading() { | 1055 void RenderViewHost::OnMsgDidStartLoading() { |
963 delegate_->DidStartLoading(); | 1056 delegate_->DidStartLoading(); |
964 } | 1057 } |
965 | 1058 |
966 void RenderViewHost::OnMsgDidStopLoading() { | 1059 void RenderViewHost::OnMsgDidStopLoading() { |
967 delegate_->DidStopLoading(); | 1060 delegate_->DidStopLoading(); |
968 } | 1061 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 void RenderViewHost::OnMsgRunJavaScriptMessage( | 1163 void RenderViewHost::OnMsgRunJavaScriptMessage( |
1071 const std::wstring& message, | 1164 const std::wstring& message, |
1072 const std::wstring& default_prompt, | 1165 const std::wstring& default_prompt, |
1073 const GURL& frame_url, | 1166 const GURL& frame_url, |
1074 const int flags, | 1167 const int flags, |
1075 IPC::Message* reply_msg) { | 1168 IPC::Message* reply_msg) { |
1076 // While a JS message dialog is showing, tabs in the same process shouldn't | 1169 // While a JS message dialog is showing, tabs in the same process shouldn't |
1077 // process input events. | 1170 // process input events. |
1078 process()->set_ignore_input_events(true); | 1171 process()->set_ignore_input_events(true); |
1079 StopHangMonitorTimeout(); | 1172 StopHangMonitorTimeout(); |
1080 delegate_->RunJavaScriptMessage(message, default_prompt, frame_url, flags, | 1173 delegate_->RunJavaScriptMessage(this, message, default_prompt, frame_url, |
1081 reply_msg, | 1174 flags, reply_msg, |
1082 &are_javascript_messages_suppressed_); | 1175 &are_javascript_messages_suppressed_); |
1083 } | 1176 } |
1084 | 1177 |
1085 void RenderViewHost::OnMsgRunBeforeUnloadConfirm(const GURL& frame_url, | 1178 void RenderViewHost::OnMsgRunBeforeUnloadConfirm(const GURL& frame_url, |
1086 const std::wstring& message, | 1179 const std::wstring& message, |
1087 IPC::Message* reply_msg) { | 1180 IPC::Message* reply_msg) { |
1088 // While a JS before unload dialog is showing, tabs in the same process | 1181 // While a JS before unload dialog is showing, tabs in the same process |
1089 // shouldn't process input events. | 1182 // shouldn't process input events. |
1090 process()->set_ignore_input_events(true); | 1183 process()->set_ignore_input_events(true); |
1091 StopHangMonitorTimeout(); | 1184 StopHangMonitorTimeout(); |
1092 delegate_->RunBeforeUnloadConfirm(message, reply_msg); | 1185 delegate_->RunBeforeUnloadConfirm(this, message, reply_msg); |
1093 } | 1186 } |
1094 | 1187 |
1095 void RenderViewHost::MediaPlayerActionAt(const gfx::Point& location, | 1188 void RenderViewHost::MediaPlayerActionAt(const gfx::Point& location, |
1096 const WebMediaPlayerAction& action) { | 1189 const WebMediaPlayerAction& action) { |
1097 // TODO(ajwong): Which thread should run this? Does it matter? | 1190 // TODO(ajwong): Which thread should run this? Does it matter? |
1098 Send(new ViewMsg_MediaPlayerActionAt(routing_id(), location, action)); | 1191 Send(new ViewMsg_MediaPlayerActionAt(routing_id(), location, action)); |
1099 } | 1192 } |
1100 | 1193 |
1101 void RenderViewHost::ContextMenuClosed( | 1194 void RenderViewHost::ContextMenuClosed( |
1102 const webkit_glue::CustomContextMenuContext& custom_context) { | 1195 const webkit_glue::CustomContextMenuContext& custom_context) { |
1103 Send(new ViewMsg_ContextMenuClosed(routing_id(), custom_context)); | 1196 Send(new ViewMsg_ContextMenuClosed(routing_id(), custom_context)); |
1104 } | 1197 } |
1105 | 1198 |
1106 void RenderViewHost::OnMsgStartDragging( | 1199 void RenderViewHost::OnMsgStartDragging( |
1107 const WebDropData& drop_data, | 1200 const WebDropData& drop_data, |
1108 WebDragOperationsMask drag_operations_mask, | 1201 WebDragOperationsMask drag_operations_mask, |
1109 const SkBitmap& image, | 1202 const SkBitmap& image, |
1110 const gfx::Point& image_offset) { | 1203 const gfx::Point& image_offset) { |
1111 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 1204 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
1112 if (view) | 1205 if (view) |
1113 view->StartDragging(drop_data, drag_operations_mask, image, image_offset); | 1206 view->StartDragging(drop_data, drag_operations_mask, image, image_offset); |
1114 } | 1207 } |
1115 | 1208 |
1116 void RenderViewHost::OnUpdateDragCursor(WebDragOperation current_op) { | 1209 void RenderViewHost::OnUpdateDragCursor(WebDragOperation current_op) { |
1117 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 1210 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
1118 if (view) | 1211 if (view) |
1119 view->UpdateDragCursor(current_op); | 1212 view->UpdateDragCursor(current_op); |
1120 } | 1213 } |
1121 | 1214 |
1122 void RenderViewHost::OnTakeFocus(bool reverse) { | 1215 void RenderViewHost::OnTakeFocus(bool reverse) { |
1123 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 1216 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 | 1253 |
1161 void RenderViewHost::OnUserGesture() { | 1254 void RenderViewHost::OnUserGesture() { |
1162 delegate_->OnUserGesture(); | 1255 delegate_->OnUserGesture(); |
1163 } | 1256 } |
1164 | 1257 |
1165 void RenderViewHost::OnMsgShouldCloseACK(bool proceed) { | 1258 void RenderViewHost::OnMsgShouldCloseACK(bool proceed) { |
1166 StopHangMonitorTimeout(); | 1259 StopHangMonitorTimeout(); |
1167 // If this renderer navigated while the beforeunload request was in flight, we | 1260 // If this renderer navigated while the beforeunload request was in flight, we |
1168 // may have cleared this state in OnMsgNavigate, in which case we can ignore | 1261 // may have cleared this state in OnMsgNavigate, in which case we can ignore |
1169 // this message. | 1262 // this message. |
1170 if (!is_waiting_for_beforeunload_ack_) | 1263 if (!is_waiting_for_beforeunload_ack_ || is_swapped_out_) |
1171 return; | 1264 return; |
1172 | 1265 |
1173 is_waiting_for_beforeunload_ack_ = false; | 1266 is_waiting_for_beforeunload_ack_ = false; |
1174 | 1267 |
1175 RenderViewHostDelegate::RendererManagement* management_delegate = | 1268 RenderViewHostDelegate::RendererManagement* management_delegate = |
1176 delegate_->GetRendererManagementDelegate(); | 1269 delegate_->GetRendererManagementDelegate(); |
1177 if (management_delegate) { | 1270 if (management_delegate) { |
1178 management_delegate->ShouldClosePage( | 1271 management_delegate->ShouldClosePage( |
1179 unload_ack_is_for_cross_site_transition_, proceed); | 1272 unload_ack_is_for_cross_site_transition_, proceed); |
1180 } | 1273 } |
1181 | 1274 |
1182 // If canceled, notify the delegate to cancel its pending navigation entry. | 1275 // If canceled, notify the delegate to cancel its pending navigation entry. |
1183 if (!proceed) | 1276 if (!proceed) |
1184 delegate_->DidCancelLoading(); | 1277 delegate_->DidCancelLoading(); |
1185 } | 1278 } |
1186 | 1279 |
| 1280 void RenderViewHost::OnMsgClosePageACK() { |
| 1281 ClosePageIgnoringUnloadEvents(); |
| 1282 } |
| 1283 |
1187 void RenderViewHost::WindowMoveOrResizeStarted() { | 1284 void RenderViewHost::WindowMoveOrResizeStarted() { |
1188 Send(new ViewMsg_MoveOrResizeStarted(routing_id())); | 1285 Send(new ViewMsg_MoveOrResizeStarted(routing_id())); |
1189 } | 1286 } |
1190 | 1287 |
1191 void RenderViewHost::NotifyRendererUnresponsive() { | 1288 void RenderViewHost::NotifyRendererUnresponsive() { |
1192 delegate_->RendererUnresponsive( | 1289 delegate_->RendererUnresponsive( |
1193 this, is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_); | 1290 this, is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_); |
1194 } | 1291 } |
1195 | 1292 |
1196 void RenderViewHost::NotifyRendererResponsive() { | 1293 void RenderViewHost::NotifyRendererResponsive() { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 // If this renderer is not permitted to request this URL, we invalidate the | 1416 // If this renderer is not permitted to request this URL, we invalidate the |
1320 // URL. This prevents us from storing the blocked URL and becoming confused | 1417 // URL. This prevents us from storing the blocked URL and becoming confused |
1321 // later. | 1418 // later. |
1322 VLOG(1) << "Blocked URL " << url->spec(); | 1419 VLOG(1) << "Blocked URL " << url->spec(); |
1323 *url = GURL(); | 1420 *url = GURL(); |
1324 } | 1421 } |
1325 } | 1422 } |
1326 | 1423 |
1327 void RenderViewHost::OnAccessibilityNotifications( | 1424 void RenderViewHost::OnAccessibilityNotifications( |
1328 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) { | 1425 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) { |
1329 if (view()) | 1426 if (view() && !is_swapped_out_) |
1330 view()->OnAccessibilityNotifications(params); | 1427 view()->OnAccessibilityNotifications(params); |
1331 | 1428 |
1332 if (!params.empty()) { | 1429 if (!params.empty()) { |
1333 for (unsigned i = 0; i < params.size(); i++) { | 1430 for (unsigned i = 0; i < params.size(); i++) { |
1334 const ViewHostMsg_AccessibilityNotification_Params& param = params[i]; | 1431 const ViewHostMsg_AccessibilityNotification_Params& param = params[i]; |
1335 | 1432 |
1336 if (param.notification_type == | 1433 if (param.notification_type == |
1337 ViewHostMsg_AccessibilityNotification_Type:: | 1434 ViewHostMsg_AccessibilityNotification_Type:: |
1338 NOTIFICATION_TYPE_LOAD_COMPLETE) { | 1435 NOTIFICATION_TYPE_LOAD_COMPLETE) { |
1339 // TODO(ctguil): Remove when mac processes OnAccessibilityNotifications. | 1436 // TODO(ctguil): Remove when mac processes OnAccessibilityNotifications. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 if (view) { | 1499 if (view) { |
1403 view->ShowPopupMenu(params.bounds, | 1500 view->ShowPopupMenu(params.bounds, |
1404 params.item_height, | 1501 params.item_height, |
1405 params.item_font_size, | 1502 params.item_font_size, |
1406 params.selected_item, | 1503 params.selected_item, |
1407 params.popup_items, | 1504 params.popup_items, |
1408 params.right_aligned); | 1505 params.right_aligned); |
1409 } | 1506 } |
1410 } | 1507 } |
1411 #endif | 1508 #endif |
OLD | NEW |