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

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: rename changes Created 5 years, 7 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
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 : parent_web_contents_(nullptr) {
292 }
293
294 WebContentsImpl::WebContentsTreeNode::~WebContentsTreeNode() {
295 // TODO(lazyboy): Enforce that a child WebContentsTreeNode gets deleted
296 // before its parent. Otherwise the child could have a stale pointer to its
297 // parent WebContents, risking a use-after-free.
Charlie Reis 2015/05/22 23:44:31 This must be fixed before committing.
298 }
299
289 // WebContentsImpl ------------------------------------------------------------- 300 // WebContentsImpl -------------------------------------------------------------
290 301
291 WebContentsImpl::WebContentsImpl(BrowserContext* browser_context, 302 WebContentsImpl::WebContentsImpl(BrowserContext* browser_context,
292 WebContentsImpl* opener) 303 WebContentsImpl* opener)
293 : delegate_(NULL), 304 : delegate_(NULL),
294 controller_(this, browser_context), 305 controller_(this, browser_context),
295 render_view_host_delegate_view_(NULL), 306 render_view_host_delegate_view_(NULL),
296 opener_(opener), 307 opener_(opener),
297 created_with_opener_(!!opener), 308 created_with_opener_(!!opener),
298 #if defined(OS_WIN) 309 #if defined(OS_WIN)
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 bool WebContentsImpl::NeedToFireBeforeUnload() { 1136 bool WebContentsImpl::NeedToFireBeforeUnload() {
1126 // TODO(creis): Should we fire even for interstitial pages? 1137 // TODO(creis): Should we fire even for interstitial pages?
1127 return WillNotifyDisconnection() && !ShowingInterstitialPage() && 1138 return WillNotifyDisconnection() && !ShowingInterstitialPage() &&
1128 !GetRenderViewHost()->SuddenTerminationAllowed(); 1139 !GetRenderViewHost()->SuddenTerminationAllowed();
1129 } 1140 }
1130 1141
1131 void WebContentsImpl::DispatchBeforeUnload(bool for_cross_site_transition) { 1142 void WebContentsImpl::DispatchBeforeUnload(bool for_cross_site_transition) {
1132 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition); 1143 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition);
1133 } 1144 }
1134 1145
1146 void WebContentsImpl::AttachToOuterWebContentsFrame(
1147 WebContents* outer_web_contents,
1148 RenderFrameHost* outer_contents_frame) {
1149 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
1150 switches::kSitePerProcess));
1151 // Create a link to our parent WebContents.
Charlie Reis 2015/05/22 23:44:31 outer
lazyboy 2015/05/26 16:32:55 Done.
1152 node_.set_parent_web_contents(
1153 static_cast<WebContentsImpl*>(outer_web_contents));
1154
1155 DCHECK(outer_contents_frame);
1156
1157 // Create a swapped out RVH and a proxy in our render manager, pointing
1158 // to the SiteInstance of the outer WebContents. The swapped out RVH will be
1159 // used to send postMessage to the inner WebContents.
1160 int proxy_to_outer_web_contents_routing_id =
1161 GetRenderManager()->CreateOuterContentsProxy(
1162 outer_contents_frame->GetSiteInstance());
1163
1164 // Swap the outer WebContents' initial frame for the inner WebContents with
Charlie Reis 2015/05/22 23:44:31 WebContents's
lazyboy 2015/05/26 16:32:55 Done.
1165 // the proxy we've created above.
1166 // The proxy has a CPFC and it uses the swapped out RV as its RenderWidget,
1167 // which gives us input and rendering.
1168 static_cast<RenderFrameHostImpl*>(outer_contents_frame)
1169 ->frame_tree_node()
1170 ->render_manager()
1171 ->ReplaceWithInnerContentsProxy(proxy_to_outer_web_contents_routing_id);
1172
1173 GetRenderManager()->SetRWHViewForInnerContents(
1174 GetRenderManager()->GetRenderWidgetHostView());
1175 }
1176
1135 void WebContentsImpl::Stop() { 1177 void WebContentsImpl::Stop() {
1136 GetRenderManager()->Stop(); 1178 GetRenderManager()->Stop();
1137 FOR_EACH_OBSERVER(WebContentsObserver, observers_, NavigationStopped()); 1179 FOR_EACH_OBSERVER(WebContentsObserver, observers_, NavigationStopped());
1138 } 1180 }
1139 1181
1140 WebContents* WebContentsImpl::Clone() { 1182 WebContents* WebContentsImpl::Clone() {
1141 // We use our current SiteInstance since the cloned entry will use it anyway. 1183 // We use our current SiteInstance since the cloned entry will use it anyway.
1142 // We pass our own opener so that the cloned page can access it if it was 1184 // We pass our own opener so that the cloned page can access it if it was
1143 // before. 1185 // before.
1144 CreateParams create_params(GetBrowserContext(), GetSiteInstance()); 1186 CreateParams create_params(GetBrowserContext(), GetSiteInstance());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 (params.routing_id != MSG_ROUTING_NONE && 1239 (params.routing_id != MSG_ROUTING_NONE &&
1198 params.main_frame_routing_id != MSG_ROUTING_NONE)); 1240 params.main_frame_routing_id != MSG_ROUTING_NONE));
1199 GetRenderManager()->Init( 1241 GetRenderManager()->Init(
1200 params.browser_context, params.site_instance, params.routing_id, 1242 params.browser_context, params.site_instance, params.routing_id,
1201 params.main_frame_routing_id); 1243 params.main_frame_routing_id);
1202 frame_tree_.root()->SetFrameName(params.main_frame_name); 1244 frame_tree_.root()->SetFrameName(params.main_frame_name);
1203 1245
1204 WebContentsViewDelegate* delegate = 1246 WebContentsViewDelegate* delegate =
1205 GetContentClient()->browser()->GetWebContentsViewDelegate(this); 1247 GetContentClient()->browser()->GetWebContentsViewDelegate(this);
1206 1248
1207 if (browser_plugin_guest_) { 1249 if (browser_plugin_guest_ &&
1250 !base::CommandLine::ForCurrentProcess()->HasSwitch(
1251 switches::kSitePerProcess)) {
1208 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( 1252 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView(
1209 this, delegate, &render_view_host_delegate_view_)); 1253 this, delegate, &render_view_host_delegate_view_));
1210 1254
1211 WebContentsViewGuest* rv = new WebContentsViewGuest( 1255 WebContentsViewGuest* rv = new WebContentsViewGuest(
1212 this, browser_plugin_guest_.get(), platform_view.Pass(), 1256 this, browser_plugin_guest_.get(), platform_view.Pass(),
1213 render_view_host_delegate_view_); 1257 render_view_host_delegate_view_);
1214 render_view_host_delegate_view_ = rv; 1258 render_view_host_delegate_view_ = rv;
1215 view_.reset(rv); 1259 view_.reset(rv);
1216 } else { 1260 } else {
1217 // Regular WebContentsView. 1261 // Regular WebContentsView.
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 int route_id, 1550 int route_id,
1507 int main_frame_route_id, 1551 int main_frame_route_id,
1508 const ViewHostMsg_CreateWindow_Params& params, 1552 const ViewHostMsg_CreateWindow_Params& params,
1509 SessionStorageNamespace* session_storage_namespace) { 1553 SessionStorageNamespace* session_storage_namespace) {
1510 // We usually create the new window in the same BrowsingInstance (group of 1554 // We usually create the new window in the same BrowsingInstance (group of
1511 // script-related windows), by passing in the current SiteInstance. However, 1555 // script-related windows), by passing in the current SiteInstance. However,
1512 // if the opener is being suppressed (in a non-guest), we create a new 1556 // if the opener is being suppressed (in a non-guest), we create a new
1513 // SiteInstance in its own BrowsingInstance. 1557 // SiteInstance in its own BrowsingInstance.
1514 bool is_guest = BrowserPluginGuest::IsGuest(this); 1558 bool is_guest = BrowserPluginGuest::IsGuest(this);
1515 1559
1560 if (is_guest &&
1561 base::CommandLine::ForCurrentProcess()->HasSwitch(
1562 switches::kSitePerProcess)) {
1563 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview>
1564 // yet.
1565 NOTREACHED();
1566 }
1567
1516 // If the opener is to be suppressed, the new window can be in any process. 1568 // If the opener is to be suppressed, the new window can be in any process.
1517 // Since routing ids are process specific, we must not have one passed in 1569 // Since routing ids are process specific, we must not have one passed in
1518 // as argument here. 1570 // as argument here.
1519 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); 1571 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE);
1520 1572
1521 scoped_refptr<SiteInstance> site_instance = 1573 scoped_refptr<SiteInstance> site_instance =
1522 params.opener_suppressed && !is_guest ? 1574 params.opener_suppressed && !is_guest ?
1523 SiteInstance::CreateForURL(GetBrowserContext(), params.target_url) : 1575 SiteInstance::CreateForURL(GetBrowserContext(), params.target_url) :
1524 GetSiteInstance(); 1576 GetSiteInstance();
1525 1577
(...skipping 2607 matching lines...) Expand 10 before | Expand all | Expand 10 after
4133 int proxy_routing_id, 4185 int proxy_routing_id,
4134 bool for_main_frame_navigation) { 4186 bool for_main_frame_navigation) {
4135 TRACE_EVENT0("browser,navigation", 4187 TRACE_EVENT0("browser,navigation",
4136 "WebContentsImpl::CreateRenderViewForRenderManager"); 4188 "WebContentsImpl::CreateRenderViewForRenderManager");
4137 // Can be NULL during tests. 4189 // Can be NULL during tests.
4138 RenderWidgetHostViewBase* rwh_view; 4190 RenderWidgetHostViewBase* rwh_view;
4139 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary 4191 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary
4140 // until RenderWidgetHost is attached to RenderFrameHost. We need to special 4192 // until RenderWidgetHost is attached to RenderFrameHost. We need to special
4141 // case this because RWH is still a base class of RenderViewHost, and child 4193 // case this because RWH is still a base class of RenderViewHost, and child
4142 // frame RWHVs are unique in that they do not have their own WebContents. 4194 // frame RWHVs are unique in that they do not have their own WebContents.
4143 if (!for_main_frame_navigation) { 4195 bool is_guest_in_site_per_process =
4196 !!browser_plugin_guest_.get() &&
4197 base::CommandLine::ForCurrentProcess()->HasSwitch(
4198 switches::kSitePerProcess);
4199 if (!for_main_frame_navigation || is_guest_in_site_per_process) {
4144 RenderWidgetHostViewChildFrame* rwh_view_child = 4200 RenderWidgetHostViewChildFrame* rwh_view_child =
4145 new RenderWidgetHostViewChildFrame(render_view_host); 4201 new RenderWidgetHostViewChildFrame(render_view_host);
4146 rwh_view = rwh_view_child; 4202 rwh_view = rwh_view_child;
4147 } else { 4203 } else {
4148 rwh_view = view_->CreateViewForWidget(render_view_host, false); 4204 rwh_view = view_->CreateViewForWidget(render_view_host, false);
4149 } 4205 }
4150 4206
4151 // Now that the RenderView has been created, we need to tell it its size. 4207 // Now that the RenderView has been created, we need to tell it its size.
4152 if (rwh_view) 4208 if (rwh_view)
4153 rwh_view->SetSize(GetSizeForNewRenderView()); 4209 rwh_view->SetSize(GetSizeForNewRenderView());
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
4277 last_reported_encoding_ = encoding; 4333 last_reported_encoding_ = encoding;
4278 4334
4279 canonical_encoding_ = GetContentClient()->browser()-> 4335 canonical_encoding_ = GetContentClient()->browser()->
4280 GetCanonicalEncodingNameByAliasName(encoding); 4336 GetCanonicalEncodingNameByAliasName(encoding);
4281 } 4337 }
4282 4338
4283 bool WebContentsImpl::IsHidden() { 4339 bool WebContentsImpl::IsHidden() {
4284 return capturer_count_ == 0 && !should_normally_be_visible_; 4340 return capturer_count_ == 0 && !should_normally_be_visible_;
4285 } 4341 }
4286 4342
4343 int WebContentsImpl::GetOuterWebContentsFrameTreeNodeID() {
4344 if (node_.parent_web_contents()) {
4345 return node_.parent_web_contents()
4346 ->GetFrameTree()
4347 ->root()
4348 ->frame_tree_node_id();
4349 }
4350 return -1;
4351 }
4352
4287 RenderFrameHostManager* WebContentsImpl::GetRenderManager() const { 4353 RenderFrameHostManager* WebContentsImpl::GetRenderManager() const {
4288 return frame_tree_.root()->render_manager(); 4354 return frame_tree_.root()->render_manager();
4289 } 4355 }
4290 4356
4291 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { 4357 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const {
4292 return browser_plugin_guest_.get(); 4358 return browser_plugin_guest_.get();
4293 } 4359 }
4294 4360
4295 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) { 4361 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) {
4296 CHECK(!browser_plugin_guest_); 4362 CHECK(!browser_plugin_guest_);
4363 CHECK(guest);
4297 browser_plugin_guest_.reset(guest); 4364 browser_plugin_guest_.reset(guest);
4298 } 4365 }
4299 4366
4300 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const { 4367 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const {
4301 return browser_plugin_embedder_.get(); 4368 return browser_plugin_embedder_.get();
4302 } 4369 }
4303 4370
4304 void WebContentsImpl::CreateBrowserPluginEmbedderIfNecessary() { 4371 void WebContentsImpl::CreateBrowserPluginEmbedderIfNecessary() {
4305 if (browser_plugin_embedder_) 4372 if (browser_plugin_embedder_)
4306 return; 4373 return;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
4388 player_map->erase(it); 4455 player_map->erase(it);
4389 } 4456 }
4390 4457
4391 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4458 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4392 force_disable_overscroll_content_ = force_disable; 4459 force_disable_overscroll_content_ = force_disable;
4393 if (view_) 4460 if (view_)
4394 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4461 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4395 } 4462 }
4396 4463
4397 } // namespace content 4464 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698