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

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: Revert unused changes from previous attempt + more cleanup. Created 5 years, 9 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 "content/browser/frame_host/render_frame_proxy_host.h"
Charlie Reis 2015/03/10 04:09:44 Not allowed by DEPS. web_contents/ can't depend o
lazyboy 2015/04/01 21:47:57 Not required anymore since I moved codes requiring
9 #include "base/command_line.h" 10 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
13 #include "base/process/process.h" 14 #include "base/process/process.h"
14 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 void WebContentsImpl::CopyMaxPageIDsFrom(WebContents* web_contents) { 891 void WebContentsImpl::CopyMaxPageIDsFrom(WebContents* web_contents) {
891 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents); 892 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents);
892 max_page_ids_ = contents->max_page_ids_; 893 max_page_ids_ = contents->max_page_ids_;
893 } 894 }
894 895
895 SiteInstanceImpl* WebContentsImpl::GetSiteInstance() const { 896 SiteInstanceImpl* WebContentsImpl::GetSiteInstance() const {
896 return GetRenderManager()->current_host()->GetSiteInstance(); 897 return GetRenderManager()->current_host()->GetSiteInstance();
897 } 898 }
898 899
899 SiteInstanceImpl* WebContentsImpl::GetPendingSiteInstance() const { 900 SiteInstanceImpl* WebContentsImpl::GetPendingSiteInstance() const {
901 CHECK(!browser_plugin_guest_);
Charlie Reis 2015/03/10 04:09:44 This doesn't belong in an accessor for the SiteIns
lazyboy 2015/04/01 21:47:57 Removed.
900 RenderViewHostImpl* dest_rvh = 902 RenderViewHostImpl* dest_rvh =
901 GetRenderManager()->pending_render_view_host() ? 903 GetRenderManager()->pending_render_view_host() ?
902 GetRenderManager()->pending_render_view_host() : 904 GetRenderManager()->pending_render_view_host() :
903 GetRenderManager()->current_host(); 905 GetRenderManager()->current_host();
904 return dest_rvh->GetSiteInstance(); 906 return dest_rvh->GetSiteInstance();
905 } 907 }
906 908
907 bool WebContentsImpl::IsLoading() const { 909 bool WebContentsImpl::IsLoading() const {
908 return is_loading_; 910 return is_loading_;
909 } 911 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 params.main_frame_routing_id == MSG_ROUTING_NONE) || 1212 params.main_frame_routing_id == MSG_ROUTING_NONE) ||
1211 (params.routing_id != MSG_ROUTING_NONE && 1213 (params.routing_id != MSG_ROUTING_NONE &&
1212 params.main_frame_routing_id != MSG_ROUTING_NONE)); 1214 params.main_frame_routing_id != MSG_ROUTING_NONE));
1213 GetRenderManager()->Init( 1215 GetRenderManager()->Init(
1214 params.browser_context, params.site_instance, params.routing_id, 1216 params.browser_context, params.site_instance, params.routing_id,
1215 params.main_frame_routing_id); 1217 params.main_frame_routing_id);
1216 1218
1217 WebContentsViewDelegate* delegate = 1219 WebContentsViewDelegate* delegate =
1218 GetContentClient()->browser()->GetWebContentsViewDelegate(this); 1220 GetContentClient()->browser()->GetWebContentsViewDelegate(this);
1219 1221
1220 if (browser_plugin_guest_) { 1222 // if (browser_plugin_guest_) {
1221 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( 1223 // scoped_ptr<WebContentsView> platform_view(CreateWebContentsView(
1222 this, delegate, &render_view_host_delegate_view_)); 1224 // this, delegate, &render_view_host_delegate_view_));
1223 1225 //
1224 WebContentsViewGuest* rv = new WebContentsViewGuest( 1226 // WebContentsViewGuest* rv = new WebContentsViewGuest(
1225 this, browser_plugin_guest_.get(), platform_view.Pass(), 1227 // this, browser_plugin_guest_.get(), platform_view.Pass(),
1226 render_view_host_delegate_view_); 1228 // render_view_host_delegate_view_);
1227 render_view_host_delegate_view_ = rv; 1229 // render_view_host_delegate_view_ = rv;
1228 view_.reset(rv); 1230 // view_.reset(rv);
1229 } else { 1231 // } else {
1230 // Regular WebContentsView. 1232 // Regular WebContentsView.
1231 view_.reset(CreateWebContentsView( 1233 view_.reset(CreateWebContentsView(
1232 this, delegate, &render_view_host_delegate_view_)); 1234 this, delegate, &render_view_host_delegate_view_));
1233 } 1235 // }
1234 CHECK(render_view_host_delegate_view_); 1236 CHECK(render_view_host_delegate_view_);
1235 CHECK(view_.get()); 1237 CHECK(view_.get());
1236 1238
1237 gfx::Size initial_size = params.initial_size; 1239 gfx::Size initial_size = params.initial_size;
1238 view_->CreateView(initial_size, params.context); 1240 view_->CreateView(initial_size, params.context);
1239 1241
1240 // Listen for whether our opener gets destroyed. 1242 // Listen for whether our opener gets destroyed.
1241 if (opener_) 1243 if (opener_)
1242 AddDestructionObserver(opener_); 1244 AddDestructionObserver(opener_);
1243 1245
(...skipping 17 matching lines...) Expand all
1261 1263
1262 // BrowserPluginGuest::Init needs to be called after this WebContents has 1264 // BrowserPluginGuest::Init needs to be called after this WebContents has
1263 // a RenderWidgetHostViewGuest. That is, |view_->CreateView| above. 1265 // a RenderWidgetHostViewGuest. That is, |view_->CreateView| above.
1264 if (browser_plugin_guest_) 1266 if (browser_plugin_guest_)
1265 browser_plugin_guest_->Init(); 1267 browser_plugin_guest_->Init();
1266 1268
1267 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++) 1269 for (size_t i = 0; i < g_created_callbacks.Get().size(); i++)
1268 g_created_callbacks.Get().at(i).Run(this); 1270 g_created_callbacks.Get().at(i).Run(this);
1269 } 1271 }
1270 1272
1273 int WebContentsImpl::AttachLocalFrameToGuest(WebContents* owner_web_contents,
Charlie Reis 2015/03/10 04:09:44 It looks like most of the operations in here proba
lazyboy 2015/04/01 21:47:57 Moved bulk of these to RFHM.
1274 int embedder_local_render_frame_id,
1275 int guest_instance_id) {
1276 SiteInstance* embedder_si = owner_web_contents->GetSiteInstance();
1277 FrameTreeNode* guest_ftn = GetFrameTree()->root();
1278
1279 RenderFrameHostImpl* embedder_local_frame =
1280 RenderFrameHostImpl::FromID(
1281 owner_web_contents->GetRenderProcessHost()->GetID(),
1282 embedder_local_render_frame_id);
Charlie Reis 2015/03/10 04:09:44 embedder_frame_routing_id?
lazyboy 2015/04/01 21:47:58 Done.
1283 DCHECK(embedder_local_frame);
1284 FrameTreeNode* embedder_ftn =
1285 embedder_local_frame->frame_tree_node();
1286
1287 FrameTreeNode* embedder_ftn_parent = embedder_ftn->parent();
1288 DCHECK(embedder_ftn_parent);
1289
1290 // TODO: Explain this.
1291 guest_ftn->render_manager()->set_pseudo_parent_frame_tree_node_id(
1292 embedder_ftn_parent->frame_tree_node_id());
1293
1294 // Create proxy stuff in Embedder process.
1295 int embedder_proxy_flags =
1296 CREATE_RF_HIDDEN |
1297 CREATE_RF_SWAPPED_OUT |
1298 CREATE_RF_FOR_MAIN_FRAME_NAVIGATION; // ???.
1299 int rv_of_embedder_id;
Charlie Reis 2015/03/10 04:09:44 Let's start moving to names that might use in prac
lazyboy 2015/04/01 21:47:57 OK, I've made some changes.
1300 scoped_ptr<RenderFrameHostImpl> so_rfh_in_embedder =
1301 guest_ftn->render_manager()->CreateRenderFrame(
1302 embedder_si,
1303 nullptr,
1304 MSG_ROUTING_NONE, // opener_route_id
1305 embedder_proxy_flags,
1306 &rv_of_embedder_id);
1307
1308 RenderFrameProxyHost* rfph_in_embedder =
1309 guest_ftn->render_manager()->GetRenderFrameProxyHost(
1310 embedder_si);
1311 DCHECK(rfph_in_embedder);
1312 int rfph_in_embedder_routing_id = rfph_in_embedder->GetRoutingID();
1313
1314 // Send a content message to complete the frame swap.
1315 embedder_ftn_parent->current_frame_host()->Send(
1316 new FrameMsg_ReplaceLocalFrameWithProxy(
1317 embedder_ftn->current_frame_host()->GetRoutingID(),
1318 rfph_in_embedder_routing_id));
1319
1320 // The swapped out render view routing ID will be used to send
1321 // postMessage.
1322 return rv_of_embedder_id;
1323 }
1324
1271 void WebContentsImpl::OnWebContentsDestroyed(WebContentsImpl* web_contents) { 1325 void WebContentsImpl::OnWebContentsDestroyed(WebContentsImpl* web_contents) {
1272 RemoveDestructionObserver(web_contents); 1326 RemoveDestructionObserver(web_contents);
1273 1327
1274 // Clear the opener if it has been closed. 1328 // Clear the opener if it has been closed.
1275 if (web_contents == opener_) { 1329 if (web_contents == opener_) {
1276 opener_ = NULL; 1330 opener_ = NULL;
1277 return; 1331 return;
1278 } 1332 }
1279 // Clear a pending contents that has been closed before being shown. 1333 // Clear a pending contents that has been closed before being shown.
1280 for (PendingContents::iterator iter = pending_contents_.begin(); 1334 for (PendingContents::iterator iter = pending_contents_.begin();
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 if (delegate_) 1556 if (delegate_)
1503 delegate_->LostMouseLock(); 1557 delegate_->LostMouseLock();
1504 } 1558 }
1505 1559
1506 void WebContentsImpl::CreateNewWindow( 1560 void WebContentsImpl::CreateNewWindow(
1507 int render_process_id, 1561 int render_process_id,
1508 int route_id, 1562 int route_id,
1509 int main_frame_route_id, 1563 int main_frame_route_id,
1510 const ViewHostMsg_CreateWindow_Params& params, 1564 const ViewHostMsg_CreateWindow_Params& params,
1511 SessionStorageNamespace* session_storage_namespace) { 1565 SessionStorageNamespace* session_storage_namespace) {
1566 DCHECK(0);
1512 // We usually create the new window in the same BrowsingInstance (group of 1567 // We usually create the new window in the same BrowsingInstance (group of
1513 // script-related windows), by passing in the current SiteInstance. However, 1568 // script-related windows), by passing in the current SiteInstance. However,
1514 // if the opener is being suppressed (in a non-guest), we create a new 1569 // if the opener is being suppressed (in a non-guest), we create a new
1515 // SiteInstance in its own BrowsingInstance. 1570 // SiteInstance in its own BrowsingInstance.
1516 bool is_guest = BrowserPluginGuest::IsGuest(this); 1571 bool is_guest = BrowserPluginGuest::IsGuest(this);
1517 1572
1518 // If the opener is to be suppressed, the new window can be in any process. 1573 // If the opener is to be suppressed, the new window can be in any process.
1519 // Since routing ids are process specific, we must not have one passed in 1574 // Since routing ids are process specific, we must not have one passed in
1520 // as argument here. 1575 // as argument here.
1521 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); 1576 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 1777
1723 void WebContentsImpl::ShowCreatedWidget(int route_id, 1778 void WebContentsImpl::ShowCreatedWidget(int route_id,
1724 bool is_fullscreen, 1779 bool is_fullscreen,
1725 const gfx::Rect& initial_rect) { 1780 const gfx::Rect& initial_rect) {
1726 RenderWidgetHostViewBase* widget_host_view = 1781 RenderWidgetHostViewBase* widget_host_view =
1727 static_cast<RenderWidgetHostViewBase*>(GetCreatedWidget(route_id)); 1782 static_cast<RenderWidgetHostViewBase*>(GetCreatedWidget(route_id));
1728 if (!widget_host_view) 1783 if (!widget_host_view)
1729 return; 1784 return;
1730 1785
1731 RenderWidgetHostView* view = NULL; 1786 RenderWidgetHostView* view = NULL;
1732 BrowserPluginGuest* guest = GetBrowserPluginGuest(); 1787 // BrowserPluginGuest* guest = GetBrowserPluginGuest();
1733 if (guest && guest->embedder_web_contents()) { 1788 // if (guest && guest->embedder_web_contents()) {
1734 view = guest->embedder_web_contents()->GetRenderWidgetHostView(); 1789 // view = guest->embedder_web_contents()->GetRenderWidgetHostView();
1735 } else { 1790 // } else {
1736 view = GetRenderWidgetHostView(); 1791 view = GetRenderWidgetHostView();
1737 } 1792 // }
1738 1793
1739 if (is_fullscreen) { 1794 if (is_fullscreen) {
1740 DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_); 1795 DCHECK_EQ(MSG_ROUTING_NONE, fullscreen_widget_routing_id_);
1741 view_->StoreFocus(); 1796 view_->StoreFocus();
1742 fullscreen_widget_routing_id_ = route_id; 1797 fullscreen_widget_routing_id_ = route_id;
1743 if (delegate_ && delegate_->EmbedsFullscreenWidget()) { 1798 if (delegate_ && delegate_->EmbedsFullscreenWidget()) {
1744 widget_host_view->InitAsChild(GetRenderWidgetHostView()->GetNativeView()); 1799 widget_host_view->InitAsChild(GetRenderWidgetHostView()->GetNativeView());
1745 delegate_->EnterFullscreenModeForTab(this, GURL()); 1800 delegate_->EnterFullscreenModeForTab(this, GURL());
1746 } else { 1801 } else {
1747 widget_host_view->InitAsFullscreen(view); 1802 widget_host_view->InitAsFullscreen(view);
(...skipping 2502 matching lines...) Expand 10 before | Expand all | Expand 10 after
4250 int proxy_routing_id, 4305 int proxy_routing_id,
4251 bool for_main_frame_navigation) { 4306 bool for_main_frame_navigation) {
4252 TRACE_EVENT0("browser,navigation", 4307 TRACE_EVENT0("browser,navigation",
4253 "WebContentsImpl::CreateRenderViewForRenderManager"); 4308 "WebContentsImpl::CreateRenderViewForRenderManager");
4254 // Can be NULL during tests. 4309 // Can be NULL during tests.
4255 RenderWidgetHostViewBase* rwh_view; 4310 RenderWidgetHostViewBase* rwh_view;
4256 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary 4311 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary
4257 // until RenderWidgetHost is attached to RenderFrameHost. We need to special 4312 // until RenderWidgetHost is attached to RenderFrameHost. We need to special
4258 // case this because RWH is still a base class of RenderViewHost, and child 4313 // case this because RWH is still a base class of RenderViewHost, and child
4259 // frame RWHVs are unique in that they do not have their own WebContents. 4314 // frame RWHVs are unique in that they do not have their own WebContents.
4260 if (!for_main_frame_navigation) { 4315 bool is_guest = GetSiteInstance()->GetSiteURL().SchemeIs("chrome-guest");
Fady Samuel 2015/03/04 22:21:06 Guests are guests if they have a BrowserPluginGues
lazyboy 2015/04/01 21:47:57 Changed to looking at browser_plugin_guest_ for no
4316 if (!for_main_frame_navigation || is_guest) {
4261 RenderWidgetHostViewChildFrame* rwh_view_child = 4317 RenderWidgetHostViewChildFrame* rwh_view_child =
4262 new RenderWidgetHostViewChildFrame(render_view_host); 4318 new RenderWidgetHostViewChildFrame(render_view_host);
4263 rwh_view = rwh_view_child; 4319 rwh_view = rwh_view_child;
4264 } else { 4320 } else {
4265 rwh_view = view_->CreateViewForWidget(render_view_host, false); 4321 rwh_view = view_->CreateViewForWidget(render_view_host, false);
4266 } 4322 }
4267 4323
4268 // Now that the RenderView has been created, we need to tell it its size. 4324 // Now that the RenderView has been created, we need to tell it its size.
4269 if (rwh_view) 4325 if (rwh_view)
4270 rwh_view->SetSize(GetSizeForNewRenderView()); 4326 rwh_view->SetSize(GetSizeForNewRenderView());
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
4406 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { 4462 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() {
4407 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); 4463 return static_cast<RenderViewHostImpl*>(GetRenderViewHost());
4408 } 4464 }
4409 4465
4410 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { 4466 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const {
4411 return browser_plugin_guest_.get(); 4467 return browser_plugin_guest_.get();
4412 } 4468 }
4413 4469
4414 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) { 4470 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) {
4415 CHECK(!browser_plugin_guest_); 4471 CHECK(!browser_plugin_guest_);
4472 CHECK(guest);
4416 browser_plugin_guest_.reset(guest); 4473 browser_plugin_guest_.reset(guest);
4417 } 4474 }
4418 4475
4419 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const { 4476 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() const {
4420 return browser_plugin_embedder_.get(); 4477 return browser_plugin_embedder_.get();
4421 } 4478 }
4422 4479
4423 void WebContentsImpl::ClearPowerSaveBlockers( 4480 void WebContentsImpl::ClearPowerSaveBlockers(
4424 RenderFrameHost* render_frame_host) { 4481 RenderFrameHost* render_frame_host) {
4425 RemoveAllMediaPlayerEntries(render_frame_host, &active_audio_players_); 4482 RemoveAllMediaPlayerEntries(render_frame_host, &active_audio_players_);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
4506 node->render_manager()->ResumeResponseDeferredAtStart(); 4563 node->render_manager()->ResumeResponseDeferredAtStart();
4507 } 4564 }
4508 4565
4509 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4566 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4510 force_disable_overscroll_content_ = force_disable; 4567 force_disable_overscroll_content_ = force_disable;
4511 if (view_) 4568 if (view_)
4512 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4569 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4513 } 4570 }
4514 4571
4515 } // namespace content 4572 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698