Index: content/browser/web_contents/web_contents_impl.cc |
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc |
index d32b7cc1dc744a1ad9674bfca7a2f5db2bf6f8e0..7ea0cb9c34d19ebd72132c816bcdff48dd196411 100644 |
--- a/content/browser/web_contents/web_contents_impl.cc |
+++ b/content/browser/web_contents/web_contents_impl.cc |
@@ -363,6 +363,7 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context, |
audio_stream_monitor_(this), |
virtual_keyboard_requested_(false), |
loading_weak_factory_(this) { |
+ LOG(ERROR) << "WC[" << this << "]::WC"; |
frame_tree_.SetFrameRemoveListener( |
base::Bind(&WebContentsImpl::OnFrameRemoved, |
base::Unretained(this))); |
@@ -408,15 +409,6 @@ WebContentsImpl::~WebContentsImpl() { |
// Manually call the observer methods for the root frame tree node. |
RenderFrameHostManager* root = GetRenderManager(); |
- if (root->pending_frame_host()) { |
- FOR_EACH_OBSERVER(WebContentsObserver, |
- observers_, |
- RenderFrameDeleted(root->pending_frame_host())); |
- } |
- FOR_EACH_OBSERVER(WebContentsObserver, |
- observers_, |
- RenderFrameDeleted(root->current_frame_host())); |
- |
if (root->pending_render_view_host()) { |
FOR_EACH_OBSERVER(WebContentsObserver, |
observers_, |
@@ -439,6 +431,7 @@ WebContentsImpl::~WebContentsImpl() { |
STLDeleteContainerPairSecondPointers(destruction_observers_.begin(), |
destruction_observers_.end()); |
+ LOG(ERROR) << "WC[" << this << "]::~WC"; |
} |
WebContentsImpl* WebContentsImpl::CreateWithOpener( |
@@ -505,9 +498,11 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, |
ObserverListBase<WebContentsObserver>::Iterator it(observers_); |
WebContentsObserver* observer; |
if (render_frame_host) { |
- while ((observer = it.GetNext()) != NULL) |
- if (observer->OnMessageReceived(message, render_frame_host)) |
- return true; |
+ if (!static_cast<RenderFrameHostImpl*>(render_frame_host)->is_swapped_out()) { |
+ while ((observer = it.GetNext()) != NULL) |
+ if (observer->OnMessageReceived(message, render_frame_host)) |
+ return true; |
+ } |
} else { |
while ((observer = it.GetNext()) != NULL) |
if (observer->OnMessageReceived(message)) |
@@ -1200,6 +1195,8 @@ WebContents* WebContentsImpl::GetWebContents() { |
} |
void WebContentsImpl::Init(const WebContents::CreateParams& params) { |
+ LOG(ERROR) << "WC[" << this << "]::Init"; |
+ |
// This is set before initializing the render manager since |
// RenderFrameHostManager::Init calls back into us via its delegate to ask if |
// it should be hidden. |
@@ -1266,6 +1263,9 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { |
for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) |
g_created_callbacks.Get().at(i).Run(this); |
+ |
+ NotifySwappedFromRenderManager( |
+ nullptr, GetRenderManager()->current_frame_host(), true); |
} |
void WebContentsImpl::OnWebContentsDestroyed(WebContentsImpl* web_contents) { |
@@ -3599,43 +3599,42 @@ void WebContentsImpl::RenderViewCreated(RenderViewHost* render_view_host) { |
// Don't send notifications if we are just creating a swapped-out RVH for |
// the opener chain. These won't be used for view-source or WebUI, so it's |
// ok to return early. |
- if (!static_cast<RenderViewHostImpl*>(render_view_host)->is_active()) |
- return; |
+ bool rvh_is_active = |
+ static_cast<RenderViewHostImpl*>(render_view_host)->is_active(); |
- if (delegate_) |
- view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
+ if (rvh_is_active) { |
+ if (delegate_) |
+ view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
- NotificationService::current()->Notify( |
- NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
- Source<WebContents>(this), |
- Details<RenderViewHost>(render_view_host)); |
- |
- // When we're creating views, we're still doing initial setup, so we always |
- // use the pending Web UI rather than any possibly existing committed one. |
- if (GetRenderManager()->pending_web_ui()) |
- GetRenderManager()->pending_web_ui()->RenderViewCreated(render_view_host); |
- |
- NavigationEntry* entry = controller_.GetPendingEntry(); |
- if (entry && entry->IsViewSourceMode()) { |
- // Put the renderer in view source mode. |
- render_view_host->Send( |
- new ViewMsg_EnableViewSourceMode(render_view_host->GetRoutingID())); |
- } |
+ NotificationService::current()->Notify( |
+ NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
+ Source<WebContents>(this), |
+ Details<RenderViewHost>(render_view_host)); |
+ |
+ // When we're creating views, we're still doing initial setup, so we always |
+ // use the pending Web UI rather than any possibly existing committed one. |
+ if (GetRenderManager()->pending_web_ui()) |
+ GetRenderManager()->pending_web_ui()->RenderViewCreated(render_view_host); |
+ |
+ NavigationEntry* entry = controller_.GetPendingEntry(); |
+ if (entry && entry->IsViewSourceMode()) { |
+ // Put the renderer in view source mode. |
+ render_view_host->Send( |
+ new ViewMsg_EnableViewSourceMode(render_view_host->GetRoutingID())); |
+ } |
- view_->RenderViewCreated(render_view_host); |
+ view_->RenderViewCreated(render_view_host); |
- FOR_EACH_OBSERVER( |
- WebContentsObserver, observers_, RenderViewCreated(render_view_host)); |
+ FOR_EACH_OBSERVER( |
+ WebContentsObserver, observers_, RenderViewCreated(render_view_host)); |
+ } |
- // We tell the observers now instead of when the main RenderFrameHostImpl is |
- // constructed because otherwise it would be too early (i.e. IPCs sent to the |
- // frame would be dropped because it's not created yet). |
- RenderFrameHost* main_frame = render_view_host->GetMainFrame(); |
- FOR_EACH_OBSERVER( |
- WebContentsObserver, observers_, RenderFrameCreated(main_frame)); |
- SetAccessibilityModeOnFrame(accessibility_mode_, main_frame); |
+ RenderFrameHostImpl* rfh = |
+ static_cast<RenderFrameHostImpl*>(render_view_host->GetMainFrame()); |
+ rfh->SetRenderFrameCreated(true); |
- DevToolsManager::GetInstance()->RenderViewCreated(this, render_view_host); |
+ if (rvh_is_active) |
+ DevToolsManager::GetInstance()->RenderViewCreated(this, render_view_host); |
} |
void WebContentsImpl::RenderViewReady(RenderViewHost* rvh) { |
@@ -3668,10 +3667,6 @@ void WebContentsImpl::RenderViewReady(RenderViewHost* rvh) { |
void WebContentsImpl::RenderViewTerminated(RenderViewHost* rvh, |
base::TerminationStatus status, |
int error_code) { |
- // TODO(nasko): This isn't ideal; the termination process should be handled by |
- // RenderFrameDeleted(). See http://crbug.com/455943. |
- ClearPowerSaveBlockers(rvh->GetMainFrame()); |
- |
if (rvh != GetRenderViewHost()) { |
// The pending page's RenderViewHost is gone. |
return; |