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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 606113005: Move RenderViewHost swap out state to RenderFrameHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review suggestions Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 SiteInstance* site_instance, int32 page_id) { 887 SiteInstance* site_instance, int32 page_id) {
888 if (GetMaxPageIDForSiteInstance(site_instance) < page_id) 888 if (GetMaxPageIDForSiteInstance(site_instance) < page_id)
889 max_page_ids_[site_instance->GetId()] = page_id; 889 max_page_ids_[site_instance->GetId()] = page_id;
890 } 890 }
891 891
892 void WebContentsImpl::CopyMaxPageIDsFrom(WebContents* web_contents) { 892 void WebContentsImpl::CopyMaxPageIDsFrom(WebContents* web_contents) {
893 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents); 893 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents);
894 max_page_ids_ = contents->max_page_ids_; 894 max_page_ids_ = contents->max_page_ids_;
895 } 895 }
896 896
897 SiteInstance* WebContentsImpl::GetSiteInstance() const { 897 SiteInstanceImpl* WebContentsImpl::GetSiteInstance() const {
898 return GetRenderManager()->current_host()->GetSiteInstance(); 898 return GetRenderManager()->current_host()->GetSiteInstance();
899 } 899 }
900 900
901 SiteInstance* WebContentsImpl::GetPendingSiteInstance() const { 901 SiteInstanceImpl* WebContentsImpl::GetPendingSiteInstance() const {
902 RenderViewHost* dest_rvh = GetRenderManager()->pending_render_view_host() ? 902 RenderViewHostImpl* dest_rvh =
903 GetRenderManager()->pending_render_view_host() : 903 GetRenderManager()->pending_render_view_host() ?
904 GetRenderManager()->current_host(); 904 GetRenderManager()->pending_render_view_host() :
905 GetRenderManager()->current_host();
905 return dest_rvh->GetSiteInstance(); 906 return dest_rvh->GetSiteInstance();
906 } 907 }
907 908
908 bool WebContentsImpl::IsLoading() const { 909 bool WebContentsImpl::IsLoading() const {
909 return is_loading_; 910 return is_loading_;
910 } 911 }
911 912
912 bool WebContentsImpl::IsLoadingToDifferentDocument() const { 913 bool WebContentsImpl::IsLoadingToDifferentDocument() const {
913 return is_loading_ && is_load_to_different_document_; 914 return is_loading_ && is_load_to_different_document_;
914 } 915 }
(...skipping 2491 matching lines...) Expand 10 before | Expand all | Expand 10 after
3406 RenderFrameHost* render_frame_host, 3407 RenderFrameHost* render_frame_host,
3407 const base::string16& message, 3408 const base::string16& message,
3408 const base::string16& default_prompt, 3409 const base::string16& default_prompt,
3409 const GURL& frame_url, 3410 const GURL& frame_url,
3410 JavaScriptMessageType javascript_message_type, 3411 JavaScriptMessageType javascript_message_type,
3411 IPC::Message* reply_msg) { 3412 IPC::Message* reply_msg) {
3412 // Suppress JavaScript dialogs when requested. Also suppress messages when 3413 // Suppress JavaScript dialogs when requested. Also suppress messages when
3413 // showing an interstitial as it's shown over the previous page and we don't 3414 // showing an interstitial as it's shown over the previous page and we don't
3414 // want the hidden page's dialogs to interfere with the interstitial. 3415 // want the hidden page's dialogs to interfere with the interstitial.
3415 bool suppress_this_message = 3416 bool suppress_this_message =
3416 static_cast<RenderViewHostImpl*>(render_frame_host->GetRenderViewHost())-> 3417 static_cast<RenderFrameHostImpl*>(render_frame_host)->is_swapped_out() ||
3417 IsSwappedOut() ||
3418 ShowingInterstitialPage() || 3418 ShowingInterstitialPage() ||
3419 !delegate_ || 3419 !delegate_ ||
3420 delegate_->ShouldSuppressDialogs() || 3420 delegate_->ShouldSuppressDialogs() ||
3421 !delegate_->GetJavaScriptDialogManager(); 3421 !delegate_->GetJavaScriptDialogManager();
3422 3422
3423 if (!suppress_this_message) { 3423 if (!suppress_this_message) {
3424 std::string accept_lang = GetContentClient()->browser()-> 3424 std::string accept_lang = GetContentClient()->browser()->
3425 GetAcceptLangs(GetBrowserContext()); 3425 GetAcceptLangs(GetBrowserContext());
3426 dialog_manager_ = delegate_->GetJavaScriptDialogManager(); 3426 dialog_manager_ = delegate_->GetJavaScriptDialogManager();
3427 dialog_manager_->RunJavaScriptDialog( 3427 dialog_manager_->RunJavaScriptDialog(
(...skipping 24 matching lines...) Expand all
3452 // http://crbug.com/288961 ). The only safe thing to do here is return. 3452 // http://crbug.com/288961 ). The only safe thing to do here is return.
3453 } 3453 }
3454 3454
3455 void WebContentsImpl::RunBeforeUnloadConfirm( 3455 void WebContentsImpl::RunBeforeUnloadConfirm(
3456 RenderFrameHost* render_frame_host, 3456 RenderFrameHost* render_frame_host,
3457 const base::string16& message, 3457 const base::string16& message,
3458 bool is_reload, 3458 bool is_reload,
3459 IPC::Message* reply_msg) { 3459 IPC::Message* reply_msg) {
3460 RenderFrameHostImpl* rfhi = 3460 RenderFrameHostImpl* rfhi =
3461 static_cast<RenderFrameHostImpl*>(render_frame_host); 3461 static_cast<RenderFrameHostImpl*>(render_frame_host);
3462 RenderViewHostImpl* rvhi =
3463 static_cast<RenderViewHostImpl*>(render_frame_host->GetRenderViewHost());
3464 if (delegate_) 3462 if (delegate_)
3465 delegate_->WillRunBeforeUnloadConfirm(); 3463 delegate_->WillRunBeforeUnloadConfirm();
3466 3464
3467 bool suppress_this_message = 3465 bool suppress_this_message =
3468 rvhi->rvh_state() != RenderViewHostImpl::STATE_DEFAULT || 3466 rfhi->rfh_state() != RenderFrameHostImpl::STATE_DEFAULT ||
3469 !delegate_ || 3467 !delegate_ ||
3470 delegate_->ShouldSuppressDialogs() || 3468 delegate_->ShouldSuppressDialogs() ||
3471 !delegate_->GetJavaScriptDialogManager(); 3469 !delegate_->GetJavaScriptDialogManager();
3472 if (suppress_this_message) { 3470 if (suppress_this_message) {
3473 rfhi->JavaScriptDialogClosed(reply_msg, true, base::string16(), true); 3471 rfhi->JavaScriptDialogClosed(reply_msg, true, base::string16(), true);
3474 return; 3472 return;
3475 } 3473 }
3476 3474
3477 is_showing_before_unload_dialog_ = true; 3475 is_showing_before_unload_dialog_ = true;
3478 dialog_manager_ = delegate_->GetJavaScriptDialogManager(); 3476 dialog_manager_ = delegate_->GetJavaScriptDialogManager();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3517 3515
3518 void WebContentsImpl::RemoveBrowserPluginEmbedder() { 3516 void WebContentsImpl::RemoveBrowserPluginEmbedder() {
3519 if (browser_plugin_embedder_) 3517 if (browser_plugin_embedder_)
3520 browser_plugin_embedder_.reset(); 3518 browser_plugin_embedder_.reset();
3521 } 3519 }
3522 3520
3523 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { 3521 void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) {
3524 // Don't send notifications if we are just creating a swapped-out RVH for 3522 // Don't send notifications if we are just creating a swapped-out RVH for
3525 // the opener chain. These won't be used for view-source or WebUI, so it's 3523 // the opener chain. These won't be used for view-source or WebUI, so it's
3526 // ok to return early. 3524 // ok to return early.
3527 if (static_cast<RenderViewHostImpl*>(render_view_host)->IsSwappedOut()) 3525 if (!static_cast<RenderViewHostImpl*>(render_view_host)->is_active())
3528 return; 3526 return;
3529 3527
3530 if (delegate_) 3528 if (delegate_)
3531 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 3529 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
3532 3530
3533 NotificationService::current()->Notify( 3531 NotificationService::current()->Notify(
3534 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, 3532 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED,
3535 Source<WebContents>(this), 3533 Source<WebContents>(this),
3536 Details<RenderViewHost>(render_view_host)); 3534 Details<RenderViewHost>(render_view_host));
3537 3535
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
3936 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); 3934 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
3937 if (rdh) // NULL in unittests. 3935 if (rdh) // NULL in unittests.
3938 rdh->OnUserGesture(this); 3936 rdh->OnUserGesture(this);
3939 } 3937 }
3940 3938
3941 void WebContentsImpl::OnIgnoredUIEvent() { 3939 void WebContentsImpl::OnIgnoredUIEvent() {
3942 // Notify observers. 3940 // Notify observers.
3943 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetIgnoredUIEvent()); 3941 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetIgnoredUIEvent());
3944 } 3942 }
3945 3943
3946 void WebContentsImpl::RendererUnresponsive(RenderViewHost* rvh, 3944 void WebContentsImpl::RendererUnresponsive(RenderViewHost* render_view_host) {
3947 bool is_during_beforeunload,
3948 bool is_during_unload) {
3949 // Don't show hung renderer dialog for a swapped out RVH. 3945 // Don't show hung renderer dialog for a swapped out RVH.
3950 if (rvh != GetRenderViewHost()) 3946 if (render_view_host != GetRenderViewHost())
3951 return; 3947 return;
3952 3948
3953 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); 3949 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(render_view_host);
3950 RenderFrameHostImpl* rfhi =
3951 static_cast<RenderFrameHostImpl*>(rvhi->GetMainFrame());
3954 3952
3955 // Ignore renderer unresponsive event if debugger is attached to the tab 3953 // Ignore renderer unresponsive event if debugger is attached to the tab
3956 // since the event may be a result of the renderer sitting on a breakpoint. 3954 // since the event may be a result of the renderer sitting on a breakpoint.
3957 // See http://crbug.com/65458 3955 // See http://crbug.com/65458
3958 if (DevToolsAgentHost::IsDebuggerAttached(this)) 3956 if (DevToolsAgentHost::IsDebuggerAttached(this))
3959 return; 3957 return;
3960 3958
3961 if (is_during_beforeunload || is_during_unload) { 3959 if (rfhi->is_waiting_for_beforeunload_ack() ||
3960 rfhi->IsWaitingForUnloadACK()) {
3962 // Hang occurred while firing the beforeunload/unload handler. 3961 // Hang occurred while firing the beforeunload/unload handler.
3963 // Pretend the handler fired so tab closing continues as if it had. 3962 // Pretend the handler fired so tab closing continues as if it had.
3964 rvhi->set_sudden_termination_allowed(true); 3963 rvhi->set_sudden_termination_allowed(true);
3965 3964
3966 if (!GetRenderManager()->ShouldCloseTabOnUnresponsiveRenderer()) 3965 if (!GetRenderManager()->ShouldCloseTabOnUnresponsiveRenderer())
3967 return; 3966 return;
3968 3967
3969 // If the tab hangs in the beforeunload/unload handler there's really 3968 // If the tab hangs in the beforeunload/unload handler there's really
3970 // nothing we can do to recover. If the hang is in the beforeunload handler, 3969 // nothing we can do to recover. If the hang is in the beforeunload handler,
3971 // pretend the beforeunload listeners have all fired and allow the delegate 3970 // pretend the beforeunload listeners have all fired and allow the delegate
3972 // to continue closing; the user will not have the option of cancelling the 3971 // to continue closing; the user will not have the option of cancelling the
3973 // close. Otherwise, pretend the unload listeners have all fired and close 3972 // close. Otherwise, pretend the unload listeners have all fired and close
3974 // the tab. 3973 // the tab.
3975 bool close = true; 3974 bool close = true;
3976 if (is_during_beforeunload && delegate_) { 3975 if (rfhi->is_waiting_for_beforeunload_ack() && delegate_) {
3977 delegate_->BeforeUnloadFired(this, true, &close); 3976 delegate_->BeforeUnloadFired(this, true, &close);
3978 } 3977 }
3979 if (close) 3978 if (close)
3980 Close(rvh); 3979 Close(rvhi);
3981 return; 3980 return;
3982 } 3981 }
3983 3982
3984 if (!GetRenderViewHostImpl() || !GetRenderViewHostImpl()->IsRenderViewLive()) 3983 if (!GetRenderViewHostImpl() || !GetRenderViewHostImpl()->IsRenderViewLive())
3985 return; 3984 return;
3986 3985
3987 if (delegate_) 3986 if (delegate_)
3988 delegate_->RendererUnresponsive(this); 3987 delegate_->RendererUnresponsive(this);
3989 } 3988 }
3990 3989
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
4372 node->render_manager()->ResumeResponseDeferredAtStart(); 4371 node->render_manager()->ResumeResponseDeferredAtStart();
4373 } 4372 }
4374 4373
4375 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4374 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4376 force_disable_overscroll_content_ = force_disable; 4375 force_disable_overscroll_content_ = force_disable;
4377 if (view_) 4376 if (view_)
4378 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4377 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4379 } 4378 }
4380 4379
4381 } // namespace content 4380 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698