| 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 return sudden_termination_allowed_ || process()->sudden_termination_allowed(); | 711 return sudden_termination_allowed_ || process()->sudden_termination_allowed(); |
| 681 } | 712 } |
| 682 | 713 |
| 683 /////////////////////////////////////////////////////////////////////////////// | 714 /////////////////////////////////////////////////////////////////////////////// |
| 684 // RenderViewHost, IPC message handlers: | 715 // RenderViewHost, IPC message handlers: |
| 685 | 716 |
| 686 bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { | 717 bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { |
| 687 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) | 718 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) |
| 688 return true; | 719 return true; |
| 689 | 720 |
| 721 // Filter out most IPC messages if this renderer is swapped out. |
| 722 // We still want to certain ACKs to keep our state consistent. |
| 723 if (is_swapped_out_) |
| 724 if (!CanHandleWhileSwappedOut(msg)) |
| 725 return true; |
| 726 |
| 690 { | 727 { |
| 691 // delegate_->OnMessageReceived can end up deleting |this|, in which case | 728 // delegate_->OnMessageReceived can end up deleting |this|, in which case |
| 692 // the destructor for ObserverListBase::Iterator would access the deleted | 729 // the destructor for ObserverListBase::Iterator would access the deleted |
| 693 // observers_. | 730 // observers_. |
| 694 ObserverListBase<RenderViewHostObserver>::Iterator it(observers_); | 731 ObserverListBase<RenderViewHostObserver>::Iterator it(observers_); |
| 695 RenderViewHostObserver* observer; | 732 RenderViewHostObserver* observer; |
| 696 while ((observer = it.GetNext()) != NULL) | 733 while ((observer = it.GetNext()) != NULL) |
| 697 if (observer->OnMessageReceived(msg)) | 734 if (observer->OnMessageReceived(msg)) |
| 698 return true; | 735 return true; |
| 699 } | 736 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) | 774 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) |
| 738 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, | 775 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, |
| 739 OnMsgRunJavaScriptMessage) | 776 OnMsgRunJavaScriptMessage) |
| 740 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, | 777 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, |
| 741 OnMsgRunBeforeUnloadConfirm) | 778 OnMsgRunBeforeUnloadConfirm) |
| 742 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnMsgStartDragging) | 779 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnMsgStartDragging) |
| 743 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) | 780 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) |
| 744 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | 781 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
| 745 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) | 782 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) |
| 746 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) | 783 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) |
| 784 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnMsgClosePageACK) |
| 747 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged) | 785 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged) |
| 748 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications, | 786 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications, |
| 749 OnAccessibilityNotifications) | 787 OnAccessibilityNotifications) |
| 750 IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted) | 788 IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted) |
| 751 IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked) | 789 IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked) |
| 752 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | 790 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
| 753 IPC_MESSAGE_HANDLER(ViewHostMsg_WebDatabaseAccessed, OnWebDatabaseAccessed) | 791 IPC_MESSAGE_HANDLER(ViewHostMsg_WebDatabaseAccessed, OnWebDatabaseAccessed) |
| 754 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) | 792 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) |
| 755 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) | 793 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) |
| 756 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) | 794 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) |
| 757 #if defined(OS_MACOSX) | 795 #if defined(OS_MACOSX) |
| 758 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) | 796 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) |
| 759 #endif | 797 #endif |
| 760 IPC_MESSAGE_HANDLER(ViewHostMsg_CommandStateChanged, | 798 IPC_MESSAGE_HANDLER(ViewHostMsg_CommandStateChanged, |
| 761 OnCommandStateChanged) | 799 OnCommandStateChanged) |
| 762 // Have the super handle all other messages. | 800 // Have the super handle all other messages. |
| 763 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) | 801 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) |
| 764 IPC_END_MESSAGE_MAP_EX() | 802 IPC_END_MESSAGE_MAP_EX() |
| 765 | 803 |
| 766 if (!msg_is_ok) { | 804 if (!msg_is_ok) { |
| 767 // The message had a handler, but its de-serialization failed. | 805 // The message had a handler, but its de-serialization failed. |
| 768 // Kill the renderer. | 806 // Kill the renderer. |
| 769 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); | 807 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); |
| 770 process()->ReceivedBadMessage(); | 808 process()->ReceivedBadMessage(); |
| 771 } | 809 } |
| 772 | 810 |
| 773 return handled; | 811 return handled; |
| 774 } | 812 } |
| 775 | 813 |
| 814 bool RenderViewHost::CanHandleWhileSwappedOut(const IPC::Message& msg) { |
| 815 // We drop most messages that arrive from a swapped out renderer. However, |
| 816 // some are important (e.g., ACKs) for keeping the browser and renderer state |
| 817 // consistent in case we later return to the renderer. |
| 818 switch (msg.type()) { |
| 819 // Sends an ACK. |
| 820 case ViewHostMsg_ShowView::ID: |
| 821 // Sends an ACK. |
| 822 case ViewHostMsg_ShowWidget::ID: |
| 823 // Sends an ACK. |
| 824 case ViewHostMsg_ShowFullscreenWidget::ID: |
| 825 // Updates browser state. |
| 826 case ViewHostMsg_RenderViewReady::ID: |
| 827 // Updates browser state. |
| 828 case ViewHostMsg_RenderViewGone::ID: |
| 829 // Updates the previous navigation entry. |
| 830 case ViewHostMsg_UpdateState::ID: |
| 831 // Sends an ACK. |
| 832 case ViewHostMsg_UpdateTargetURL::ID: |
| 833 // Updates browser state. |
| 834 case ViewHostMsg_Snapshot::ID: |
| 835 // We allow closing even if we are in the process of swapping out. |
| 836 case ViewHostMsg_Close::ID: |
| 837 // Sends an ACK. |
| 838 case ViewHostMsg_RequestMove::ID: |
| 839 // Updates browser state, and important for tests. |
| 840 case ViewHostMsg_DomOperationResponse::ID: |
| 841 // Suppresses dialog and sends an ACK. |
| 842 case ViewHostMsg_RunJavaScriptMessage::ID: |
| 843 // Suppresses dialog and sends an ACK. |
| 844 case ViewHostMsg_RunBeforeUnloadConfirm::ID: |
| 845 // Stops hang monitor. |
| 846 case ViewHostMsg_ShouldClose_ACK::ID: |
| 847 // We allow closing even if we are in the process of swapping out. |
| 848 case ViewHostMsg_ClosePage_ACK::ID: |
| 849 // Sends an ACK. |
| 850 case ViewHostMsg_AccessibilityNotifications::ID: |
| 851 return true; |
| 852 default: |
| 853 break; |
| 854 } |
| 855 return false; |
| 856 } |
| 857 |
| 776 void RenderViewHost::Shutdown() { | 858 void RenderViewHost::Shutdown() { |
| 777 // If we are being run modally (see RunModal), then we need to cleanup. | 859 // If we are being run modally (see RunModal), then we need to cleanup. |
| 778 if (run_modal_reply_msg_) { | 860 if (run_modal_reply_msg_) { |
| 779 Send(run_modal_reply_msg_); | 861 Send(run_modal_reply_msg_); |
| 780 run_modal_reply_msg_ = NULL; | 862 run_modal_reply_msg_ = NULL; |
| 781 } | 863 } |
| 782 | 864 |
| 783 RenderWidgetHost::Shutdown(); | 865 RenderWidgetHost::Shutdown(); |
| 784 } | 866 } |
| 785 | 867 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 809 if (view) | 891 if (view) |
| 810 view->CreateNewFullscreenWidget(route_id); | 892 view->CreateNewFullscreenWidget(route_id); |
| 811 } | 893 } |
| 812 | 894 |
| 813 void RenderViewHost::OnMsgShowView(int route_id, | 895 void RenderViewHost::OnMsgShowView(int route_id, |
| 814 WindowOpenDisposition disposition, | 896 WindowOpenDisposition disposition, |
| 815 const gfx::Rect& initial_pos, | 897 const gfx::Rect& initial_pos, |
| 816 bool user_gesture) { | 898 bool user_gesture) { |
| 817 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 899 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
| 818 if (view) { | 900 if (view) { |
| 819 view->ShowCreatedWindow(route_id, disposition, initial_pos, user_gesture); | 901 if (!is_swapped_out_) |
| 902 view->ShowCreatedWindow(route_id, disposition, initial_pos, user_gesture); |
| 820 Send(new ViewMsg_Move_ACK(route_id)); | 903 Send(new ViewMsg_Move_ACK(route_id)); |
| 821 } | 904 } |
| 822 } | 905 } |
| 823 | 906 |
| 824 void RenderViewHost::OnMsgShowWidget(int route_id, | 907 void RenderViewHost::OnMsgShowWidget(int route_id, |
| 825 const gfx::Rect& initial_pos) { | 908 const gfx::Rect& initial_pos) { |
| 826 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 909 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
| 827 if (view) { | 910 if (view) { |
| 828 view->ShowCreatedWidget(route_id, initial_pos); | 911 if (!is_swapped_out_) |
| 912 view->ShowCreatedWidget(route_id, initial_pos); |
| 829 Send(new ViewMsg_Move_ACK(route_id)); | 913 Send(new ViewMsg_Move_ACK(route_id)); |
| 830 } | 914 } |
| 831 } | 915 } |
| 832 | 916 |
| 833 void RenderViewHost::OnMsgShowFullscreenWidget(int route_id) { | 917 void RenderViewHost::OnMsgShowFullscreenWidget(int route_id) { |
| 834 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 918 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
| 835 if (view) { | 919 if (view) { |
| 836 view->ShowCreatedFullscreenWidget(route_id); | 920 if (!is_swapped_out_) |
| 921 view->ShowCreatedFullscreenWidget(route_id); |
| 837 Send(new ViewMsg_Move_ACK(route_id)); | 922 Send(new ViewMsg_Move_ACK(route_id)); |
| 838 } | 923 } |
| 839 } | 924 } |
| 840 | 925 |
| 841 void RenderViewHost::OnMsgRunModal(IPC::Message* reply_msg) { | 926 void RenderViewHost::OnMsgRunModal(IPC::Message* reply_msg) { |
| 842 DCHECK(!run_modal_reply_msg_); | 927 DCHECK(!run_modal_reply_msg_); |
| 843 run_modal_reply_msg_ = reply_msg; | 928 run_modal_reply_msg_ = reply_msg; |
| 844 | 929 |
| 845 // TODO(darin): Bug 1107929: Need to inform our delegate to show this view in | 930 // TODO(darin): Bug 1107929: Need to inform our delegate to show this view in |
| 846 // an app-modal fashion. | 931 // an app-modal fashion. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 } | 1033 } |
| 949 delegate_->UpdateTitle(this, page_id, title); | 1034 delegate_->UpdateTitle(this, page_id, title); |
| 950 } | 1035 } |
| 951 | 1036 |
| 952 void RenderViewHost::OnMsgUpdateEncoding(const std::string& encoding_name) { | 1037 void RenderViewHost::OnMsgUpdateEncoding(const std::string& encoding_name) { |
| 953 delegate_->UpdateEncoding(this, encoding_name); | 1038 delegate_->UpdateEncoding(this, encoding_name); |
| 954 } | 1039 } |
| 955 | 1040 |
| 956 void RenderViewHost::OnMsgUpdateTargetURL(int32 page_id, | 1041 void RenderViewHost::OnMsgUpdateTargetURL(int32 page_id, |
| 957 const GURL& url) { | 1042 const GURL& url) { |
| 958 delegate_->UpdateTargetURL(page_id, url); | 1043 if (!is_swapped_out_) |
| 1044 delegate_->UpdateTargetURL(page_id, url); |
| 959 | 1045 |
| 960 // Send a notification back to the renderer that we are ready to | 1046 // Send a notification back to the renderer that we are ready to |
| 961 // receive more target urls. | 1047 // receive more target urls. |
| 962 Send(new ViewMsg_UpdateTargetURL_ACK(routing_id())); | 1048 Send(new ViewMsg_UpdateTargetURL_ACK(routing_id())); |
| 963 } | 1049 } |
| 964 | 1050 |
| 965 void RenderViewHost::OnUpdateInspectorSetting( | 1051 void RenderViewHost::OnUpdateInspectorSetting( |
| 966 const std::string& key, const std::string& value) { | 1052 const std::string& key, const std::string& value) { |
| 967 delegate_->UpdateInspectorSetting(key, value); | 1053 delegate_->UpdateInspectorSetting(key, value); |
| 968 } | 1054 } |
| 969 | 1055 |
| 970 void RenderViewHost::OnMsgClose() { | 1056 void RenderViewHost::OnMsgClose() { |
| 971 // If the renderer is telling us to close, it has already run the unload | 1057 // If the renderer is telling us to close, it has already run the unload |
| 972 // events, and we can take the fast path. | 1058 // events, and we can take the fast path. |
| 973 ClosePageIgnoringUnloadEvents(); | 1059 ClosePageIgnoringUnloadEvents(); |
| 974 } | 1060 } |
| 975 | 1061 |
| 976 void RenderViewHost::OnMsgRequestMove(const gfx::Rect& pos) { | 1062 void RenderViewHost::OnMsgRequestMove(const gfx::Rect& pos) { |
| 977 delegate_->RequestMove(pos); | 1063 if (!is_swapped_out_) |
| 1064 delegate_->RequestMove(pos); |
| 978 Send(new ViewMsg_Move_ACK(routing_id())); | 1065 Send(new ViewMsg_Move_ACK(routing_id())); |
| 979 } | 1066 } |
| 980 | 1067 |
| 981 void RenderViewHost::OnMsgDidStartLoading() { | 1068 void RenderViewHost::OnMsgDidStartLoading() { |
| 982 delegate_->DidStartLoading(); | 1069 delegate_->DidStartLoading(); |
| 983 } | 1070 } |
| 984 | 1071 |
| 985 void RenderViewHost::OnMsgDidStopLoading() { | 1072 void RenderViewHost::OnMsgDidStopLoading() { |
| 986 delegate_->DidStopLoading(); | 1073 delegate_->DidStopLoading(); |
| 987 } | 1074 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 void RenderViewHost::OnMsgRunJavaScriptMessage( | 1175 void RenderViewHost::OnMsgRunJavaScriptMessage( |
| 1089 const std::wstring& message, | 1176 const std::wstring& message, |
| 1090 const std::wstring& default_prompt, | 1177 const std::wstring& default_prompt, |
| 1091 const GURL& frame_url, | 1178 const GURL& frame_url, |
| 1092 const int flags, | 1179 const int flags, |
| 1093 IPC::Message* reply_msg) { | 1180 IPC::Message* reply_msg) { |
| 1094 // While a JS message dialog is showing, tabs in the same process shouldn't | 1181 // While a JS message dialog is showing, tabs in the same process shouldn't |
| 1095 // process input events. | 1182 // process input events. |
| 1096 process()->set_ignore_input_events(true); | 1183 process()->set_ignore_input_events(true); |
| 1097 StopHangMonitorTimeout(); | 1184 StopHangMonitorTimeout(); |
| 1098 delegate_->RunJavaScriptMessage(message, default_prompt, frame_url, flags, | 1185 delegate_->RunJavaScriptMessage(this, message, default_prompt, frame_url, |
| 1099 reply_msg, | 1186 flags, reply_msg, |
| 1100 &are_javascript_messages_suppressed_); | 1187 &are_javascript_messages_suppressed_); |
| 1101 } | 1188 } |
| 1102 | 1189 |
| 1103 void RenderViewHost::OnMsgRunBeforeUnloadConfirm(const GURL& frame_url, | 1190 void RenderViewHost::OnMsgRunBeforeUnloadConfirm(const GURL& frame_url, |
| 1104 const std::wstring& message, | 1191 const std::wstring& message, |
| 1105 IPC::Message* reply_msg) { | 1192 IPC::Message* reply_msg) { |
| 1106 // While a JS before unload dialog is showing, tabs in the same process | 1193 // While a JS before unload dialog is showing, tabs in the same process |
| 1107 // shouldn't process input events. | 1194 // shouldn't process input events. |
| 1108 process()->set_ignore_input_events(true); | 1195 process()->set_ignore_input_events(true); |
| 1109 StopHangMonitorTimeout(); | 1196 StopHangMonitorTimeout(); |
| 1110 delegate_->RunBeforeUnloadConfirm(message, reply_msg); | 1197 delegate_->RunBeforeUnloadConfirm(this, message, reply_msg); |
| 1111 } | 1198 } |
| 1112 | 1199 |
| 1113 void RenderViewHost::MediaPlayerActionAt(const gfx::Point& location, | 1200 void RenderViewHost::MediaPlayerActionAt(const gfx::Point& location, |
| 1114 const WebMediaPlayerAction& action) { | 1201 const WebMediaPlayerAction& action) { |
| 1115 // TODO(ajwong): Which thread should run this? Does it matter? | 1202 // TODO(ajwong): Which thread should run this? Does it matter? |
| 1116 Send(new ViewMsg_MediaPlayerActionAt(routing_id(), location, action)); | 1203 Send(new ViewMsg_MediaPlayerActionAt(routing_id(), location, action)); |
| 1117 } | 1204 } |
| 1118 | 1205 |
| 1119 void RenderViewHost::ContextMenuClosed( | 1206 void RenderViewHost::ContextMenuClosed( |
| 1120 const webkit_glue::CustomContextMenuContext& custom_context) { | 1207 const webkit_glue::CustomContextMenuContext& custom_context) { |
| 1121 Send(new ViewMsg_ContextMenuClosed(routing_id(), custom_context)); | 1208 Send(new ViewMsg_ContextMenuClosed(routing_id(), custom_context)); |
| 1122 } | 1209 } |
| 1123 | 1210 |
| 1124 void RenderViewHost::OnMsgStartDragging( | 1211 void RenderViewHost::OnMsgStartDragging( |
| 1125 const WebDropData& drop_data, | 1212 const WebDropData& drop_data, |
| 1126 WebDragOperationsMask drag_operations_mask, | 1213 WebDragOperationsMask drag_operations_mask, |
| 1127 const SkBitmap& image, | 1214 const SkBitmap& image, |
| 1128 const gfx::Point& image_offset) { | 1215 const gfx::Point& image_offset) { |
| 1129 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 1216 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
| 1130 if (view) | 1217 if (view) |
| 1131 view->StartDragging(drop_data, drag_operations_mask, image, image_offset); | 1218 view->StartDragging(drop_data, drag_operations_mask, image, image_offset); |
| 1132 } | 1219 } |
| 1133 | 1220 |
| 1134 void RenderViewHost::OnUpdateDragCursor(WebDragOperation current_op) { | 1221 void RenderViewHost::OnUpdateDragCursor(WebDragOperation current_op) { |
| 1135 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 1222 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
| 1136 if (view) | 1223 if (view) |
| 1137 view->UpdateDragCursor(current_op); | 1224 view->UpdateDragCursor(current_op); |
| 1138 } | 1225 } |
| 1139 | 1226 |
| 1140 void RenderViewHost::OnTakeFocus(bool reverse) { | 1227 void RenderViewHost::OnTakeFocus(bool reverse) { |
| 1141 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 1228 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 | 1265 |
| 1179 void RenderViewHost::OnUserGesture() { | 1266 void RenderViewHost::OnUserGesture() { |
| 1180 delegate_->OnUserGesture(); | 1267 delegate_->OnUserGesture(); |
| 1181 } | 1268 } |
| 1182 | 1269 |
| 1183 void RenderViewHost::OnMsgShouldCloseACK(bool proceed) { | 1270 void RenderViewHost::OnMsgShouldCloseACK(bool proceed) { |
| 1184 StopHangMonitorTimeout(); | 1271 StopHangMonitorTimeout(); |
| 1185 // If this renderer navigated while the beforeunload request was in flight, we | 1272 // If this renderer navigated while the beforeunload request was in flight, we |
| 1186 // may have cleared this state in OnMsgNavigate, in which case we can ignore | 1273 // may have cleared this state in OnMsgNavigate, in which case we can ignore |
| 1187 // this message. | 1274 // this message. |
| 1188 if (!is_waiting_for_beforeunload_ack_) | 1275 if (!is_waiting_for_beforeunload_ack_ || is_swapped_out_) |
| 1189 return; | 1276 return; |
| 1190 | 1277 |
| 1191 is_waiting_for_beforeunload_ack_ = false; | 1278 is_waiting_for_beforeunload_ack_ = false; |
| 1192 | 1279 |
| 1193 RenderViewHostDelegate::RendererManagement* management_delegate = | 1280 RenderViewHostDelegate::RendererManagement* management_delegate = |
| 1194 delegate_->GetRendererManagementDelegate(); | 1281 delegate_->GetRendererManagementDelegate(); |
| 1195 if (management_delegate) { | 1282 if (management_delegate) { |
| 1196 management_delegate->ShouldClosePage( | 1283 management_delegate->ShouldClosePage( |
| 1197 unload_ack_is_for_cross_site_transition_, proceed); | 1284 unload_ack_is_for_cross_site_transition_, proceed); |
| 1198 } | 1285 } |
| 1199 | 1286 |
| 1200 // If canceled, notify the delegate to cancel its pending navigation entry. | 1287 // If canceled, notify the delegate to cancel its pending navigation entry. |
| 1201 if (!proceed) | 1288 if (!proceed) |
| 1202 delegate_->DidCancelLoading(); | 1289 delegate_->DidCancelLoading(); |
| 1203 } | 1290 } |
| 1204 | 1291 |
| 1292 void RenderViewHost::OnMsgClosePageACK() { |
| 1293 ClosePageIgnoringUnloadEvents(); |
| 1294 } |
| 1295 |
| 1205 void RenderViewHost::WindowMoveOrResizeStarted() { | 1296 void RenderViewHost::WindowMoveOrResizeStarted() { |
| 1206 Send(new ViewMsg_MoveOrResizeStarted(routing_id())); | 1297 Send(new ViewMsg_MoveOrResizeStarted(routing_id())); |
| 1207 } | 1298 } |
| 1208 | 1299 |
| 1209 void RenderViewHost::NotifyRendererUnresponsive() { | 1300 void RenderViewHost::NotifyRendererUnresponsive() { |
| 1210 delegate_->RendererUnresponsive( | 1301 delegate_->RendererUnresponsive( |
| 1211 this, is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_); | 1302 this, is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_); |
| 1212 } | 1303 } |
| 1213 | 1304 |
| 1214 void RenderViewHost::NotifyRendererResponsive() { | 1305 void RenderViewHost::NotifyRendererResponsive() { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 // If this renderer is not permitted to request this URL, we invalidate the | 1428 // If this renderer is not permitted to request this URL, we invalidate the |
| 1338 // URL. This prevents us from storing the blocked URL and becoming confused | 1429 // URL. This prevents us from storing the blocked URL and becoming confused |
| 1339 // later. | 1430 // later. |
| 1340 VLOG(1) << "Blocked URL " << url->spec(); | 1431 VLOG(1) << "Blocked URL " << url->spec(); |
| 1341 *url = GURL(); | 1432 *url = GURL(); |
| 1342 } | 1433 } |
| 1343 } | 1434 } |
| 1344 | 1435 |
| 1345 void RenderViewHost::OnAccessibilityNotifications( | 1436 void RenderViewHost::OnAccessibilityNotifications( |
| 1346 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) { | 1437 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) { |
| 1347 if (view()) | 1438 if (view() && !is_swapped_out_) |
| 1348 view()->OnAccessibilityNotifications(params); | 1439 view()->OnAccessibilityNotifications(params); |
| 1349 | 1440 |
| 1350 if (!params.empty()) { | 1441 if (!params.empty()) { |
| 1351 for (unsigned i = 0; i < params.size(); i++) { | 1442 for (unsigned i = 0; i < params.size(); i++) { |
| 1352 const ViewHostMsg_AccessibilityNotification_Params& param = params[i]; | 1443 const ViewHostMsg_AccessibilityNotification_Params& param = params[i]; |
| 1353 | 1444 |
| 1354 if (param.notification_type == | 1445 if (param.notification_type == |
| 1355 ViewHostMsg_AccessibilityNotification_Type:: | 1446 ViewHostMsg_AccessibilityNotification_Type:: |
| 1356 NOTIFICATION_TYPE_LOAD_COMPLETE) { | 1447 NOTIFICATION_TYPE_LOAD_COMPLETE) { |
| 1357 // TODO(ctguil): Remove when mac processes OnAccessibilityNotifications. | 1448 // TODO(ctguil): Remove when mac processes OnAccessibilityNotifications. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1454 LOG(DFATAL) << "Invalid checked state " << checked_state; | 1545 LOG(DFATAL) << "Invalid checked state " << checked_state; |
| 1455 return; | 1546 return; |
| 1456 } | 1547 } |
| 1457 | 1548 |
| 1458 CommandState state; | 1549 CommandState state; |
| 1459 state.is_enabled = is_enabled; | 1550 state.is_enabled = is_enabled; |
| 1460 state.checked_state = | 1551 state.checked_state = |
| 1461 static_cast<RenderViewCommandCheckedState>(checked_state); | 1552 static_cast<RenderViewCommandCheckedState>(checked_state); |
| 1462 command_states_[static_cast<RenderViewCommand>(command)] = state; | 1553 command_states_[static_cast<RenderViewCommand>(command)] = state; |
| 1463 } | 1554 } |
| OLD | NEW |