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

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

Issue 10827078: Support frame tree propagation between renderers in the same browsing instance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another round of fixes based on Charlie's review. Created 8 years, 3 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) 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/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 2748 matching lines...) Expand 10 before | Expand all | Expand 10 after
2759 2759
2760 // Update the URL display. 2760 // Update the URL display.
2761 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); 2761 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL);
2762 } 2762 }
2763 2763
2764 void WebContentsImpl::DidChangeLoadProgress(double progress) { 2764 void WebContentsImpl::DidChangeLoadProgress(double progress) {
2765 if (delegate_) 2765 if (delegate_)
2766 delegate_->LoadProgressChanged(this, progress); 2766 delegate_->LoadProgressChanged(this, progress);
2767 } 2767 }
2768 2768
2769 void WebContentsImpl::DidUpdateFrameTree(RenderViewHost* rvh) {
2770 render_manager_.DidUpdateFrameTree(rvh);
2771 }
2772
2769 void WebContentsImpl::DocumentAvailableInMainFrame( 2773 void WebContentsImpl::DocumentAvailableInMainFrame(
2770 RenderViewHost* render_view_host) { 2774 RenderViewHost* render_view_host) {
2771 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2775 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
2772 DocumentAvailableInMainFrame()); 2776 DocumentAvailableInMainFrame());
2773 } 2777 }
2774 2778
2775 void WebContentsImpl::DocumentOnLoadCompletedInMainFrame( 2779 void WebContentsImpl::DocumentOnLoadCompletedInMainFrame(
2776 RenderViewHost* render_view_host, 2780 RenderViewHost* render_view_host,
2777 int32 page_id) { 2781 int32 page_id) {
2778 content::NotificationService::current()->Notify( 2782 content::NotificationService::current()->Notify(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 void WebContentsImpl::RouteMessageEvent( 2857 void WebContentsImpl::RouteMessageEvent(
2854 RenderViewHost* rvh, 2858 RenderViewHost* rvh,
2855 const ViewMsg_PostMessage_Params& params) { 2859 const ViewMsg_PostMessage_Params& params) {
2856 // Only deliver the message to the active RenderViewHost if the request 2860 // Only deliver the message to the active RenderViewHost if the request
2857 // came from a RenderViewHost in the same BrowsingInstance. 2861 // came from a RenderViewHost in the same BrowsingInstance.
2858 if (!rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) 2862 if (!rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance()))
2859 return; 2863 return;
2860 2864
2861 ViewMsg_PostMessage_Params new_params(params); 2865 ViewMsg_PostMessage_Params new_params(params);
2862 2866
2867 // If the renderer has changed while the post message is being routed,
2868 // drop the message, as it will not be delivered to the right target.
2869 if (GetRenderViewHost()->GetProcess()->GetID() != params.target_process_id)
2870 return;
2871 DCHECK(params.target_frame_id != 0);
2872
2863 // If there is a source_routing_id, translate it to the routing ID for 2873 // If there is a source_routing_id, translate it to the routing ID for
2864 // the equivalent swapped out RVH in the target process. If we need 2874 // the equivalent swapped out RVH in the target process. If we need
2865 // to create a swapped out RVH for the source tab, we create its opener 2875 // to create a swapped out RVH for the source tab, we create its opener
2866 // chain as well, since those will also be accessible to the target page. 2876 // chain as well, since those will also be accessible to the target page.
2867 if (new_params.source_routing_id != MSG_ROUTING_NONE) { 2877 if (new_params.source_routing_id != MSG_ROUTING_NONE) {
2868 // Try to look up the WebContents for the source page. 2878 // Try to look up the WebContents for the source page.
2869 WebContentsImpl* source_contents = NULL; 2879 WebContentsImpl* source_contents = NULL;
2870 RenderViewHostImpl* source_rvh = RenderViewHostImpl::FromID( 2880 RenderViewHostImpl* source_rvh = RenderViewHostImpl::FromID(
2871 rvh->GetProcess()->GetID(), params.source_routing_id); 2881 rvh->GetProcess()->GetID(), params.source_routing_id);
2872 if (source_rvh) { 2882 if (source_rvh) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
3100 } 3110 }
3101 3111
3102 int WebContentsImpl::CreateOpenerRenderViews(SiteInstance* instance) { 3112 int WebContentsImpl::CreateOpenerRenderViews(SiteInstance* instance) {
3103 int opener_route_id = MSG_ROUTING_NONE; 3113 int opener_route_id = MSG_ROUTING_NONE;
3104 3114
3105 // If this tab has an opener, ensure it has a RenderView in the given 3115 // If this tab has an opener, ensure it has a RenderView in the given
3106 // SiteInstance as well. 3116 // SiteInstance as well.
3107 if (opener_) 3117 if (opener_)
3108 opener_route_id = opener_->CreateOpenerRenderViews(instance); 3118 opener_route_id = opener_->CreateOpenerRenderViews(instance);
3109 3119
3120 // If any of the renderers for this WebContents has the same SiteInstance,
3121 // use it.
3122 if (render_manager_.current_host()->GetSiteInstance() == instance)
3123 return render_manager_.current_host()->GetRoutingID();
3124
3125 RenderViewHostImpl* rvh = render_manager_.GetSwappedOutRenderViewHost(
3126 instance);
3127 if (rvh)
3128 return rvh->GetRoutingID();
3129
3110 // Create a swapped out RenderView in the given SiteInstance if none exists, 3130 // Create a swapped out RenderView in the given SiteInstance if none exists,
3111 // setting its opener to the given route_id. Return the new view's route_id. 3131 // setting its opener to the given route_id. Return the new view's route_id.
3112 return render_manager_.CreateRenderView(instance, opener_route_id, true); 3132 return render_manager_.CreateRenderView(instance, opener_route_id, true);
3113 } 3133 }
3114 3134
3115 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { 3135 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() {
3116 return GetController(); 3136 return GetController();
3117 } 3137 }
3118 3138
3119 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { 3139 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
3231 old_browser_plugin_host()->embedder_render_process_host(); 3251 old_browser_plugin_host()->embedder_render_process_host();
3232 *embedder_container_id = old_browser_plugin_host()->instance_id(); 3252 *embedder_container_id = old_browser_plugin_host()->instance_id();
3233 int embedder_process_id = 3253 int embedder_process_id =
3234 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; 3254 embedder_render_process_host ? embedder_render_process_host->GetID() : -1;
3235 if (embedder_process_id != -1) { 3255 if (embedder_process_id != -1) {
3236 *embedder_channel_name = 3256 *embedder_channel_name =
3237 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), 3257 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(),
3238 embedder_process_id); 3258 embedder_process_id);
3239 } 3259 }
3240 } 3260 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698