| OLD | NEW |
| 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 2728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2739 | 2739 |
| 2740 // Update the URL display. | 2740 // Update the URL display. |
| 2741 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); | 2741 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); |
| 2742 } | 2742 } |
| 2743 | 2743 |
| 2744 void WebContentsImpl::DidChangeLoadProgress(double progress) { | 2744 void WebContentsImpl::DidChangeLoadProgress(double progress) { |
| 2745 if (delegate_) | 2745 if (delegate_) |
| 2746 delegate_->LoadProgressChanged(this, progress); | 2746 delegate_->LoadProgressChanged(this, progress); |
| 2747 } | 2747 } |
| 2748 | 2748 |
| 2749 void WebContentsImpl::DidUpdateFrameTree(RenderViewHost* rvh) { |
| 2750 render_manager_.DidUpdateFrameTree(rvh); |
| 2751 } |
| 2752 |
| 2749 void WebContentsImpl::DocumentAvailableInMainFrame( | 2753 void WebContentsImpl::DocumentAvailableInMainFrame( |
| 2750 RenderViewHost* render_view_host) { | 2754 RenderViewHost* render_view_host) { |
| 2751 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2755 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2752 DocumentAvailableInMainFrame()); | 2756 DocumentAvailableInMainFrame()); |
| 2753 } | 2757 } |
| 2754 | 2758 |
| 2755 void WebContentsImpl::DocumentOnLoadCompletedInMainFrame( | 2759 void WebContentsImpl::DocumentOnLoadCompletedInMainFrame( |
| 2756 RenderViewHost* render_view_host, | 2760 RenderViewHost* render_view_host, |
| 2757 int32 page_id) { | 2761 int32 page_id) { |
| 2758 content::NotificationService::current()->Notify( | 2762 content::NotificationService::current()->Notify( |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2833 void WebContentsImpl::RouteMessageEvent( | 2837 void WebContentsImpl::RouteMessageEvent( |
| 2834 RenderViewHost* rvh, | 2838 RenderViewHost* rvh, |
| 2835 const ViewMsg_PostMessage_Params& params) { | 2839 const ViewMsg_PostMessage_Params& params) { |
| 2836 // Only deliver the message to the active RenderViewHost if the request | 2840 // Only deliver the message to the active RenderViewHost if the request |
| 2837 // came from a RenderViewHost in the same BrowsingInstance. | 2841 // came from a RenderViewHost in the same BrowsingInstance. |
| 2838 if (!rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) | 2842 if (!rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) |
| 2839 return; | 2843 return; |
| 2840 | 2844 |
| 2841 ViewMsg_PostMessage_Params new_params(params); | 2845 ViewMsg_PostMessage_Params new_params(params); |
| 2842 | 2846 |
| 2847 // If the renderer has changed while the post message is being routed, |
| 2848 // drop the message, as it will not be delivered to the right target. |
| 2849 if (GetRenderViewHost()->GetProcess()->GetID() != params.target_process_id) |
| 2850 return; |
| 2851 DCHECK(params.target_frame_id != 0); |
| 2852 |
| 2843 // If there is a source_routing_id, translate it to the routing ID for | 2853 // If there is a source_routing_id, translate it to the routing ID for |
| 2844 // the equivalent swapped out RVH in the target process. If we need | 2854 // the equivalent swapped out RVH in the target process. If we need |
| 2845 // to create a swapped out RVH for the source tab, we create its opener | 2855 // to create a swapped out RVH for the source tab, we create its opener |
| 2846 // chain as well, since those will also be accessible to the target page. | 2856 // chain as well, since those will also be accessible to the target page. |
| 2847 if (new_params.source_routing_id != MSG_ROUTING_NONE) { | 2857 if (new_params.source_routing_id != MSG_ROUTING_NONE) { |
| 2848 // Try to look up the WebContents for the source page. | 2858 // Try to look up the WebContents for the source page. |
| 2849 WebContentsImpl* source_contents = NULL; | 2859 WebContentsImpl* source_contents = NULL; |
| 2850 RenderViewHostImpl* source_rvh = RenderViewHostImpl::FromID( | 2860 RenderViewHostImpl* source_rvh = RenderViewHostImpl::FromID( |
| 2851 rvh->GetProcess()->GetID(), params.source_routing_id); | 2861 rvh->GetProcess()->GetID(), params.source_routing_id); |
| 2852 if (source_rvh) { | 2862 if (source_rvh) { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3080 } | 3090 } |
| 3081 | 3091 |
| 3082 int WebContentsImpl::CreateOpenerRenderViews(SiteInstance* instance) { | 3092 int WebContentsImpl::CreateOpenerRenderViews(SiteInstance* instance) { |
| 3083 int opener_route_id = MSG_ROUTING_NONE; | 3093 int opener_route_id = MSG_ROUTING_NONE; |
| 3084 | 3094 |
| 3085 // If this tab has an opener, ensure it has a RenderView in the given | 3095 // If this tab has an opener, ensure it has a RenderView in the given |
| 3086 // SiteInstance as well. | 3096 // SiteInstance as well. |
| 3087 if (opener_) | 3097 if (opener_) |
| 3088 opener_route_id = opener_->CreateOpenerRenderViews(instance); | 3098 opener_route_id = opener_->CreateOpenerRenderViews(instance); |
| 3089 | 3099 |
| 3100 // If any of the renderers for this WebContents has the same SiteInstance, |
| 3101 // use it. |
| 3102 if (render_manager_.current_host()->GetSiteInstance() == instance) |
| 3103 return render_manager_.current_host()->GetRoutingID(); |
| 3104 |
| 3105 RenderViewHostImpl* rvh = render_manager_.GetSwappedOutRenderViewHost( |
| 3106 instance); |
| 3107 if (rvh) |
| 3108 return rvh->GetRoutingID(); |
| 3109 |
| 3090 // Create a swapped out RenderView in the given SiteInstance if none exists, | 3110 // Create a swapped out RenderView in the given SiteInstance if none exists, |
| 3091 // setting its opener to the given route_id. Return the new view's route_id. | 3111 // setting its opener to the given route_id. Return the new view's route_id. |
| 3092 return render_manager_.CreateRenderView(instance, opener_route_id, true); | 3112 return render_manager_.CreateRenderView(instance, opener_route_id, true); |
| 3093 } | 3113 } |
| 3094 | 3114 |
| 3095 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 3115 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
| 3096 return GetController(); | 3116 return GetController(); |
| 3097 } | 3117 } |
| 3098 | 3118 |
| 3099 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { | 3119 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3211 old_browser_plugin_host()->embedder_render_process_host(); | 3231 old_browser_plugin_host()->embedder_render_process_host(); |
| 3212 *embedder_container_id = old_browser_plugin_host()->instance_id(); | 3232 *embedder_container_id = old_browser_plugin_host()->instance_id(); |
| 3213 int embedder_process_id = | 3233 int embedder_process_id = |
| 3214 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3234 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
| 3215 if (embedder_process_id != -1) { | 3235 if (embedder_process_id != -1) { |
| 3216 *embedder_channel_name = | 3236 *embedder_channel_name = |
| 3217 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3237 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
| 3218 embedder_process_id); | 3238 embedder_process_id); |
| 3219 } | 3239 } |
| 3220 } | 3240 } |
| OLD | NEW |