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

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

Issue 6319001: Support window.opener after a process swap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with trunk. Created 9 years, 7 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) 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 21 matching lines...) Expand all
32 #include "content/browser/site_instance.h" 32 #include "content/browser/site_instance.h"
33 #include "content/browser/user_metrics.h" 33 #include "content/browser/user_metrics.h"
34 #include "content/common/bindings_policy.h" 34 #include "content/common/bindings_policy.h"
35 #include "content/common/content_constants.h" 35 #include "content/common/content_constants.h"
36 #include "content/common/drag_messages.h" 36 #include "content/common/drag_messages.h"
37 #include "content/common/native_web_keyboard_event.h" 37 #include "content/common/native_web_keyboard_event.h"
38 #include "content/common/notification_details.h" 38 #include "content/common/notification_details.h"
39 #include "content/common/notification_service.h" 39 #include "content/common/notification_service.h"
40 #include "content/common/notification_type.h" 40 #include "content/common/notification_type.h"
41 #include "content/common/result_codes.h" 41 #include "content/common/result_codes.h"
42 #include "content/common/swapped_out_messages.h"
42 #include "content/common/url_constants.h" 43 #include "content/common/url_constants.h"
43 #include "content/common/view_messages.h" 44 #include "content/common/view_messages.h"
44 #include "net/base/net_util.h" 45 #include "net/base/net_util.h"
45 #include "net/url_request/url_request_context_getter.h" 46 #include "net/url_request/url_request_context_getter.h"
46 #include "third_party/skia/include/core/SkBitmap.h" 47 #include "third_party/skia/include/core/SkBitmap.h"
47 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" 48 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h"
48 #include "ui/gfx/native_widget_types.h" 49 #include "ui/gfx/native_widget_types.h"
49 #include "webkit/glue/context_menu.h" 50 #include "webkit/glue/context_menu.h"
50 #include "webkit/glue/webaccessibility.h" 51 #include "webkit/glue/webaccessibility.h"
51 #include "webkit/glue/webdropdata.h" 52 #include "webkit/glue/webdropdata.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 86
86 RenderViewHost::RenderViewHost(SiteInstance* instance, 87 RenderViewHost::RenderViewHost(SiteInstance* instance,
87 RenderViewHostDelegate* delegate, 88 RenderViewHostDelegate* delegate,
88 int routing_id, 89 int routing_id,
89 SessionStorageNamespace* session_storage) 90 SessionStorageNamespace* session_storage)
90 : RenderWidgetHost(instance->GetProcess(), routing_id), 91 : RenderWidgetHost(instance->GetProcess(), routing_id),
91 instance_(instance), 92 instance_(instance),
92 delegate_(delegate), 93 delegate_(delegate),
93 waiting_for_drag_context_response_(false), 94 waiting_for_drag_context_response_(false),
94 enabled_bindings_(0), 95 enabled_bindings_(0),
95 pending_request_id_(0), 96 pending_request_id_(-1),
96 navigations_suspended_(false), 97 navigations_suspended_(false),
97 suspended_nav_message_(NULL), 98 suspended_nav_message_(NULL),
99 is_swapped_out_(false),
98 run_modal_reply_msg_(NULL), 100 run_modal_reply_msg_(NULL),
99 is_waiting_for_beforeunload_ack_(false), 101 is_waiting_for_beforeunload_ack_(false),
100 is_waiting_for_unload_ack_(false), 102 is_waiting_for_unload_ack_(false),
101 unload_ack_is_for_cross_site_transition_(false), 103 unload_ack_is_for_cross_site_transition_(false),
102 are_javascript_messages_suppressed_(false), 104 are_javascript_messages_suppressed_(false),
103 sudden_termination_allowed_(false), 105 sudden_termination_allowed_(false),
104 session_storage_namespace_(session_storage), 106 session_storage_namespace_(session_storage),
105 save_accessibility_tree_for_testing_(false), 107 save_accessibility_tree_for_testing_(false),
106 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING) { 108 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING) {
107 if (!session_storage_namespace_) { 109 if (!session_storage_namespace_) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 Navigate(params); 253 Navigate(params);
252 } 254 }
253 255
254 void RenderViewHost::SetNavigationsSuspended(bool suspend) { 256 void RenderViewHost::SetNavigationsSuspended(bool suspend) {
255 // This should only be called to toggle the state. 257 // This should only be called to toggle the state.
256 DCHECK(navigations_suspended_ != suspend); 258 DCHECK(navigations_suspended_ != suspend);
257 259
258 navigations_suspended_ = suspend; 260 navigations_suspended_ = suspend;
259 if (!suspend && suspended_nav_message_.get()) { 261 if (!suspend && suspended_nav_message_.get()) {
260 // There's a navigation message waiting to be sent. Now that we're not 262 // There's a navigation message waiting to be sent. Now that we're not
261 // suspended anymore, resume navigation by sending it. 263 // suspended anymore, resume navigation by sending it. If we were swapped
264 // out, we should also stop filtering out the IPC messages now.
265 is_swapped_out_ = false;
262 Send(suspended_nav_message_.release()); 266 Send(suspended_nav_message_.release());
263 } 267 }
264 } 268 }
265 269
270 void RenderViewHost::CancelSuspendedNavigations() {
271 // Clear any state if a pending navigation is canceled or pre-empted.
272 if (suspended_nav_message_.get())
273 suspended_nav_message_.reset();
274 navigations_suspended_ = false;
275 }
276
266 void RenderViewHost::FirePageBeforeUnload(bool for_cross_site_transition) { 277 void RenderViewHost::FirePageBeforeUnload(bool for_cross_site_transition) {
267 if (!IsRenderViewLive()) { 278 if (!IsRenderViewLive()) {
268 // This RenderViewHost doesn't have a live renderer, so just skip running 279 // This RenderViewHost doesn't have a live renderer, so just skip running
269 // the onbeforeunload handler. 280 // the onbeforeunload handler.
270 is_waiting_for_beforeunload_ack_ = true; // Checked by OnMsgShouldCloseACK. 281 is_waiting_for_beforeunload_ack_ = true; // Checked by OnMsgShouldCloseACK.
271 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; 282 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition;
272 OnMsgShouldCloseACK(true); 283 OnMsgShouldCloseACK(true);
273 return; 284 return;
274 } 285 }
275 286
(...skipping 12 matching lines...) Expand all
288 } else { 299 } else {
289 // Start the hang monitor in case the renderer hangs in the beforeunload 300 // Start the hang monitor in case the renderer hangs in the beforeunload
290 // handler. 301 // handler.
291 is_waiting_for_beforeunload_ack_ = true; 302 is_waiting_for_beforeunload_ack_ = true;
292 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; 303 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition;
293 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 304 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
294 Send(new ViewMsg_ShouldClose(routing_id())); 305 Send(new ViewMsg_ShouldClose(routing_id()));
295 } 306 }
296 } 307 }
297 308
298 void RenderViewHost::ClosePage(bool for_cross_site_transition, 309 void RenderViewHost::SwapOut(int new_render_process_host_id,
299 int new_render_process_host_id, 310 int new_request_id) {
300 int new_request_id) { 311 // 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 312 // 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 313 // already decided to silence them in crbug.com/68780. We will set it back
303 // errors) where we'll continue to show this RVH. 314 // to false in SetNavigationsSuspended if we swap back in.
315 is_swapped_out_ = true;
316
317 // This will be set back to false in OnSwapOutACK, just before we replace
318 // this RVH with the pending RVH.
304 is_waiting_for_unload_ack_ = true; 319 is_waiting_for_unload_ack_ = true;
305 // Start the hang monitor in case the renderer hangs in the unload handler. 320 // Start the hang monitor in case the renderer hangs in the unload handler.
306 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); 321 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
307 322
308 ViewMsg_ClosePage_Params params; 323 ViewMsg_SwapOut_Params params;
309 params.closing_process_id = process()->id(); 324 params.closing_process_id = process()->id();
310 params.closing_route_id = routing_id(); 325 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; 326 params.new_render_process_host_id = new_render_process_host_id;
313 params.new_request_id = new_request_id; 327 params.new_request_id = new_request_id;
314 if (IsRenderViewLive()) { 328 if (IsRenderViewLive()) {
329 Send(new ViewMsg_SwapOut(routing_id(), params));
330 } else {
331 // This RenderViewHost doesn't have a live renderer, so just skip the unload
332 // event. We must notify the ResourceDispatcherHost on the IO thread,
333 // which we will do through the RenderProcessHost's widget helper.
334 process()->CrossSiteSwapOutACK(params);
335 }
336 }
337
338 void RenderViewHost::OnSwapOutACK() {
339 // Stop the hang monitor now that the unload handler has finished.
340 StopHangMonitorTimeout();
341 is_waiting_for_unload_ack_ = false;
342 }
343
344 void RenderViewHost::WasSwappedOut() {
345 // Don't bother reporting hung state anymore.
346 StopHangMonitorTimeout();
347
348 // Inform the renderer that it can exit if no one else is using it.
349 Send(new ViewMsg_WasSwappedOut(routing_id()));
350 }
351
352 void RenderViewHost::ClosePage() {
353 // Start the hang monitor in case the renderer hangs in the unload handler.
354 is_waiting_for_unload_ack_ = true;
355 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS));
356
357 if (IsRenderViewLive()) {
358 // TODO(creis): Should this be moved to Shutdown? It may not be called for
359 // RenderViewHosts that have been swapped out.
315 NotificationService::current()->Notify( 360 NotificationService::current()->Notify(
316 NotificationType::RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, 361 NotificationType::RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW,
317 Source<RenderViewHost>(this), 362 Source<RenderViewHost>(this),
318 NotificationService::NoDetails()); 363 NotificationService::NoDetails());
319 364
320 Send(new ViewMsg_ClosePage(routing_id(), params)); 365 Send(new ViewMsg_ClosePage(routing_id()));
321 } else { 366 } else {
322 // This RenderViewHost doesn't have a live renderer, so just skip closing 367 // 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, 368 // 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(); 369 ClosePageIgnoringUnloadEvents();
338 } 370 }
339 } 371 }
340 372
341 void RenderViewHost::ClosePageIgnoringUnloadEvents() { 373 void RenderViewHost::ClosePageIgnoringUnloadEvents() {
342 StopHangMonitorTimeout(); 374 StopHangMonitorTimeout();
343 is_waiting_for_beforeunload_ack_ = false; 375 is_waiting_for_beforeunload_ack_ = false;
344 is_waiting_for_unload_ack_ = false; 376 is_waiting_for_unload_ack_ = false;
345 377
346 sudden_termination_allowed_ = true; 378 sudden_termination_allowed_ = true;
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 return sudden_termination_allowed_ || process()->sudden_termination_allowed(); 696 return sudden_termination_allowed_ || process()->sudden_termination_allowed();
665 } 697 }
666 698
667 /////////////////////////////////////////////////////////////////////////////// 699 ///////////////////////////////////////////////////////////////////////////////
668 // RenderViewHost, IPC message handlers: 700 // RenderViewHost, IPC message handlers:
669 701
670 bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { 702 bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
671 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this)) 703 if (!BrowserMessageFilter::CheckCanDispatchOnUI(msg, this))
672 return true; 704 return true;
673 705
706 // Filter out most IPC messages if this renderer is swapped out.
707 // We still want to certain ACKs to keep our state consistent.
708 if (is_swapped_out_)
709 if (!content::SwappedOutMessages::CanHandleWhileSwappedOut(msg))
710 return true;
711
674 { 712 {
675 // delegate_->OnMessageReceived can end up deleting |this|, in which case 713 // delegate_->OnMessageReceived can end up deleting |this|, in which case
676 // the destructor for ObserverListBase::Iterator would access the deleted 714 // the destructor for ObserverListBase::Iterator would access the deleted
677 // observers_. 715 // observers_.
678 ObserverListBase<RenderViewHostObserver>::Iterator it(observers_); 716 ObserverListBase<RenderViewHostObserver>::Iterator it(observers_);
679 RenderViewHostObserver* observer; 717 RenderViewHostObserver* observer;
680 while ((observer = it.GetNext()) != NULL) 718 while ((observer = it.GetNext()) != NULL)
681 if (observer->OnMessageReceived(msg)) 719 if (observer->OnMessageReceived(msg))
682 return true; 720 return true;
683 } 721 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) 759 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText)
722 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, 760 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage,
723 OnMsgRunJavaScriptMessage) 761 OnMsgRunJavaScriptMessage)
724 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, 762 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm,
725 OnMsgRunBeforeUnloadConfirm) 763 OnMsgRunBeforeUnloadConfirm)
726 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnMsgStartDragging) 764 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnMsgStartDragging)
727 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) 765 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor)
728 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) 766 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
729 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) 767 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole)
730 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) 768 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK)
769 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnMsgClosePageACK)
731 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged) 770 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged)
732 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications, 771 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications,
733 OnAccessibilityNotifications) 772 OnAccessibilityNotifications)
734 IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted) 773 IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted)
735 IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked) 774 IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked)
736 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) 775 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed)
737 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) 776 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged)
738 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) 777 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits)
739 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) 778 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse)
740 #if defined(OS_MACOSX) 779 #if defined(OS_MACOSX)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 if (view) 829 if (view)
791 view->CreateNewFullscreenWidget(route_id); 830 view->CreateNewFullscreenWidget(route_id);
792 } 831 }
793 832
794 void RenderViewHost::OnMsgShowView(int route_id, 833 void RenderViewHost::OnMsgShowView(int route_id,
795 WindowOpenDisposition disposition, 834 WindowOpenDisposition disposition,
796 const gfx::Rect& initial_pos, 835 const gfx::Rect& initial_pos,
797 bool user_gesture) { 836 bool user_gesture) {
798 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 837 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
799 if (view) { 838 if (view) {
800 view->ShowCreatedWindow(route_id, disposition, initial_pos, user_gesture); 839 if (!is_swapped_out_)
840 view->ShowCreatedWindow(route_id, disposition, initial_pos, user_gesture);
801 Send(new ViewMsg_Move_ACK(route_id)); 841 Send(new ViewMsg_Move_ACK(route_id));
802 } 842 }
803 } 843 }
804 844
805 void RenderViewHost::OnMsgShowWidget(int route_id, 845 void RenderViewHost::OnMsgShowWidget(int route_id,
806 const gfx::Rect& initial_pos) { 846 const gfx::Rect& initial_pos) {
807 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 847 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
808 if (view) { 848 if (view) {
809 view->ShowCreatedWidget(route_id, initial_pos); 849 if (!is_swapped_out_)
850 view->ShowCreatedWidget(route_id, initial_pos);
810 Send(new ViewMsg_Move_ACK(route_id)); 851 Send(new ViewMsg_Move_ACK(route_id));
811 } 852 }
812 } 853 }
813 854
814 void RenderViewHost::OnMsgShowFullscreenWidget(int route_id) { 855 void RenderViewHost::OnMsgShowFullscreenWidget(int route_id) {
815 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 856 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
816 if (view) { 857 if (view) {
817 view->ShowCreatedFullscreenWidget(route_id); 858 if (!is_swapped_out_)
859 view->ShowCreatedFullscreenWidget(route_id);
818 Send(new ViewMsg_Move_ACK(route_id)); 860 Send(new ViewMsg_Move_ACK(route_id));
819 } 861 }
820 } 862 }
821 863
822 void RenderViewHost::OnMsgRunModal(IPC::Message* reply_msg) { 864 void RenderViewHost::OnMsgRunModal(IPC::Message* reply_msg) {
823 DCHECK(!run_modal_reply_msg_); 865 DCHECK(!run_modal_reply_msg_);
824 run_modal_reply_msg_ = reply_msg; 866 run_modal_reply_msg_ = reply_msg;
825 867
826 // TODO(darin): Bug 1107929: Need to inform our delegate to show this view in 868 // TODO(darin): Bug 1107929: Need to inform our delegate to show this view in
827 // an app-modal fashion. 869 // an app-modal fashion.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 } 971 }
930 delegate_->UpdateTitle(this, page_id, title); 972 delegate_->UpdateTitle(this, page_id, title);
931 } 973 }
932 974
933 void RenderViewHost::OnMsgUpdateEncoding(const std::string& encoding_name) { 975 void RenderViewHost::OnMsgUpdateEncoding(const std::string& encoding_name) {
934 delegate_->UpdateEncoding(this, encoding_name); 976 delegate_->UpdateEncoding(this, encoding_name);
935 } 977 }
936 978
937 void RenderViewHost::OnMsgUpdateTargetURL(int32 page_id, 979 void RenderViewHost::OnMsgUpdateTargetURL(int32 page_id,
938 const GURL& url) { 980 const GURL& url) {
939 delegate_->UpdateTargetURL(page_id, url); 981 if (!is_swapped_out_)
982 delegate_->UpdateTargetURL(page_id, url);
940 983
941 // Send a notification back to the renderer that we are ready to 984 // Send a notification back to the renderer that we are ready to
942 // receive more target urls. 985 // receive more target urls.
943 Send(new ViewMsg_UpdateTargetURL_ACK(routing_id())); 986 Send(new ViewMsg_UpdateTargetURL_ACK(routing_id()));
944 } 987 }
945 988
946 void RenderViewHost::OnUpdateInspectorSetting( 989 void RenderViewHost::OnUpdateInspectorSetting(
947 const std::string& key, const std::string& value) { 990 const std::string& key, const std::string& value) {
948 delegate_->UpdateInspectorSetting(key, value); 991 delegate_->UpdateInspectorSetting(key, value);
949 } 992 }
950 993
951 void RenderViewHost::OnMsgClose() { 994 void RenderViewHost::OnMsgClose() {
952 // If the renderer is telling us to close, it has already run the unload 995 // If the renderer is telling us to close, it has already run the unload
953 // events, and we can take the fast path. 996 // events, and we can take the fast path.
954 ClosePageIgnoringUnloadEvents(); 997 ClosePageIgnoringUnloadEvents();
955 } 998 }
956 999
957 void RenderViewHost::OnMsgRequestMove(const gfx::Rect& pos) { 1000 void RenderViewHost::OnMsgRequestMove(const gfx::Rect& pos) {
958 delegate_->RequestMove(pos); 1001 if (!is_swapped_out_)
1002 delegate_->RequestMove(pos);
959 Send(new ViewMsg_Move_ACK(routing_id())); 1003 Send(new ViewMsg_Move_ACK(routing_id()));
960 } 1004 }
961 1005
962 void RenderViewHost::OnMsgDidStartLoading() { 1006 void RenderViewHost::OnMsgDidStartLoading() {
963 delegate_->DidStartLoading(); 1007 delegate_->DidStartLoading();
964 } 1008 }
965 1009
966 void RenderViewHost::OnMsgDidStopLoading() { 1010 void RenderViewHost::OnMsgDidStopLoading() {
967 delegate_->DidStopLoading(); 1011 delegate_->DidStopLoading();
968 } 1012 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 void RenderViewHost::OnMsgRunJavaScriptMessage( 1114 void RenderViewHost::OnMsgRunJavaScriptMessage(
1071 const std::wstring& message, 1115 const std::wstring& message,
1072 const std::wstring& default_prompt, 1116 const std::wstring& default_prompt,
1073 const GURL& frame_url, 1117 const GURL& frame_url,
1074 const int flags, 1118 const int flags,
1075 IPC::Message* reply_msg) { 1119 IPC::Message* reply_msg) {
1076 // While a JS message dialog is showing, tabs in the same process shouldn't 1120 // While a JS message dialog is showing, tabs in the same process shouldn't
1077 // process input events. 1121 // process input events.
1078 process()->set_ignore_input_events(true); 1122 process()->set_ignore_input_events(true);
1079 StopHangMonitorTimeout(); 1123 StopHangMonitorTimeout();
1080 delegate_->RunJavaScriptMessage(message, default_prompt, frame_url, flags, 1124 delegate_->RunJavaScriptMessage(this, message, default_prompt, frame_url,
1081 reply_msg, 1125 flags, reply_msg,
1082 &are_javascript_messages_suppressed_); 1126 &are_javascript_messages_suppressed_);
1083 } 1127 }
1084 1128
1085 void RenderViewHost::OnMsgRunBeforeUnloadConfirm(const GURL& frame_url, 1129 void RenderViewHost::OnMsgRunBeforeUnloadConfirm(const GURL& frame_url,
1086 const std::wstring& message, 1130 const std::wstring& message,
1087 IPC::Message* reply_msg) { 1131 IPC::Message* reply_msg) {
1088 // While a JS before unload dialog is showing, tabs in the same process 1132 // While a JS before unload dialog is showing, tabs in the same process
1089 // shouldn't process input events. 1133 // shouldn't process input events.
1090 process()->set_ignore_input_events(true); 1134 process()->set_ignore_input_events(true);
1091 StopHangMonitorTimeout(); 1135 StopHangMonitorTimeout();
1092 delegate_->RunBeforeUnloadConfirm(message, reply_msg); 1136 delegate_->RunBeforeUnloadConfirm(this, message, reply_msg);
1093 } 1137 }
1094 1138
1095 void RenderViewHost::MediaPlayerActionAt(const gfx::Point& location, 1139 void RenderViewHost::MediaPlayerActionAt(const gfx::Point& location,
1096 const WebMediaPlayerAction& action) { 1140 const WebMediaPlayerAction& action) {
1097 // TODO(ajwong): Which thread should run this? Does it matter? 1141 // TODO(ajwong): Which thread should run this? Does it matter?
1098 Send(new ViewMsg_MediaPlayerActionAt(routing_id(), location, action)); 1142 Send(new ViewMsg_MediaPlayerActionAt(routing_id(), location, action));
1099 } 1143 }
1100 1144
1101 void RenderViewHost::ContextMenuClosed( 1145 void RenderViewHost::ContextMenuClosed(
1102 const webkit_glue::CustomContextMenuContext& custom_context) { 1146 const webkit_glue::CustomContextMenuContext& custom_context) {
1103 Send(new ViewMsg_ContextMenuClosed(routing_id(), custom_context)); 1147 Send(new ViewMsg_ContextMenuClosed(routing_id(), custom_context));
1104 } 1148 }
1105 1149
1106 void RenderViewHost::OnMsgStartDragging( 1150 void RenderViewHost::OnMsgStartDragging(
1107 const WebDropData& drop_data, 1151 const WebDropData& drop_data,
1108 WebDragOperationsMask drag_operations_mask, 1152 WebDragOperationsMask drag_operations_mask,
1109 const SkBitmap& image, 1153 const SkBitmap& image,
1110 const gfx::Point& image_offset) { 1154 const gfx::Point& image_offset) {
1111 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 1155 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
1112 if (view) 1156 if (view)
1113 view->StartDragging(drop_data, drag_operations_mask, image, image_offset); 1157 view->StartDragging(drop_data, drag_operations_mask, image, image_offset);
1114 } 1158 }
1115 1159
1116 void RenderViewHost::OnUpdateDragCursor(WebDragOperation current_op) { 1160 void RenderViewHost::OnUpdateDragCursor(WebDragOperation current_op) {
1117 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 1161 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
1118 if (view) 1162 if (view)
1119 view->UpdateDragCursor(current_op); 1163 view->UpdateDragCursor(current_op);
1120 } 1164 }
1121 1165
1122 void RenderViewHost::OnTakeFocus(bool reverse) { 1166 void RenderViewHost::OnTakeFocus(bool reverse) {
1123 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); 1167 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 1204
1161 void RenderViewHost::OnUserGesture() { 1205 void RenderViewHost::OnUserGesture() {
1162 delegate_->OnUserGesture(); 1206 delegate_->OnUserGesture();
1163 } 1207 }
1164 1208
1165 void RenderViewHost::OnMsgShouldCloseACK(bool proceed) { 1209 void RenderViewHost::OnMsgShouldCloseACK(bool proceed) {
1166 StopHangMonitorTimeout(); 1210 StopHangMonitorTimeout();
1167 // If this renderer navigated while the beforeunload request was in flight, we 1211 // 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 1212 // may have cleared this state in OnMsgNavigate, in which case we can ignore
1169 // this message. 1213 // this message.
1170 if (!is_waiting_for_beforeunload_ack_) 1214 if (!is_waiting_for_beforeunload_ack_ || is_swapped_out_)
1171 return; 1215 return;
1172 1216
1173 is_waiting_for_beforeunload_ack_ = false; 1217 is_waiting_for_beforeunload_ack_ = false;
1174 1218
1175 RenderViewHostDelegate::RendererManagement* management_delegate = 1219 RenderViewHostDelegate::RendererManagement* management_delegate =
1176 delegate_->GetRendererManagementDelegate(); 1220 delegate_->GetRendererManagementDelegate();
1177 if (management_delegate) { 1221 if (management_delegate) {
1178 management_delegate->ShouldClosePage( 1222 management_delegate->ShouldClosePage(
1179 unload_ack_is_for_cross_site_transition_, proceed); 1223 unload_ack_is_for_cross_site_transition_, proceed);
1180 } 1224 }
1181 1225
1182 // If canceled, notify the delegate to cancel its pending navigation entry. 1226 // If canceled, notify the delegate to cancel its pending navigation entry.
1183 if (!proceed) 1227 if (!proceed)
1184 delegate_->DidCancelLoading(); 1228 delegate_->DidCancelLoading();
1185 } 1229 }
1186 1230
1231 void RenderViewHost::OnMsgClosePageACK() {
1232 ClosePageIgnoringUnloadEvents();
1233 }
1234
1187 void RenderViewHost::WindowMoveOrResizeStarted() { 1235 void RenderViewHost::WindowMoveOrResizeStarted() {
1188 Send(new ViewMsg_MoveOrResizeStarted(routing_id())); 1236 Send(new ViewMsg_MoveOrResizeStarted(routing_id()));
1189 } 1237 }
1190 1238
1191 void RenderViewHost::NotifyRendererUnresponsive() { 1239 void RenderViewHost::NotifyRendererUnresponsive() {
1192 delegate_->RendererUnresponsive( 1240 delegate_->RendererUnresponsive(
1193 this, is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_); 1241 this, is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_);
1194 } 1242 }
1195 1243
1196 void RenderViewHost::NotifyRendererResponsive() { 1244 void RenderViewHost::NotifyRendererResponsive() {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 // If this renderer is not permitted to request this URL, we invalidate the 1367 // 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 1368 // URL. This prevents us from storing the blocked URL and becoming confused
1321 // later. 1369 // later.
1322 VLOG(1) << "Blocked URL " << url->spec(); 1370 VLOG(1) << "Blocked URL " << url->spec();
1323 *url = GURL(); 1371 *url = GURL();
1324 } 1372 }
1325 } 1373 }
1326 1374
1327 void RenderViewHost::OnAccessibilityNotifications( 1375 void RenderViewHost::OnAccessibilityNotifications(
1328 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) { 1376 const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) {
1329 if (view()) 1377 if (view() && !is_swapped_out_)
1330 view()->OnAccessibilityNotifications(params); 1378 view()->OnAccessibilityNotifications(params);
1331 1379
1332 if (!params.empty()) { 1380 if (!params.empty()) {
1333 for (unsigned i = 0; i < params.size(); i++) { 1381 for (unsigned i = 0; i < params.size(); i++) {
1334 const ViewHostMsg_AccessibilityNotification_Params& param = params[i]; 1382 const ViewHostMsg_AccessibilityNotification_Params& param = params[i];
1335 1383
1336 if (param.notification_type == 1384 if (param.notification_type ==
1337 ViewHostMsg_AccessibilityNotification_Type:: 1385 ViewHostMsg_AccessibilityNotification_Type::
1338 NOTIFICATION_TYPE_LOAD_COMPLETE) { 1386 NOTIFICATION_TYPE_LOAD_COMPLETE) {
1339 // TODO(ctguil): Remove when mac processes OnAccessibilityNotifications. 1387 // TODO(ctguil): Remove when mac processes OnAccessibilityNotifications.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 if (view) { 1450 if (view) {
1403 view->ShowPopupMenu(params.bounds, 1451 view->ShowPopupMenu(params.bounds,
1404 params.item_height, 1452 params.item_height,
1405 params.item_font_size, 1453 params.item_font_size,
1406 params.selected_item, 1454 params.selected_item,
1407 params.popup_items, 1455 params.popup_items,
1408 params.right_aligned); 1456 params.right_aligned);
1409 } 1457 }
1410 } 1458 }
1411 #endif 1459 #endif
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host.h ('k') | content/browser/renderer_host/render_view_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698