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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 3939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3950 const base::string16& source_id) { | 3950 const base::string16& source_id) { |
3951 if (!delegate_) | 3951 if (!delegate_) |
3952 return false; | 3952 return false; |
3953 return delegate_->AddMessageToConsole(this, level, message, line_no, | 3953 return delegate_->AddMessageToConsole(this, level, message, line_no, |
3954 source_id); | 3954 source_id); |
3955 } | 3955 } |
3956 | 3956 |
3957 int WebContentsImpl::CreateSwappedOutRenderView( | 3957 int WebContentsImpl::CreateSwappedOutRenderView( |
3958 SiteInstance* instance) { | 3958 SiteInstance* instance) { |
3959 int render_view_routing_id = MSG_ROUTING_NONE; | 3959 int render_view_routing_id = MSG_ROUTING_NONE; |
3960 GetRenderManager()->CreateRenderFrame( | 3960 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
3961 instance, nullptr, MSG_ROUTING_NONE, | 3961 switches::kSitePerProcess)) { |
3962 CREATE_RF_SWAPPED_OUT | CREATE_RF_FOR_MAIN_FRAME_NAVIGATION | | 3962 GetRenderManager()->CreateRenderFrameProxy(instance); |
3963 CREATE_RF_HIDDEN, | 3963 } else { |
3964 &render_view_routing_id); | 3964 GetRenderManager()->CreateRenderFrame( |
| 3965 instance, nullptr, MSG_ROUTING_NONE, |
| 3966 CREATE_RF_SWAPPED_OUT | CREATE_RF_FOR_MAIN_FRAME_NAVIGATION | |
| 3967 CREATE_RF_HIDDEN, |
| 3968 &render_view_routing_id); |
| 3969 } |
3965 return render_view_routing_id; | 3970 return render_view_routing_id; |
3966 } | 3971 } |
3967 | 3972 |
3968 void WebContentsImpl::OnUserGesture() { | 3973 void WebContentsImpl::OnUserGesture() { |
3969 // Notify observers. | 3974 // Notify observers. |
3970 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); | 3975 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); |
3971 | 3976 |
3972 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 3977 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
3973 if (rdh) // NULL in unittests. | 3978 if (rdh) // NULL in unittests. |
3974 rdh->OnUserGesture(this); | 3979 rdh->OnUserGesture(this); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4145 return GetRenderManager()->pending_render_view_host()->GetRoutingID(); | 4150 return GetRenderManager()->pending_render_view_host()->GetRoutingID(); |
4146 | 4151 |
4147 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost( | 4152 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost( |
4148 instance); | 4153 instance); |
4149 if (rvh) | 4154 if (rvh) |
4150 return rvh->GetRoutingID(); | 4155 return rvh->GetRoutingID(); |
4151 | 4156 |
4152 // Create a swapped out RenderView in the given SiteInstance if none exists, | 4157 // Create a swapped out RenderView in the given SiteInstance if none exists, |
4153 // setting its opener to the given route_id. Return the new view's route_id. | 4158 // setting its opener to the given route_id. Return the new view's route_id. |
4154 int render_view_routing_id = MSG_ROUTING_NONE; | 4159 int render_view_routing_id = MSG_ROUTING_NONE; |
4155 GetRenderManager()->CreateRenderFrame(instance, nullptr, opener_route_id, | 4160 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
4156 CREATE_RF_FOR_MAIN_FRAME_NAVIGATION | | 4161 switches::kSitePerProcess)) { |
| 4162 GetRenderManager()->CreateRenderFrameProxy(instance); |
| 4163 render_view_routing_id = |
| 4164 frame_tree_.GetRenderViewHost(instance)->GetRoutingID(); |
| 4165 } else { |
| 4166 GetRenderManager()->CreateRenderFrame(instance, nullptr, opener_route_id, |
| 4167 CREATE_RF_FOR_MAIN_FRAME_NAVIGATION | |
4157 CREATE_RF_SWAPPED_OUT | | 4168 CREATE_RF_SWAPPED_OUT | |
4158 CREATE_RF_HIDDEN, | 4169 CREATE_RF_HIDDEN, |
4159 &render_view_routing_id); | 4170 &render_view_routing_id); |
| 4171 } |
4160 return render_view_routing_id; | 4172 return render_view_routing_id; |
4161 } | 4173 } |
4162 | 4174 |
4163 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 4175 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
4164 return GetController(); | 4176 return GetController(); |
4165 } | 4177 } |
4166 | 4178 |
4167 scoped_ptr<WebUIImpl> WebContentsImpl::CreateWebUIForRenderManager( | 4179 scoped_ptr<WebUIImpl> WebContentsImpl::CreateWebUIForRenderManager( |
4168 const GURL& url) { | 4180 const GURL& url) { |
4169 return scoped_ptr<WebUIImpl>(static_cast<WebUIImpl*>(CreateWebUI(url))); | 4181 return scoped_ptr<WebUIImpl>(static_cast<WebUIImpl*>(CreateWebUI(url))); |
4170 } | 4182 } |
4171 | 4183 |
4172 NavigationEntry* | 4184 NavigationEntry* |
4173 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { | 4185 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { |
4174 return controller_.GetLastCommittedEntry(); | 4186 return controller_.GetLastCommittedEntry(); |
4175 } | 4187 } |
4176 | 4188 |
4177 bool WebContentsImpl::CreateRenderViewForRenderManager( | 4189 bool WebContentsImpl::CreateRenderViewForRenderManager( |
4178 RenderViewHost* render_view_host, | 4190 RenderViewHost* render_view_host, |
4179 int opener_route_id, | 4191 int opener_route_id, |
4180 int proxy_routing_id, | 4192 int proxy_routing_id, |
| 4193 const FrameReplicationState& replicated_frame_state, |
4181 bool for_main_frame_navigation) { | 4194 bool for_main_frame_navigation) { |
4182 TRACE_EVENT0("browser,navigation", | 4195 TRACE_EVENT0("browser,navigation", |
4183 "WebContentsImpl::CreateRenderViewForRenderManager"); | 4196 "WebContentsImpl::CreateRenderViewForRenderManager"); |
4184 // Can be NULL during tests. | 4197 // Can be NULL during tests. |
4185 RenderWidgetHostViewBase* rwh_view; | 4198 RenderWidgetHostViewBase* rwh_view; |
4186 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary | 4199 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary |
4187 // until RenderWidgetHost is attached to RenderFrameHost. We need to special | 4200 // until RenderWidgetHost is attached to RenderFrameHost. We need to special |
4188 // case this because RWH is still a base class of RenderViewHost, and child | 4201 // case this because RWH is still a base class of RenderViewHost, and child |
4189 // frame RWHVs are unique in that they do not have their own WebContents. | 4202 // frame RWHVs are unique in that they do not have their own WebContents. |
4190 if (!for_main_frame_navigation) { | 4203 if (!for_main_frame_navigation) { |
(...skipping 11 matching lines...) Expand all Loading... |
4202 // Make sure we use the correct starting page_id in the new RenderView. | 4215 // Make sure we use the correct starting page_id in the new RenderView. |
4203 UpdateMaxPageIDIfNecessary(render_view_host); | 4216 UpdateMaxPageIDIfNecessary(render_view_host); |
4204 int32 max_page_id = | 4217 int32 max_page_id = |
4205 GetMaxPageIDForSiteInstance(render_view_host->GetSiteInstance()); | 4218 GetMaxPageIDForSiteInstance(render_view_host->GetSiteInstance()); |
4206 | 4219 |
4207 if (!static_cast<RenderViewHostImpl*>( | 4220 if (!static_cast<RenderViewHostImpl*>( |
4208 render_view_host)->CreateRenderView(base::string16(), | 4221 render_view_host)->CreateRenderView(base::string16(), |
4209 opener_route_id, | 4222 opener_route_id, |
4210 proxy_routing_id, | 4223 proxy_routing_id, |
4211 max_page_id, | 4224 max_page_id, |
| 4225 replicated_frame_state, |
4212 created_with_opener_)) { | 4226 created_with_opener_)) { |
4213 return false; | 4227 return false; |
4214 } | 4228 } |
4215 | 4229 |
4216 SetHistoryOffsetAndLengthForView(render_view_host, | 4230 SetHistoryOffsetAndLengthForView(render_view_host, |
4217 controller_.GetLastCommittedEntryIndex(), | 4231 controller_.GetLastCommittedEntryIndex(), |
4218 controller_.GetEntryCount()); | 4232 controller_.GetEntryCount()); |
4219 | 4233 |
4220 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 4234 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
4221 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on | 4235 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4262 WebContentsAndroid* web_contents_android = | 4276 WebContentsAndroid* web_contents_android = |
4263 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); | 4277 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); |
4264 if (!web_contents_android) { | 4278 if (!web_contents_android) { |
4265 web_contents_android = new WebContentsAndroid(this); | 4279 web_contents_android = new WebContentsAndroid(this); |
4266 SetUserData(kWebContentsAndroidKey, web_contents_android); | 4280 SetUserData(kWebContentsAndroidKey, web_contents_android); |
4267 } | 4281 } |
4268 return web_contents_android; | 4282 return web_contents_android; |
4269 } | 4283 } |
4270 | 4284 |
4271 bool WebContentsImpl::CreateRenderViewForInitialEmptyDocument() { | 4285 bool WebContentsImpl::CreateRenderViewForInitialEmptyDocument() { |
4272 return CreateRenderViewForRenderManager(GetRenderViewHost(), | 4286 return CreateRenderViewForRenderManager( |
4273 MSG_ROUTING_NONE, | 4287 GetRenderViewHost(), MSG_ROUTING_NONE, MSG_ROUTING_NONE, |
4274 MSG_ROUTING_NONE, | 4288 frame_tree_.root()->current_replication_state(), true); |
4275 true); | |
4276 } | 4289 } |
4277 | 4290 |
4278 #elif defined(OS_MACOSX) | 4291 #elif defined(OS_MACOSX) |
4279 | 4292 |
4280 void WebContentsImpl::SetAllowOtherViews(bool allow) { | 4293 void WebContentsImpl::SetAllowOtherViews(bool allow) { |
4281 view_->SetAllowOtherViews(allow); | 4294 view_->SetAllowOtherViews(allow); |
4282 } | 4295 } |
4283 | 4296 |
4284 bool WebContentsImpl::GetAllowOtherViews() { | 4297 bool WebContentsImpl::GetAllowOtherViews() { |
4285 return view_->GetAllowOtherViews(); | 4298 return view_->GetAllowOtherViews(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4435 player_map->erase(it); | 4448 player_map->erase(it); |
4436 } | 4449 } |
4437 | 4450 |
4438 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4451 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4439 force_disable_overscroll_content_ = force_disable; | 4452 force_disable_overscroll_content_ = force_disable; |
4440 if (view_) | 4453 if (view_) |
4441 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4454 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4442 } | 4455 } |
4443 | 4456 |
4444 } // namespace content | 4457 } // namespace content |
OLD | NEW |