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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 3841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3852 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here, | 3852 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here, |
3853 // as it is deprecated and can be out of sync with GetRenderViewHost(). | 3853 // as it is deprecated and can be out of sync with GetRenderViewHost(). |
3854 GURL url = controller_.GetActiveEntry() | 3854 GURL url = controller_.GetActiveEntry() |
3855 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); | 3855 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); |
3856 | 3856 |
3857 return GetRenderManager()->current_host()->GetWebkitPrefs(url); | 3857 return GetRenderManager()->current_host()->GetWebkitPrefs(url); |
3858 } | 3858 } |
3859 | 3859 |
3860 int WebContentsImpl::CreateSwappedOutRenderView( | 3860 int WebContentsImpl::CreateSwappedOutRenderView( |
3861 SiteInstance* instance) { | 3861 SiteInstance* instance) { |
3862 return GetRenderManager()->CreateRenderFrame( | 3862 return GetRenderManager()->CreateRenderFrame(instance, MSG_ROUTING_NONE, |
3863 instance, MSG_ROUTING_NONE, true, true, true); | 3863 true, true); |
3864 } | 3864 } |
3865 | 3865 |
3866 void WebContentsImpl::OnUserGesture() { | 3866 void WebContentsImpl::OnUserGesture() { |
3867 // Notify observers. | 3867 // Notify observers. |
3868 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); | 3868 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); |
3869 | 3869 |
3870 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 3870 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
3871 if (rdh) // NULL in unittests. | 3871 if (rdh) // NULL in unittests. |
3872 rdh->OnUserGesture(this); | 3872 rdh->OnUserGesture(this); |
3873 } | 3873 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4023 instance) | 4023 instance) |
4024 return GetRenderManager()->pending_render_view_host()->GetRoutingID(); | 4024 return GetRenderManager()->pending_render_view_host()->GetRoutingID(); |
4025 | 4025 |
4026 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost( | 4026 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost( |
4027 instance); | 4027 instance); |
4028 if (rvh) | 4028 if (rvh) |
4029 return rvh->GetRoutingID(); | 4029 return rvh->GetRoutingID(); |
4030 | 4030 |
4031 // Create a swapped out RenderView in the given SiteInstance if none exists, | 4031 // Create a swapped out RenderView in the given SiteInstance if none exists, |
4032 // setting its opener to the given route_id. Return the new view's route_id. | 4032 // setting its opener to the given route_id. Return the new view's route_id. |
4033 return GetRenderManager()->CreateRenderFrame( | 4033 return GetRenderManager()->CreateRenderFrame(instance, opener_route_id, |
4034 instance, opener_route_id, true, true, true); | 4034 true, true); |
4035 } | 4035 } |
4036 | 4036 |
4037 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 4037 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
4038 return GetController(); | 4038 return GetController(); |
4039 } | 4039 } |
4040 | 4040 |
4041 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { | 4041 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { |
4042 return static_cast<WebUIImpl*>(CreateWebUI(url)); | 4042 return static_cast<WebUIImpl*>(CreateWebUI(url)); |
4043 } | 4043 } |
4044 | 4044 |
4045 NavigationEntry* | 4045 NavigationEntry* |
4046 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { | 4046 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { |
4047 return controller_.GetLastCommittedEntry(); | 4047 return controller_.GetLastCommittedEntry(); |
4048 } | 4048 } |
4049 | 4049 |
4050 bool WebContentsImpl::CreateRenderViewForRenderManager( | 4050 bool WebContentsImpl::CreateRenderViewForRenderManager( |
4051 RenderViewHost* render_view_host, | 4051 RenderViewHost* render_view_host, |
4052 int opener_route_id, | 4052 int opener_route_id, |
4053 int proxy_routing_id, | 4053 int proxy_routing_id, |
4054 bool for_main_frame_navigation) { | 4054 bool for_main_frame) { |
4055 TRACE_EVENT0("browser", "WebContentsImpl::CreateRenderViewForRenderManager"); | 4055 TRACE_EVENT0("browser", "WebContentsImpl::CreateRenderViewForRenderManager"); |
4056 // Can be NULL during tests. | 4056 // Can be NULL during tests. |
4057 RenderWidgetHostViewBase* rwh_view; | 4057 RenderWidgetHostViewBase* rwh_view; |
4058 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary | 4058 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary |
4059 // until RenderWidgetHost is attached to RenderFrameHost. We need to special | 4059 // until RenderWidgetHost is attached to RenderFrameHost. We need to special |
4060 // case this because RWH is still a base class of RenderViewHost, and child | 4060 // case this because RWH is still a base class of RenderViewHost, and child |
4061 // frame RWHVs are unique in that they do not have their own WebContents. | 4061 // frame RWHVs are unique in that they do not have their own WebContents. |
4062 if (!for_main_frame_navigation) { | 4062 if (!for_main_frame) { |
4063 RenderWidgetHostViewChildFrame* rwh_view_child = | 4063 RenderWidgetHostViewChildFrame* rwh_view_child = |
4064 new RenderWidgetHostViewChildFrame(render_view_host); | 4064 new RenderWidgetHostViewChildFrame(render_view_host); |
4065 rwh_view = rwh_view_child; | 4065 rwh_view = rwh_view_child; |
4066 } else { | 4066 } else { |
4067 rwh_view = view_->CreateViewForWidget(render_view_host); | 4067 rwh_view = view_->CreateViewForWidget(render_view_host); |
4068 } | 4068 } |
4069 | 4069 |
4070 // Now that the RenderView has been created, we need to tell it its size. | 4070 // Now that the RenderView has been created, we need to tell it its size. |
4071 if (rwh_view) | 4071 if (rwh_view) |
4072 rwh_view->SetSize(GetSizeForNewRenderView()); | 4072 rwh_view->SetSize(GetSizeForNewRenderView()); |
(...skipping 16 matching lines...) Expand all Loading... |
4089 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on | 4089 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on |
4090 // linux. See crbug.com/83941. | 4090 // linux. See crbug.com/83941. |
4091 if (rwh_view) { | 4091 if (rwh_view) { |
4092 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) | 4092 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) |
4093 render_widget_host->WasResized(); | 4093 render_widget_host->WasResized(); |
4094 } | 4094 } |
4095 #endif | 4095 #endif |
4096 | 4096 |
4097 return true; | 4097 return true; |
4098 } | 4098 } |
4099 | |
4100 bool WebContentsImpl::CreateRenderFrameForRenderManager( | |
4101 RenderFrameHost* render_frame_host, | |
4102 int parent_routing_id) { | |
4103 TRACE_EVENT0("browser", "WebContentsImpl::CreateRenderFrameForRenderManager"); | |
4104 | |
4105 RenderFrameHostImpl* rfh = | |
4106 static_cast<RenderFrameHostImpl*>(render_frame_host); | |
4107 if (!rfh->CreateRenderFrame(parent_routing_id)) | |
4108 return false; | |
4109 | |
4110 // TODO(nasko): When RenderWidgetHost is owned by RenderFrameHost, the passed | |
4111 // RenderFrameHost will have to be associated with the appropriate | |
4112 // RenderWidgetHostView or a new one should be created here. | |
4113 | |
4114 return true; | |
4115 } | |
4116 | 4099 |
4117 #if defined(OS_ANDROID) | 4100 #if defined(OS_ANDROID) |
4118 | 4101 |
4119 base::android::ScopedJavaLocalRef<jobject> | 4102 base::android::ScopedJavaLocalRef<jobject> |
4120 WebContentsImpl::GetJavaWebContents() { | 4103 WebContentsImpl::GetJavaWebContents() { |
4121 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 4104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
4122 | 4105 |
4123 WebContentsAndroid* web_contents_android = | 4106 WebContentsAndroid* web_contents_android = |
4124 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); | 4107 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); |
4125 if (!web_contents_android) { | 4108 if (!web_contents_android) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4262 if (new_size != old_size) | 4245 if (new_size != old_size) |
4263 delegate_->UpdatePreferredSize(this, new_size); | 4246 delegate_->UpdatePreferredSize(this, new_size); |
4264 } | 4247 } |
4265 | 4248 |
4266 void WebContentsImpl::ResumeResponseDeferredAtStart() { | 4249 void WebContentsImpl::ResumeResponseDeferredAtStart() { |
4267 FrameTreeNode* node = frame_tree_.root(); | 4250 FrameTreeNode* node = frame_tree_.root(); |
4268 node->render_manager()->ResumeResponseDeferredAtStart(); | 4251 node->render_manager()->ResumeResponseDeferredAtStart(); |
4269 } | 4252 } |
4270 | 4253 |
4271 } // namespace content | 4254 } // namespace content |
OLD | NEW |