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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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::WebContentsNode -------------------------------------------- | |
290 WebContentsImpl::WebContentsNode::WebContentsNode() | |
291 : parent_web_contents_(NULL) { | |
Charlie Reis
2015/04/30 23:06:46
nullptr
lazyboy
2015/05/05 07:28:14
Done.
| |
292 } | |
293 | |
294 WebContentsImpl::WebContentsNode::~WebContentsNode() { | |
Charlie Reis
2015/04/30 23:06:47
Is there any way for us to enforce that a child We
lazyboy
2015/05/05 07:28:14
Should we keep vector<WebContents*> children_ insi
| |
295 } | |
296 | |
289 // WebContentsImpl ------------------------------------------------------------- | 297 // WebContentsImpl ------------------------------------------------------------- |
290 | 298 |
291 WebContentsImpl::WebContentsImpl(BrowserContext* browser_context, | 299 WebContentsImpl::WebContentsImpl(BrowserContext* browser_context, |
292 WebContentsImpl* opener) | 300 WebContentsImpl* opener) |
293 : delegate_(NULL), | 301 : delegate_(NULL), |
294 controller_(this, browser_context), | 302 controller_(this, browser_context), |
295 render_view_host_delegate_view_(NULL), | 303 render_view_host_delegate_view_(NULL), |
296 opener_(opener), | 304 opener_(opener), |
297 created_with_opener_(!!opener), | 305 created_with_opener_(!!opener), |
298 #if defined(OS_WIN) | 306 #if defined(OS_WIN) |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 const GURL& WebContentsImpl::GetLastCommittedURL() const { | 620 const GURL& WebContentsImpl::GetLastCommittedURL() const { |
613 // We may not have a navigation entry yet. | 621 // We may not have a navigation entry yet. |
614 NavigationEntry* entry = controller_.GetLastCommittedEntry(); | 622 NavigationEntry* entry = controller_.GetLastCommittedEntry(); |
615 return entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); | 623 return entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); |
616 } | 624 } |
617 | 625 |
618 WebContentsDelegate* WebContentsImpl::GetDelegate() { | 626 WebContentsDelegate* WebContentsImpl::GetDelegate() { |
619 return delegate_; | 627 return delegate_; |
620 } | 628 } |
621 | 629 |
630 int WebContentsImpl::AttachLocalFrameToGuest(WebContents* embedder_web_contents, | |
631 int embedder_frame_process_id, | |
632 int embedder_frame_routing_id) { | |
633 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | |
Charlie Reis
2015/04/30 23:06:46
CHECK
lazyboy
2015/05/05 07:28:14
Done.
| |
634 switches::kSitePerProcess)); | |
635 // 1. Create a link to our parent WebContents. | |
636 node_.set_parent_web_contents( | |
637 static_cast<WebContentsImpl*>(embedder_web_contents)); | |
638 | |
639 RenderFrameHostImpl* embedder_frame = | |
640 RenderFrameHostImpl::FromID(embedder_frame_process_id, | |
641 embedder_frame_routing_id); | |
642 DCHECK(embedder_frame); | |
643 | |
644 // 2. Create a swapped out RVH and a proxy in our render manager, pointing | |
645 // to embedder site instance. The swapped out RVH will be used to send | |
Charlie Reis
2015/04/30 23:06:47
the embedder's SiteInstance.
lazyboy
2015/05/05 07:28:14
Done.
| |
646 // postMessage to guest. | |
Charlie Reis
2015/04/30 23:06:46
Alex pointed out that postMessage doesn't go throu
lazyboy
2015/05/05 07:28:14
I've changed the CL to use <iframe>.contentWindow
| |
647 int swapped_out_render_view_routing_id = MSG_ROUTING_NONE; | |
648 int proxy_to_embedder_routing_id = MSG_ROUTING_NONE; | |
649 GetRenderManager()->CreateEmbedderProxy( | |
650 embedder_frame->GetSiteInstance(), | |
651 &swapped_out_render_view_routing_id, | |
652 &proxy_to_embedder_routing_id); | |
653 | |
654 // 3. Swap the embedder's initial frame pointing to guest with the proxy | |
Charlie Reis
2015/04/30 23:06:47
initial frame for the guest
lazyboy
2015/05/05 07:28:14
Done.
| |
655 // we've created above. | |
656 // The proxy has a CPFC and it uses the swapped out RV as its RenderWidget, | |
657 // which gives us input and rendering. | |
658 embedder_frame->frame_tree_node()->render_manager() | |
659 ->ReplaceWithGuestProxy(proxy_to_embedder_routing_id); | |
660 | |
661 // The swapped out render view routing ID will be used to send | |
662 // postMessage. | |
663 return swapped_out_render_view_routing_id; | |
Charlie Reis
2015/04/30 23:06:46
Is this needed, given that postMessage should go t
lazyboy
2015/05/05 07:28:14
Not anymore. this function returns void now.
| |
664 } | |
665 | |
622 void WebContentsImpl::SetDelegate(WebContentsDelegate* delegate) { | 666 void WebContentsImpl::SetDelegate(WebContentsDelegate* delegate) { |
623 // TODO(cbentzel): remove this debugging code? | 667 // TODO(cbentzel): remove this debugging code? |
624 if (delegate == delegate_) | 668 if (delegate == delegate_) |
625 return; | 669 return; |
626 if (delegate_) | 670 if (delegate_) |
627 delegate_->Detach(this); | 671 delegate_->Detach(this); |
628 delegate_ = delegate; | 672 delegate_ = delegate; |
629 if (delegate_) { | 673 if (delegate_) { |
630 delegate_->Attach(this); | 674 delegate_->Attach(this); |
631 // Ensure the visible RVH reflects the new delegate's preferences. | 675 // Ensure the visible RVH reflects the new delegate's preferences. |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1197 params.main_frame_routing_id == MSG_ROUTING_NONE) || | 1241 params.main_frame_routing_id == MSG_ROUTING_NONE) || |
1198 (params.routing_id != MSG_ROUTING_NONE && | 1242 (params.routing_id != MSG_ROUTING_NONE && |
1199 params.main_frame_routing_id != MSG_ROUTING_NONE)); | 1243 params.main_frame_routing_id != MSG_ROUTING_NONE)); |
1200 GetRenderManager()->Init( | 1244 GetRenderManager()->Init( |
1201 params.browser_context, params.site_instance, params.routing_id, | 1245 params.browser_context, params.site_instance, params.routing_id, |
1202 params.main_frame_routing_id); | 1246 params.main_frame_routing_id); |
1203 | 1247 |
1204 WebContentsViewDelegate* delegate = | 1248 WebContentsViewDelegate* delegate = |
1205 GetContentClient()->browser()->GetWebContentsViewDelegate(this); | 1249 GetContentClient()->browser()->GetWebContentsViewDelegate(this); |
1206 | 1250 |
1207 if (browser_plugin_guest_) { | 1251 if (browser_plugin_guest_ && |
1252 !base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1253 switches::kSitePerProcess)) { | |
1208 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( | 1254 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( |
1209 this, delegate, &render_view_host_delegate_view_)); | 1255 this, delegate, &render_view_host_delegate_view_)); |
1210 | 1256 |
1211 WebContentsViewGuest* rv = new WebContentsViewGuest( | 1257 WebContentsViewGuest* rv = new WebContentsViewGuest( |
1212 this, browser_plugin_guest_.get(), platform_view.Pass(), | 1258 this, browser_plugin_guest_.get(), platform_view.Pass(), |
1213 render_view_host_delegate_view_); | 1259 render_view_host_delegate_view_); |
1214 render_view_host_delegate_view_ = rv; | 1260 render_view_host_delegate_view_ = rv; |
1215 view_.reset(rv); | 1261 view_.reset(rv); |
1216 } else { | 1262 } else { |
1217 // Regular WebContentsView. | 1263 // Regular WebContentsView. |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1500 if (delegate_) | 1546 if (delegate_) |
1501 delegate_->LostMouseLock(); | 1547 delegate_->LostMouseLock(); |
1502 } | 1548 } |
1503 | 1549 |
1504 void WebContentsImpl::CreateNewWindow( | 1550 void WebContentsImpl::CreateNewWindow( |
1505 int render_process_id, | 1551 int render_process_id, |
1506 int route_id, | 1552 int route_id, |
1507 int main_frame_route_id, | 1553 int main_frame_route_id, |
1508 const ViewHostMsg_CreateWindow_Params& params, | 1554 const ViewHostMsg_CreateWindow_Params& params, |
1509 SessionStorageNamespace* session_storage_namespace) { | 1555 SessionStorageNamespace* session_storage_namespace) { |
1556 // TODO(lazyboy): CreateNewWindow doesn't work for <webview> yet. | |
1557 DCHECK(0); | |
Charlie Reis
2015/04/30 23:06:47
This needs updating to work in non-site-per-proces
lazyboy
2015/05/05 07:28:14
This doesn't break until we use new window from <w
| |
1510 // We usually create the new window in the same BrowsingInstance (group of | 1558 // We usually create the new window in the same BrowsingInstance (group of |
1511 // script-related windows), by passing in the current SiteInstance. However, | 1559 // 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 | 1560 // if the opener is being suppressed (in a non-guest), we create a new |
1513 // SiteInstance in its own BrowsingInstance. | 1561 // SiteInstance in its own BrowsingInstance. |
1514 bool is_guest = BrowserPluginGuest::IsGuest(this); | 1562 bool is_guest = BrowserPluginGuest::IsGuest(this); |
1515 | 1563 |
1516 // If the opener is to be suppressed, the new window can be in any process. | 1564 // 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 | 1565 // Since routing ids are process specific, we must not have one passed in |
1518 // as argument here. | 1566 // as argument here. |
1519 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); | 1567 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1721 void WebContentsImpl::ShowCreatedWidget(int route_id, | 1769 void WebContentsImpl::ShowCreatedWidget(int route_id, |
1722 bool is_fullscreen, | 1770 bool is_fullscreen, |
1723 const gfx::Rect& initial_rect) { | 1771 const gfx::Rect& initial_rect) { |
1724 RenderWidgetHostViewBase* widget_host_view = | 1772 RenderWidgetHostViewBase* widget_host_view = |
1725 static_cast<RenderWidgetHostViewBase*>(GetCreatedWidget(route_id)); | 1773 static_cast<RenderWidgetHostViewBase*>(GetCreatedWidget(route_id)); |
1726 if (!widget_host_view) | 1774 if (!widget_host_view) |
1727 return; | 1775 return; |
1728 | 1776 |
1729 RenderWidgetHostView* view = NULL; | 1777 RenderWidgetHostView* view = NULL; |
1730 BrowserPluginGuest* guest = GetBrowserPluginGuest(); | 1778 BrowserPluginGuest* guest = GetBrowserPluginGuest(); |
1731 if (guest && guest->embedder_web_contents()) { | 1779 if (guest && guest->embedder_web_contents() && |
1780 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1781 switches::kSitePerProcess)) { | |
1732 view = guest->embedder_web_contents()->GetRenderWidgetHostView(); | 1782 view = guest->embedder_web_contents()->GetRenderWidgetHostView(); |
1733 } else { | 1783 } else { |
1734 view = GetRenderWidgetHostView(); | 1784 view = GetRenderWidgetHostView(); |
1735 } | 1785 } |
1736 | 1786 |
1737 if (is_fullscreen) { | 1787 if (is_fullscreen) { |
1738 DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_); | 1788 DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_); |
1739 view_->StoreFocus(); | 1789 view_->StoreFocus(); |
1740 fullscreen_widget_routing_id_ = route_id; | 1790 fullscreen_widget_routing_id_ = route_id; |
1741 if (delegate_ && delegate_->EmbedsFullscreenWidget()) { | 1791 if (delegate_ && delegate_->EmbedsFullscreenWidget()) { |
(...skipping 2422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4164 int proxy_routing_id, | 4214 int proxy_routing_id, |
4165 bool for_main_frame_navigation) { | 4215 bool for_main_frame_navigation) { |
4166 TRACE_EVENT0("browser,navigation", | 4216 TRACE_EVENT0("browser,navigation", |
4167 "WebContentsImpl::CreateRenderViewForRenderManager"); | 4217 "WebContentsImpl::CreateRenderViewForRenderManager"); |
4168 // Can be NULL during tests. | 4218 // Can be NULL during tests. |
4169 RenderWidgetHostViewBase* rwh_view; | 4219 RenderWidgetHostViewBase* rwh_view; |
4170 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary | 4220 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary |
4171 // until RenderWidgetHost is attached to RenderFrameHost. We need to special | 4221 // until RenderWidgetHost is attached to RenderFrameHost. We need to special |
4172 // case this because RWH is still a base class of RenderViewHost, and child | 4222 // case this because RWH is still a base class of RenderViewHost, and child |
4173 // frame RWHVs are unique in that they do not have their own WebContents. | 4223 // frame RWHVs are unique in that they do not have their own WebContents. |
4174 if (!for_main_frame_navigation) { | 4224 bool is_guest_in_site_per_process = !!browser_plugin_guest_.get() && |
4225 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
4226 switches::kSitePerProcess); | |
4227 if (!for_main_frame_navigation || is_guest_in_site_per_process) { | |
Charlie Reis
2015/04/30 23:06:46
Sounds like you might not need this if you don't p
lazyboy
2015/05/05 07:28:14
Not passing CREATE_RF_FOR_MAIN_FRAME_NAVIGATION st
| |
4175 RenderWidgetHostViewChildFrame* rwh_view_child = | 4228 RenderWidgetHostViewChildFrame* rwh_view_child = |
4176 new RenderWidgetHostViewChildFrame(render_view_host); | 4229 new RenderWidgetHostViewChildFrame(render_view_host); |
4177 rwh_view = rwh_view_child; | 4230 rwh_view = rwh_view_child; |
4231 if (is_guest_in_site_per_process) | |
4232 GetRenderManager()->UpdateGuestRWHView(rwh_view_child); | |
4178 } else { | 4233 } else { |
4179 rwh_view = view_->CreateViewForWidget(render_view_host, false); | 4234 rwh_view = view_->CreateViewForWidget(render_view_host, false); |
4180 } | 4235 } |
4181 | 4236 |
4182 // Now that the RenderView has been created, we need to tell it its size. | 4237 // Now that the RenderView has been created, we need to tell it its size. |
4183 if (rwh_view) | 4238 if (rwh_view) |
4184 rwh_view->SetSize(GetSizeForNewRenderView()); | 4239 rwh_view->SetSize(GetSizeForNewRenderView()); |
4185 | 4240 |
4186 // Make sure we use the correct starting page_id in the new RenderView. | 4241 // Make sure we use the correct starting page_id in the new RenderView. |
4187 UpdateMaxPageIDIfNecessary(render_view_host); | 4242 UpdateMaxPageIDIfNecessary(render_view_host); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4306 last_reported_encoding_ = encoding; | 4361 last_reported_encoding_ = encoding; |
4307 | 4362 |
4308 canonical_encoding_ = GetContentClient()->browser()-> | 4363 canonical_encoding_ = GetContentClient()->browser()-> |
4309 GetCanonicalEncodingNameByAliasName(encoding); | 4364 GetCanonicalEncodingNameByAliasName(encoding); |
4310 } | 4365 } |
4311 | 4366 |
4312 bool WebContentsImpl::IsHidden() { | 4367 bool WebContentsImpl::IsHidden() { |
4313 return capturer_count_ == 0 && !should_normally_be_visible_; | 4368 return capturer_count_ == 0 && !should_normally_be_visible_; |
4314 } | 4369 } |
4315 | 4370 |
4371 int64 WebContentsImpl::GetEmbedderFrameTreeNodeID() { | |
4372 if (node_.parent_web_contents()) { | |
4373 return node_.parent_web_contents()->GetFrameTree()->root() | |
4374 ->frame_tree_node_id(); | |
4375 } | |
4376 return -1; | |
4377 } | |
4378 | |
4316 RenderFrameHostManager* WebContentsImpl::GetRenderManager() const { | 4379 RenderFrameHostManager* WebContentsImpl::GetRenderManager() const { |
4317 return frame_tree_.root()->render_manager(); | 4380 return frame_tree_.root()->render_manager(); |
4318 } | 4381 } |
4319 | 4382 |
4320 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { | 4383 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { |
4321 return browser_plugin_guest_.get(); | 4384 return browser_plugin_guest_.get(); |
4322 } | 4385 } |
4323 | 4386 |
4324 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) { | 4387 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) { |
4325 CHECK(!browser_plugin_guest_); | 4388 CHECK(!browser_plugin_guest_); |
4389 CHECK(guest); | |
4326 browser_plugin_guest_.reset(guest); | 4390 browser_plugin_guest_.reset(guest); |
4327 } | 4391 } |
4328 | 4392 |
4329 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const { | 4393 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const { |
4330 return browser_plugin_embedder_.get(); | 4394 return browser_plugin_embedder_.get(); |
4331 } | 4395 } |
4332 | 4396 |
4333 void WebContentsImpl::CreateBrowserPluginEmbedderIfNecessary() { | 4397 void WebContentsImpl::CreateBrowserPluginEmbedderIfNecessary() { |
4334 if (browser_plugin_embedder_) | 4398 if (browser_plugin_embedder_) |
4335 return; | 4399 return; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4422 node->render_manager()->ResumeResponseDeferredAtStart(); | 4486 node->render_manager()->ResumeResponseDeferredAtStart(); |
4423 } | 4487 } |
4424 | 4488 |
4425 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4489 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4426 force_disable_overscroll_content_ = force_disable; | 4490 force_disable_overscroll_content_ = force_disable; |
4427 if (view_) | 4491 if (view_) |
4428 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4492 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4429 } | 4493 } |
4430 | 4494 |
4431 } // namespace content | 4495 } // namespace content |
OLD | NEW |