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

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

Issue 972313002: Make <webview> use out-of-process iframe architecture. (Closed) Base URL: ssh://saopaulo.wat/mnt/dev/shared/src@testoopif2z-better-chrome
Patch Set: address comments from creis@ Created 5 years, 6 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
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 int identifier) 279 int identifier)
280 : render_process_id(render_process_id), 280 : render_process_id(render_process_id),
281 render_frame_id(render_frame_id), 281 render_frame_id(render_frame_id),
282 chooser(chooser), 282 chooser(chooser),
283 identifier(identifier) { 283 identifier(identifier) {
284 } 284 }
285 285
286 WebContentsImpl::ColorChooserInfo::~ColorChooserInfo() { 286 WebContentsImpl::ColorChooserInfo::~ColorChooserInfo() {
287 } 287 }
288 288
289 // WebContentsImpl::WebContentsTreeNode ----------------------------------------
290 WebContentsImpl::WebContentsTreeNode::WebContentsTreeNode()
291 : outer_web_contents_(nullptr) {
292 }
293
294 WebContentsImpl::WebContentsTreeNode::~WebContentsTreeNode() {
295 // Remove child pointer from our parent.
296 if (outer_web_contents_) {
297 ChildrenSet& child_ptrs_in_parent =
298 outer_web_contents_->node_->inner_web_contents_tree_nodes_;
299 ChildrenSet::iterator iter = child_ptrs_in_parent.find(this);
300 DCHECK(iter != child_ptrs_in_parent.end());
301 child_ptrs_in_parent.erase(this);
302 }
303
304 // Remove parent pointers from our children.
305 for (WebContentsTreeNode* child : inner_web_contents_tree_nodes_)
Charlie Reis 2015/06/02 23:55:43 Please add a TODO to delete the child WCs if you d
lazyboy 2015/06/03 22:32:27 Done.
306 child->outer_web_contents_ = nullptr;
307 }
308
309 void WebContentsImpl::WebContentsTreeNode::SetOuterWebContents(
310 WebContentsImpl* outer_web_contents) {
311 outer_web_contents_ = outer_web_contents;
312
313 if (!outer_web_contents_->node_)
314 outer_web_contents_->node_.reset(new WebContentsTreeNode());
315
316 outer_web_contents_->node_->inner_web_contents_tree_nodes_.insert(this);
317 }
318
289 // WebContentsImpl ------------------------------------------------------------- 319 // WebContentsImpl -------------------------------------------------------------
290 320
291 WebContentsImpl::WebContentsImpl(BrowserContext* browser_context, 321 WebContentsImpl::WebContentsImpl(BrowserContext* browser_context,
292 WebContentsImpl* opener) 322 WebContentsImpl* opener)
293 : delegate_(NULL), 323 : delegate_(NULL),
294 controller_(this, browser_context), 324 controller_(this, browser_context),
295 render_view_host_delegate_view_(NULL), 325 render_view_host_delegate_view_(NULL),
296 opener_(opener), 326 opener_(opener),
297 created_with_opener_(!!opener), 327 created_with_opener_(!!opener),
298 #if defined(OS_WIN) 328 #if defined(OS_WIN)
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 bool WebContentsImpl::NeedToFireBeforeUnload() { 1181 bool WebContentsImpl::NeedToFireBeforeUnload() {
1152 // TODO(creis): Should we fire even for interstitial pages? 1182 // TODO(creis): Should we fire even for interstitial pages?
1153 return WillNotifyDisconnection() && !ShowingInterstitialPage() && 1183 return WillNotifyDisconnection() && !ShowingInterstitialPage() &&
1154 !GetRenderViewHost()->SuddenTerminationAllowed(); 1184 !GetRenderViewHost()->SuddenTerminationAllowed();
1155 } 1185 }
1156 1186
1157 void WebContentsImpl::DispatchBeforeUnload(bool for_cross_site_transition) { 1187 void WebContentsImpl::DispatchBeforeUnload(bool for_cross_site_transition) {
1158 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition); 1188 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition);
1159 } 1189 }
1160 1190
1191 void WebContentsImpl::AttachToOuterWebContentsFrame(
1192 WebContents* outer_web_contents,
1193 RenderFrameHost* outer_contents_frame) {
1194 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
1195 switches::kSitePerProcess));
1196 // Create a link to our outer WebContents.
1197 node_.reset(new WebContentsTreeNode());
1198 node_->SetOuterWebContents(static_cast<WebContentsImpl*>(outer_web_contents));
1199
1200 DCHECK(outer_contents_frame);
1201
1202 // Create a swapped out RVH and a proxy in our render manager, pointing
1203 // to the SiteInstance of the outer WebContents. The swapped out RVH will be
1204 // used to send postMessage to the inner WebContents.
1205 // TODO(lazyboy): Use RenderFrameHostManager::CreateRenderFrameProxy() once
1206 // we can create a proxy without swapped out RF.
1207 int proxy_to_outer_web_contents_routing_id =
1208 GetRenderManager()->CreateOuterDelegateProxy(
1209 outer_contents_frame->GetSiteInstance());
1210
1211 // Swap the outer WebContents's initial frame for the inner WebContents with
1212 // the proxy we've created above.
1213 // The proxy has a CPFC and it uses the swapped out RV as its RenderWidget,
1214 // which gives us input and rendering.
1215 static_cast<RenderFrameHostImpl*>(outer_contents_frame)
1216 ->frame_tree_node()
1217 ->render_manager()
1218 ->SwapFrameWithProxy(proxy_to_outer_web_contents_routing_id);
1219
1220 GetRenderManager()->SetRWHViewForInnerContents(
1221 GetRenderManager()->GetRenderWidgetHostView());
1222 }
1223
1161 void WebContentsImpl::Stop() { 1224 void WebContentsImpl::Stop() {
1162 GetRenderManager()->Stop(); 1225 GetRenderManager()->Stop();
1163 FOR_EACH_OBSERVER(WebContentsObserver, observers_, NavigationStopped()); 1226 FOR_EACH_OBSERVER(WebContentsObserver, observers_, NavigationStopped());
1164 } 1227 }
1165 1228
1166 WebContents* WebContentsImpl::Clone() { 1229 WebContents* WebContentsImpl::Clone() {
1167 // We use our current SiteInstance since the cloned entry will use it anyway. 1230 // We use our current SiteInstance since the cloned entry will use it anyway.
1168 // We pass our own opener so that the cloned page can access it if it was 1231 // We pass our own opener so that the cloned page can access it if it was
1169 // before. 1232 // before.
1170 CreateParams create_params(GetBrowserContext(), GetSiteInstance()); 1233 CreateParams create_params(GetBrowserContext(), GetSiteInstance());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 (params.routing_id != MSG_ROUTING_NONE && 1286 (params.routing_id != MSG_ROUTING_NONE &&
1224 params.main_frame_routing_id != MSG_ROUTING_NONE)); 1287 params.main_frame_routing_id != MSG_ROUTING_NONE));
1225 GetRenderManager()->Init( 1288 GetRenderManager()->Init(
1226 params.browser_context, params.site_instance, params.routing_id, 1289 params.browser_context, params.site_instance, params.routing_id,
1227 params.main_frame_routing_id); 1290 params.main_frame_routing_id);
1228 frame_tree_.root()->SetFrameName(params.main_frame_name); 1291 frame_tree_.root()->SetFrameName(params.main_frame_name);
1229 1292
1230 WebContentsViewDelegate* delegate = 1293 WebContentsViewDelegate* delegate =
1231 GetContentClient()->browser()->GetWebContentsViewDelegate(this); 1294 GetContentClient()->browser()->GetWebContentsViewDelegate(this);
1232 1295
1233 if (browser_plugin_guest_) { 1296 if (browser_plugin_guest_ &&
1297 !base::CommandLine::ForCurrentProcess()->HasSwitch(
1298 switches::kSitePerProcess)) {
1234 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( 1299 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView(
1235 this, delegate, &render_view_host_delegate_view_)); 1300 this, delegate, &render_view_host_delegate_view_));
1236 1301
1237 WebContentsViewGuest* rv = new WebContentsViewGuest( 1302 WebContentsViewGuest* rv = new WebContentsViewGuest(
1238 this, browser_plugin_guest_.get(), platform_view.Pass(), 1303 this, browser_plugin_guest_.get(), platform_view.Pass(),
1239 render_view_host_delegate_view_); 1304 render_view_host_delegate_view_);
1240 render_view_host_delegate_view_ = rv; 1305 render_view_host_delegate_view_ = rv;
1241 view_.reset(rv); 1306 view_.reset(rv);
1242 } else { 1307 } else {
1243 // Regular WebContentsView. 1308 // Regular WebContentsView.
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 int route_id, 1597 int route_id,
1533 int main_frame_route_id, 1598 int main_frame_route_id,
1534 const ViewHostMsg_CreateWindow_Params& params, 1599 const ViewHostMsg_CreateWindow_Params& params,
1535 SessionStorageNamespace* session_storage_namespace) { 1600 SessionStorageNamespace* session_storage_namespace) {
1536 // We usually create the new window in the same BrowsingInstance (group of 1601 // We usually create the new window in the same BrowsingInstance (group of
1537 // script-related windows), by passing in the current SiteInstance. However, 1602 // script-related windows), by passing in the current SiteInstance. However,
1538 // if the opener is being suppressed (in a non-guest), we create a new 1603 // if the opener is being suppressed (in a non-guest), we create a new
1539 // SiteInstance in its own BrowsingInstance. 1604 // SiteInstance in its own BrowsingInstance.
1540 bool is_guest = BrowserPluginGuest::IsGuest(this); 1605 bool is_guest = BrowserPluginGuest::IsGuest(this);
1541 1606
1607 if (is_guest &&
1608 base::CommandLine::ForCurrentProcess()->HasSwitch(
1609 switches::kSitePerProcess)) {
1610 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview>
1611 // yet.
1612 NOTREACHED();
1613 }
1614
1542 // If the opener is to be suppressed, the new window can be in any process. 1615 // If the opener is to be suppressed, the new window can be in any process.
1543 // Since routing ids are process specific, we must not have one passed in 1616 // Since routing ids are process specific, we must not have one passed in
1544 // as argument here. 1617 // as argument here.
1545 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); 1618 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE);
1546 1619
1547 scoped_refptr<SiteInstance> site_instance = 1620 scoped_refptr<SiteInstance> site_instance =
1548 params.opener_suppressed && !is_guest ? 1621 params.opener_suppressed && !is_guest ?
1549 SiteInstance::CreateForURL(GetBrowserContext(), params.target_url) : 1622 SiteInstance::CreateForURL(GetBrowserContext(), params.target_url) :
1550 GetSiteInstance(); 1623 GetSiteInstance();
1551 1624
(...skipping 2628 matching lines...) Expand 10 before | Expand all | Expand 10 after
4180 int proxy_routing_id, 4253 int proxy_routing_id,
4181 bool for_main_frame_navigation) { 4254 bool for_main_frame_navigation) {
4182 TRACE_EVENT0("browser,navigation", 4255 TRACE_EVENT0("browser,navigation",
4183 "WebContentsImpl::CreateRenderViewForRenderManager"); 4256 "WebContentsImpl::CreateRenderViewForRenderManager");
4184 // Can be NULL during tests. 4257 // Can be NULL during tests.
4185 RenderWidgetHostViewBase* rwh_view; 4258 RenderWidgetHostViewBase* rwh_view;
4186 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary 4259 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary
4187 // until RenderWidgetHost is attached to RenderFrameHost. We need to special 4260 // until RenderWidgetHost is attached to RenderFrameHost. We need to special
4188 // case this because RWH is still a base class of RenderViewHost, and child 4261 // 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. 4262 // frame RWHVs are unique in that they do not have their own WebContents.
4190 if (!for_main_frame_navigation) { 4263 bool is_guest_in_site_per_process =
4264 !!browser_plugin_guest_.get() &&
4265 base::CommandLine::ForCurrentProcess()->HasSwitch(
4266 switches::kSitePerProcess);
4267 if (!for_main_frame_navigation || is_guest_in_site_per_process) {
4191 RenderWidgetHostViewChildFrame* rwh_view_child = 4268 RenderWidgetHostViewChildFrame* rwh_view_child =
4192 new RenderWidgetHostViewChildFrame(render_view_host); 4269 new RenderWidgetHostViewChildFrame(render_view_host);
4193 rwh_view = rwh_view_child; 4270 rwh_view = rwh_view_child;
4194 } else { 4271 } else {
4195 rwh_view = view_->CreateViewForWidget(render_view_host, false); 4272 rwh_view = view_->CreateViewForWidget(render_view_host, false);
4196 } 4273 }
4197 4274
4198 // Now that the RenderView has been created, we need to tell it its size. 4275 // Now that the RenderView has been created, we need to tell it its size.
4199 if (rwh_view) 4276 if (rwh_view)
4200 rwh_view->SetSize(GetSizeForNewRenderView()); 4277 rwh_view->SetSize(GetSizeForNewRenderView());
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
4324 last_reported_encoding_ = encoding; 4401 last_reported_encoding_ = encoding;
4325 4402
4326 canonical_encoding_ = GetContentClient()->browser()-> 4403 canonical_encoding_ = GetContentClient()->browser()->
4327 GetCanonicalEncodingNameByAliasName(encoding); 4404 GetCanonicalEncodingNameByAliasName(encoding);
4328 } 4405 }
4329 4406
4330 bool WebContentsImpl::IsHidden() { 4407 bool WebContentsImpl::IsHidden() {
4331 return capturer_count_ == 0 && !should_normally_be_visible_; 4408 return capturer_count_ == 0 && !should_normally_be_visible_;
4332 } 4409 }
4333 4410
4411 int WebContentsImpl::GetOuterDelegateFrameTreeNodeID() {
4412 if (node_ && node_->outer_web_contents()) {
4413 return node_->outer_web_contents()
4414 ->GetFrameTree()
4415 ->root()
4416 ->frame_tree_node_id();
4417 }
4418 return -1;
4419 }
4420
4334 RenderFrameHostManager* WebContentsImpl::GetRenderManager() const { 4421 RenderFrameHostManager* WebContentsImpl::GetRenderManager() const {
4335 return frame_tree_.root()->render_manager(); 4422 return frame_tree_.root()->render_manager();
4336 } 4423 }
4337 4424
4338 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { 4425 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const {
4339 return browser_plugin_guest_.get(); 4426 return browser_plugin_guest_.get();
4340 } 4427 }
4341 4428
4342 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) { 4429 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) {
4343 CHECK(!browser_plugin_guest_); 4430 CHECK(!browser_plugin_guest_);
4431 CHECK(guest);
4344 browser_plugin_guest_.reset(guest); 4432 browser_plugin_guest_.reset(guest);
4345 } 4433 }
4346 4434
4347 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const { 4435 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const {
4348 return browser_plugin_embedder_.get(); 4436 return browser_plugin_embedder_.get();
4349 } 4437 }
4350 4438
4351 void WebContentsImpl::CreateBrowserPluginEmbedderIfNecessary() { 4439 void WebContentsImpl::CreateBrowserPluginEmbedderIfNecessary() {
4352 if (browser_plugin_embedder_) 4440 if (browser_plugin_embedder_)
4353 return; 4441 return;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
4435 player_map->erase(it); 4523 player_map->erase(it);
4436 } 4524 }
4437 4525
4438 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4526 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4439 force_disable_overscroll_content_ = force_disable; 4527 force_disable_overscroll_content_ = force_disable;
4440 if (view_) 4528 if (view_)
4441 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4529 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4442 } 4530 }
4443 4531
4444 } // namespace content 4532 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698