Index: content/browser/tab_contents/render_view_host_manager.cc |
diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc |
index 03d8b0aff8886dfbf21cdeb7fb641fc29d95a7d5..da2c40c2099a5d7664719f407df4be263ecbd54e 100644 |
--- a/content/browser/tab_contents/render_view_host_manager.cc |
+++ b/content/browser/tab_contents/render_view_host_manager.cc |
@@ -6,6 +6,7 @@ |
#include "base/command_line.h" |
#include "base/logging.h" |
+#include "content/browser/browser_context.h" |
#include "content/browser/debugger/devtools_manager_impl.h" |
#include "content/browser/renderer_host/render_view_host.h" |
#include "content/browser/renderer_host/render_view_host_delegate.h" |
@@ -71,6 +72,8 @@ void RenderViewHostManager::Init(content::BrowserContext* browser_context, |
// Keep track of renderer processes as they start to shut down. |
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING, |
content::NotificationService::AllSources()); |
+ |
+ browser_context_ = browser_context; |
} |
RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const { |
@@ -92,13 +95,14 @@ RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) { |
!render_view_host_->IsRenderViewLive()) { |
// Note: we don't call InitRenderView here because we are navigating away |
// soon anyway, and we don't have the NavigationEntry for this host. |
- delegate_->CreateRenderViewForRenderManager(render_view_host_); |
+ delegate_->CreateRenderViewForRenderManager(render_view_host_, |
+ MSG_ROUTING_NONE); |
} |
// If the renderer crashed, then try to create a new one to satisfy this |
// navigation request. |
if (!dest_render_view_host->IsRenderViewLive()) { |
- if (!InitRenderView(dest_render_view_host, entry)) |
+ if (!InitRenderView(dest_render_view_host, entry, MSG_ROUTING_NONE)) |
return NULL; |
// Now that we've created a new renderer, be sure to hide it if it isn't |
@@ -489,7 +493,7 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( |
} |
bool RenderViewHostManager::CreatePendingRenderView( |
- const NavigationEntry& entry, SiteInstance* instance) { |
+ const NavigationEntry& entry, SiteInstance* instance, int opener_route_id) { |
NavigationEntry* curr_entry = |
delegate_->GetControllerForRenderManager().GetLastCommittedEntry(); |
if (curr_entry) { |
@@ -520,7 +524,8 @@ bool RenderViewHostManager::CreatePendingRenderView( |
// Prevent the process from exiting while we're trying to use it. |
pending_render_view_host_->process()->AddPendingView(); |
- bool success = InitRenderView(pending_render_view_host_, entry); |
+ bool success = InitRenderView(pending_render_view_host_, entry, |
+ opener_route_id); |
if (success) { |
// Don't show the view until we get a DidNavigate from it. |
pending_render_view_host_->view()->Hide(); |
@@ -531,13 +536,15 @@ bool RenderViewHostManager::CreatePendingRenderView( |
} |
bool RenderViewHostManager::InitRenderView(RenderViewHost* render_view_host, |
- const NavigationEntry& entry) { |
+ const NavigationEntry& entry, |
+ int opener_route_id) { |
// If the pending navigation is to a WebUI, tell the RenderView about any |
// bindings it will need enabled. |
if (pending_web_ui_.get()) |
render_view_host->AllowBindings(pending_web_ui_->bindings()); |
- return delegate_->CreateRenderViewForRenderManager(render_view_host); |
+ return delegate_->CreateRenderViewForRenderManager(render_view_host, |
+ opener_route_id); |
} |
void RenderViewHostManager::CommitPending() { |
@@ -666,12 +673,29 @@ RenderViewHost* RenderViewHostManager::UpdateRendererStateForNavigate( |
if (ShouldTransitionCrossSite() || force_swap) |
new_instance = GetSiteInstanceForEntry(entry, curr_instance); |
+ int opener_route_id = MSG_ROUTING_NONE; |
+ |
if (new_instance != curr_instance || force_swap) { |
// New SiteInstance. |
DCHECK(!cross_navigation_pending_); |
+ // Create proxies for the RenderView's opener chain. |
+ // TODO(supersat): This current only creates a proxy for the direct opener. |
+ if (entry.opener_content_frame_id() != -1) { |
+ content::ContentFrame* opener_frame = |
+ browser_context_->frame_mapper().FindFrame( |
+ entry.opener_content_frame_id()); |
+ // TODO(supersat): Don't use the testing method. |
+ RenderViewHostManager* opener_rvhm = |
+ opener_frame->tab_contents().render_manager_for_testing(); |
+ RenderViewHost* opener_rvh = opener_rvhm->SwappedOutRVHForNavigationEntry( |
+ entry, MSG_ROUTING_NONE); |
+ opener_route_id = opener_rvh->routing_id(); |
+ } |
+ |
// Create a pending RVH and navigate it. |
- bool success = CreatePendingRenderView(entry, new_instance); |
+ bool success = CreatePendingRenderView(entry, new_instance, |
+ opener_route_id); |
if (!success) |
return NULL; |
@@ -812,3 +836,39 @@ bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { |
return swapped_out_hosts_.find(rvh->site_instance()->id()) != |
swapped_out_hosts_.end(); |
} |
+ |
+RenderViewHost* RenderViewHostManager::SwappedOutRVHForNavigationEntry( |
+ const NavigationEntry& entry, int opener_route_id) { |
+ SiteInstance* site_instance = GetSiteInstanceForEntry( |
+ entry, render_view_host_->site_instance()); |
+ |
+ // If we already have a swapped out RVH |
awong
2011/12/21 01:56:07
Use a period at the end of a comment.
supersat
2011/12/23 03:22:46
Done.
|
+ RenderViewHostMap::iterator iter = |
+ swapped_out_hosts_.find(site_instance->id()); |
+ if (iter != swapped_out_hosts_.end()) |
+ return iter->second; |
+ |
+ RenderViewHost* rvh = RenderViewHostFactory::Create( |
+ site_instance, render_view_delegate_, MSG_ROUTING_NONE, delegate_-> |
+ GetControllerForRenderManager().session_storage_namespace()); |
+ |
+ // TODO(supersat): Do we need to call this? |
+ // Prevent the process from exiting while we're trying to use it. |
+ //rvh->process()->AddPendingView(); |
+ |
+ bool success = InitRenderView(rvh, entry, opener_route_id); |
+ if (success) { |
+ content::ContentFrame* frame = browser_context_->frame_mapper().FindFrame( |
+ entry.opener_content_frame_id()); |
+ browser_context_->frame_mapper().AddSwappedOutRendererToFrame(frame, |
+ rvh->process()->GetID(), rvh->routing_id(), -1); |
+ |
+ rvh->view()->Hide(); |
+ // We're not swapping in a new RenderView, so the new ids are set to -1. |
+ rvh->SwapOutAndProxy(-1, -1, entry.opener_content_frame_id()); |
+ swapped_out_hosts_[site_instance->id()] = rvh; |
+ return rvh; |
+ } else { |
+ return NULL; |
+ } |
+} |