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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 #include "content/public/browser/storage_partition.h" | 87 #include "content/public/browser/storage_partition.h" |
88 #include "content/public/browser/user_metrics.h" | 88 #include "content/public/browser/user_metrics.h" |
89 #include "content/public/browser/web_contents_delegate.h" | 89 #include "content/public/browser/web_contents_delegate.h" |
90 #include "content/public/browser/web_contents_observer.h" | 90 #include "content/public/browser/web_contents_observer.h" |
91 #include "content/public/common/bindings_policy.h" | 91 #include "content/public/common/bindings_policy.h" |
92 #include "content/public/common/content_constants.h" | 92 #include "content/public/common/content_constants.h" |
93 #include "content/public/common/content_switches.h" | 93 #include "content/public/common/content_switches.h" |
94 #include "content/public/common/page_zoom.h" | 94 #include "content/public/common/page_zoom.h" |
95 #include "content/public/common/result_codes.h" | 95 #include "content/public/common/result_codes.h" |
96 #include "content/public/common/security_style.h" | 96 #include "content/public/common/security_style.h" |
| 97 #include "content/public/common/site_isolation_policy.h" |
97 #include "content/public/common/url_constants.h" | 98 #include "content/public/common/url_constants.h" |
98 #include "content/public/common/url_utils.h" | 99 #include "content/public/common/url_utils.h" |
99 #include "content/public/common/web_preferences.h" | 100 #include "content/public/common/web_preferences.h" |
100 #include "net/base/net_util.h" | 101 #include "net/base/net_util.h" |
101 #include "net/http/http_cache.h" | 102 #include "net/http/http_cache.h" |
102 #include "net/http/http_transaction_factory.h" | 103 #include "net/http/http_transaction_factory.h" |
103 #include "net/url_request/url_request_context.h" | 104 #include "net/url_request/url_request_context.h" |
104 #include "net/url_request/url_request_context_getter.h" | 105 #include "net/url_request/url_request_context_getter.h" |
105 #include "ui/base/layout.h" | 106 #include "ui/base/layout.h" |
106 #include "ui/gfx/display.h" | 107 #include "ui/gfx/display.h" |
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 !GetRenderViewHost()->SuddenTerminationAllowed(); | 1211 !GetRenderViewHost()->SuddenTerminationAllowed(); |
1211 } | 1212 } |
1212 | 1213 |
1213 void WebContentsImpl::DispatchBeforeUnload(bool for_cross_site_transition) { | 1214 void WebContentsImpl::DispatchBeforeUnload(bool for_cross_site_transition) { |
1214 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition); | 1215 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition); |
1215 } | 1216 } |
1216 | 1217 |
1217 void WebContentsImpl::AttachToOuterWebContentsFrame( | 1218 void WebContentsImpl::AttachToOuterWebContentsFrame( |
1218 WebContents* outer_web_contents, | 1219 WebContents* outer_web_contents, |
1219 RenderFrameHost* outer_contents_frame) { | 1220 RenderFrameHost* outer_contents_frame) { |
1220 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1221 CHECK(SiteIsolationPolicy::GuestsShouldUseCrossProcessFrames()); |
1221 switches::kSitePerProcess)); | |
1222 // Create a link to our outer WebContents. | 1222 // Create a link to our outer WebContents. |
1223 node_.reset(new WebContentsTreeNode()); | 1223 node_.reset(new WebContentsTreeNode()); |
1224 node_->ConnectToOuterWebContents( | 1224 node_->ConnectToOuterWebContents( |
1225 static_cast<WebContentsImpl*>(outer_web_contents), | 1225 static_cast<WebContentsImpl*>(outer_web_contents), |
1226 static_cast<RenderFrameHostImpl*>(outer_contents_frame)); | 1226 static_cast<RenderFrameHostImpl*>(outer_contents_frame)); |
1227 | 1227 |
1228 DCHECK(outer_contents_frame); | 1228 DCHECK(outer_contents_frame); |
1229 | 1229 |
1230 // Create a proxy in top-level RenderFrameHostManager, pointing to the | 1230 // Create a proxy in top-level RenderFrameHostManager, pointing to the |
1231 // SiteInstance of the outer WebContents. The proxy will be used to send | 1231 // SiteInstance of the outer WebContents. The proxy will be used to send |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 params.main_frame_routing_id != MSG_ROUTING_NONE)); | 1305 params.main_frame_routing_id != MSG_ROUTING_NONE)); |
1306 GetRenderManager()->Init( | 1306 GetRenderManager()->Init( |
1307 params.browser_context, params.site_instance, params.routing_id, | 1307 params.browser_context, params.site_instance, params.routing_id, |
1308 params.main_frame_routing_id); | 1308 params.main_frame_routing_id); |
1309 frame_tree_.root()->SetFrameName(params.main_frame_name); | 1309 frame_tree_.root()->SetFrameName(params.main_frame_name); |
1310 | 1310 |
1311 WebContentsViewDelegate* delegate = | 1311 WebContentsViewDelegate* delegate = |
1312 GetContentClient()->browser()->GetWebContentsViewDelegate(this); | 1312 GetContentClient()->browser()->GetWebContentsViewDelegate(this); |
1313 | 1313 |
1314 if (browser_plugin_guest_ && | 1314 if (browser_plugin_guest_ && |
1315 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1315 !SiteIsolationPolicy::GuestsShouldUseCrossProcessFrames()) { |
1316 switches::kSitePerProcess)) { | |
1317 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( | 1316 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( |
1318 this, delegate, &render_view_host_delegate_view_)); | 1317 this, delegate, &render_view_host_delegate_view_)); |
1319 | 1318 |
1320 WebContentsViewGuest* rv = new WebContentsViewGuest( | 1319 WebContentsViewGuest* rv = new WebContentsViewGuest( |
1321 this, browser_plugin_guest_.get(), platform_view.Pass(), | 1320 this, browser_plugin_guest_.get(), platform_view.Pass(), |
1322 render_view_host_delegate_view_); | 1321 render_view_host_delegate_view_); |
1323 render_view_host_delegate_view_ = rv; | 1322 render_view_host_delegate_view_ = rv; |
1324 view_.reset(rv); | 1323 view_.reset(rv); |
1325 } else { | 1324 } else { |
1326 // Regular WebContentsView. | 1325 // Regular WebContentsView. |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1607 int route_id, | 1606 int route_id, |
1608 int main_frame_route_id, | 1607 int main_frame_route_id, |
1609 const ViewHostMsg_CreateWindow_Params& params, | 1608 const ViewHostMsg_CreateWindow_Params& params, |
1610 SessionStorageNamespace* session_storage_namespace) { | 1609 SessionStorageNamespace* session_storage_namespace) { |
1611 // We usually create the new window in the same BrowsingInstance (group of | 1610 // We usually create the new window in the same BrowsingInstance (group of |
1612 // script-related windows), by passing in the current SiteInstance. However, | 1611 // script-related windows), by passing in the current SiteInstance. However, |
1613 // if the opener is being suppressed (in a non-guest), we create a new | 1612 // if the opener is being suppressed (in a non-guest), we create a new |
1614 // SiteInstance in its own BrowsingInstance. | 1613 // SiteInstance in its own BrowsingInstance. |
1615 bool is_guest = BrowserPluginGuest::IsGuest(this); | 1614 bool is_guest = BrowserPluginGuest::IsGuest(this); |
1616 | 1615 |
1617 if (is_guest && | 1616 if (is_guest && SiteIsolationPolicy::GuestsShouldUseCrossProcessFrames()) { |
1618 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1619 switches::kSitePerProcess)) { | |
1620 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> | 1617 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> |
1621 // yet. | 1618 // yet. |
1622 NOTREACHED(); | 1619 NOTREACHED(); |
1623 } | 1620 } |
1624 | 1621 |
1625 // If the opener is to be suppressed, the new window can be in any process. | 1622 // If the opener is to be suppressed, the new window can be in any process. |
1626 // Since routing ids are process specific, we must not have one passed in | 1623 // Since routing ids are process specific, we must not have one passed in |
1627 // as argument here. | 1624 // as argument here. |
1628 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); | 1625 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); |
1629 | 1626 |
(...skipping 2364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3994 | 3991 |
3995 void WebContentsImpl::EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) { | 3992 void WebContentsImpl::EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) { |
3996 WebContentsImpl* source_web_contents = static_cast<WebContentsImpl*>( | 3993 WebContentsImpl* source_web_contents = static_cast<WebContentsImpl*>( |
3997 WebContents::FromRenderFrameHost(source_rfh)); | 3994 WebContents::FromRenderFrameHost(source_rfh)); |
3998 | 3995 |
3999 if (source_web_contents) { | 3996 if (source_web_contents) { |
4000 // If this message is going to outer WebContents from inner WebContents, | 3997 // If this message is going to outer WebContents from inner WebContents, |
4001 // then we should not create a RenderView. AttachToOuterWebContentsFrame() | 3998 // then we should not create a RenderView. AttachToOuterWebContentsFrame() |
4002 // already created a RenderFrameProxyHost for that purpose. | 3999 // already created a RenderFrameProxyHost for that purpose. |
4003 if (GetBrowserPluginEmbedder() && | 4000 if (GetBrowserPluginEmbedder() && |
4004 base::CommandLine::ForCurrentProcess()->HasSwitch( | 4001 SiteIsolationPolicy::GuestsShouldUseCrossProcessFrames()) { |
4005 switches::kSitePerProcess)) { | |
4006 return; | 4002 return; |
4007 } | 4003 } |
4008 | 4004 |
4009 if (GetBrowserPluginGuest()) { | 4005 if (GetBrowserPluginGuest()) { |
4010 // We create a swapped out RenderView for the embedder in the guest's | 4006 // We create a swapped out RenderView for the embedder in the guest's |
4011 // render process but we intentionally do not expose the embedder's | 4007 // render process but we intentionally do not expose the embedder's |
4012 // opener chain to it. | 4008 // opener chain to it. |
4013 source_web_contents->CreateSwappedOutRenderView(GetSiteInstance()); | 4009 source_web_contents->CreateSwappedOutRenderView(GetSiteInstance()); |
4014 } else { | 4010 } else { |
4015 RenderFrameHostImpl* source_rfhi = | 4011 RenderFrameHostImpl* source_rfhi = |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4220 TRACE_EVENT0("browser,navigation", | 4216 TRACE_EVENT0("browser,navigation", |
4221 "WebContentsImpl::CreateRenderViewForRenderManager"); | 4217 "WebContentsImpl::CreateRenderViewForRenderManager"); |
4222 // Can be NULL during tests. | 4218 // Can be NULL during tests. |
4223 RenderWidgetHostViewBase* rwh_view; | 4219 RenderWidgetHostViewBase* rwh_view; |
4224 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary | 4220 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary |
4225 // until RenderWidgetHost is attached to RenderFrameHost. We need to special | 4221 // until RenderWidgetHost is attached to RenderFrameHost. We need to special |
4226 // 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 |
4227 // 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. |
4228 bool is_guest_in_site_per_process = | 4224 bool is_guest_in_site_per_process = |
4229 !!browser_plugin_guest_.get() && | 4225 !!browser_plugin_guest_.get() && |
4230 base::CommandLine::ForCurrentProcess()->HasSwitch( | 4226 SiteIsolationPolicy::GuestsShouldUseCrossProcessFrames(); |
4231 switches::kSitePerProcess); | |
4232 if (!for_main_frame_navigation || is_guest_in_site_per_process) { | 4227 if (!for_main_frame_navigation || is_guest_in_site_per_process) { |
4233 RenderWidgetHostViewChildFrame* rwh_view_child = | 4228 RenderWidgetHostViewChildFrame* rwh_view_child = |
4234 new RenderWidgetHostViewChildFrame(render_view_host); | 4229 new RenderWidgetHostViewChildFrame(render_view_host); |
4235 rwh_view = rwh_view_child; | 4230 rwh_view = rwh_view_child; |
4236 } else { | 4231 } else { |
4237 rwh_view = view_->CreateViewForWidget(render_view_host, false); | 4232 rwh_view = view_->CreateViewForWidget(render_view_host, false); |
4238 } | 4233 } |
4239 | 4234 |
4240 // Now that the RenderView has been created, we need to tell it its size. | 4235 // Now that the RenderView has been created, we need to tell it its size. |
4241 if (rwh_view) | 4236 if (rwh_view) |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4484 player_map->erase(it); | 4479 player_map->erase(it); |
4485 } | 4480 } |
4486 | 4481 |
4487 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4482 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4488 force_disable_overscroll_content_ = force_disable; | 4483 force_disable_overscroll_content_ = force_disable; |
4489 if (view_) | 4484 if (view_) |
4490 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4485 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4491 } | 4486 } |
4492 | 4487 |
4493 } // namespace content | 4488 } // namespace content |
OLD | NEW |