| Index: content/browser/web_contents/render_view_host_manager.cc
 | 
| diff --git a/content/browser/web_contents/render_view_host_manager.cc b/content/browser/web_contents/render_view_host_manager.cc
 | 
| index 62fec79d74de5e16ec285817f4bc86b6f9eb9689..cbe1d22e24c25073488a3d74e709aadc526db7e0 100644
 | 
| --- a/content/browser/web_contents/render_view_host_manager.cc
 | 
| +++ b/content/browser/web_contents/render_view_host_manager.cc
 | 
| @@ -239,6 +239,23 @@ void RenderViewHostManager::DidNavigateMainFrame(
 | 
|    }
 | 
|  }
 | 
|  
 | 
| +void RenderViewHostManager::DidUpdateFrameTree(
 | 
| +    RenderViewHost* render_view_host) {
 | 
| +  DCHECK(render_view_host == current_host());
 | 
| +
 | 
| +  for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin();
 | 
| +       iter != swapped_out_hosts_.end();
 | 
| +       ++iter) {
 | 
| +    DCHECK(iter->second->GetSiteInstance() !=
 | 
| +        current_host()->GetSiteInstance());
 | 
| +
 | 
| +    iter->second->UpdateFrameTree(
 | 
| +        render_view_host->GetProcess()->GetID(),
 | 
| +        render_view_host->GetRoutingID(),
 | 
| +        render_view_host->GetFrameTree());
 | 
| +  }
 | 
| +}
 | 
| +
 | 
|  void RenderViewHostManager::SetWebUIPostCommit(WebUIImpl* web_ui) {
 | 
|    DCHECK(!web_ui_.get());
 | 
|    web_ui_.reset(web_ui);
 | 
| @@ -495,6 +512,14 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry(
 | 
|      if (entry.IsViewSourceMode())
 | 
|        return SiteInstance::CreateForURL(browser_context, dest_url);
 | 
|  
 | 
| +    // If we are navigating from blank SiteInstance to WebUI, make sure we
 | 
| +    // create a new one.
 | 
| +    const WebUIControllerFactory* web_ui_factory =
 | 
| +        content::GetContentClient()->browser()->GetWebUIControllerFactory();
 | 
| +    if (web_ui_factory &&
 | 
| +        web_ui_factory->UseWebUIForURL(browser_context, dest_url))
 | 
| +        return SiteInstance::CreateForURL(browser_context, dest_url);
 | 
| +
 | 
|      // Normally the "site" on the SiteInstance is set lazily when the load
 | 
|      // actually commits. This is to support better process sharing in case
 | 
|      // the site redirects to some other site: we want to use the destination
 | 
| @@ -577,6 +602,17 @@ int RenderViewHostManager::CreateRenderView(
 | 
|      bool swapped_out) {
 | 
|    CHECK(instance);
 | 
|  
 | 
| +  // If the current host is already in the site instance we are looking for
 | 
| +  // and we are creating a swapped out renderer, just return the routing id.
 | 
| +  if (current_host()->GetSiteInstance() == instance) {
 | 
| +    // TODO(nasko): Convert this if statement to a DCHECK once all causes
 | 
| +    // of creating a new non-swapped out RVH for the same SiteInstance as the
 | 
| +    // active one are tracked down and resolved.
 | 
| +    if (swapped_out) {
 | 
| +      return current_host()->GetRoutingID();
 | 
| +    }
 | 
| +  }
 | 
| +
 | 
|    // Check if we've already created an RVH for this SiteInstance.  If so, try
 | 
|    // to re-use the existing one, which has already been initialized.  We'll
 | 
|    // remove it from the list of swapped out hosts if it commits.
 | 
| @@ -607,6 +643,15 @@ int RenderViewHostManager::CreateRenderView(
 | 
|      if (success) {
 | 
|        // Don't show the view until we get a DidNavigate from it.
 | 
|        new_render_view_host->GetView()->Hide();
 | 
| +
 | 
| +      // If we are creating a swapped out RVH, send a message to update the
 | 
| +      // frame tree based on the active RVH for this RenderViewHostManager.
 | 
| +      if (swapped_out) {
 | 
| +        new_render_view_host->UpdateFrameTree(
 | 
| +            current_host()->GetProcess()->GetID(),
 | 
| +            current_host()->GetRoutingID(),
 | 
| +            current_host()->GetFrameTree());
 | 
| +      }
 | 
|      } else if (!swapped_out) {
 | 
|        CancelPending();
 | 
|      }
 | 
| 
 |