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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 #include "content/public/browser/notification_service.h" | 81 #include "content/public/browser/notification_service.h" |
82 #include "content/public/browser/render_widget_host_iterator.h" | 82 #include "content/public/browser/render_widget_host_iterator.h" |
83 #include "content/public/browser/resource_request_details.h" | 83 #include "content/public/browser/resource_request_details.h" |
84 #include "content/public/browser/screen_orientation_dispatcher_host.h" | 84 #include "content/public/browser/screen_orientation_dispatcher_host.h" |
85 #include "content/public/browser/security_style_explanations.h" | 85 #include "content/public/browser/security_style_explanations.h" |
86 #include "content/public/browser/storage_partition.h" | 86 #include "content/public/browser/storage_partition.h" |
87 #include "content/public/browser/user_metrics.h" | 87 #include "content/public/browser/user_metrics.h" |
88 #include "content/public/browser/web_contents_delegate.h" | 88 #include "content/public/browser/web_contents_delegate.h" |
89 #include "content/public/browser/web_contents_observer.h" | 89 #include "content/public/browser/web_contents_observer.h" |
90 #include "content/public/common/bindings_policy.h" | 90 #include "content/public/common/bindings_policy.h" |
| 91 #include "content/public/common/browser_plugin_guest_mode.h" |
91 #include "content/public/common/content_constants.h" | 92 #include "content/public/common/content_constants.h" |
92 #include "content/public/common/content_switches.h" | 93 #include "content/public/common/content_switches.h" |
93 #include "content/public/common/page_zoom.h" | 94 #include "content/public/common/page_zoom.h" |
94 #include "content/public/common/result_codes.h" | 95 #include "content/public/common/result_codes.h" |
95 #include "content/public/common/security_style.h" | 96 #include "content/public/common/security_style.h" |
96 #include "content/public/common/url_constants.h" | 97 #include "content/public/common/url_constants.h" |
97 #include "content/public/common/url_utils.h" | 98 #include "content/public/common/url_utils.h" |
98 #include "content/public/common/web_preferences.h" | 99 #include "content/public/common/web_preferences.h" |
99 #include "mojo/common/url_type_converters.h" | 100 #include "mojo/common/url_type_converters.h" |
100 #include "mojo/converters/geometry/geometry_type_converters.h" | 101 #include "mojo/converters/geometry/geometry_type_converters.h" |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 !GetRenderViewHost()->SuddenTerminationAllowed(); | 1225 !GetRenderViewHost()->SuddenTerminationAllowed(); |
1225 } | 1226 } |
1226 | 1227 |
1227 void WebContentsImpl::DispatchBeforeUnload(bool for_cross_site_transition) { | 1228 void WebContentsImpl::DispatchBeforeUnload(bool for_cross_site_transition) { |
1228 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition); | 1229 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition); |
1229 } | 1230 } |
1230 | 1231 |
1231 void WebContentsImpl::AttachToOuterWebContentsFrame( | 1232 void WebContentsImpl::AttachToOuterWebContentsFrame( |
1232 WebContents* outer_web_contents, | 1233 WebContents* outer_web_contents, |
1233 RenderFrameHost* outer_contents_frame) { | 1234 RenderFrameHost* outer_contents_frame) { |
1234 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1235 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); |
1235 switches::kSitePerProcess)); | |
1236 // Create a link to our outer WebContents. | 1236 // Create a link to our outer WebContents. |
1237 node_.reset(new WebContentsTreeNode()); | 1237 node_.reset(new WebContentsTreeNode()); |
1238 node_->ConnectToOuterWebContents( | 1238 node_->ConnectToOuterWebContents( |
1239 static_cast<WebContentsImpl*>(outer_web_contents), | 1239 static_cast<WebContentsImpl*>(outer_web_contents), |
1240 static_cast<RenderFrameHostImpl*>(outer_contents_frame)); | 1240 static_cast<RenderFrameHostImpl*>(outer_contents_frame)); |
1241 | 1241 |
1242 DCHECK(outer_contents_frame); | 1242 DCHECK(outer_contents_frame); |
1243 | 1243 |
1244 // Create a proxy in top-level RenderFrameHostManager, pointing to the | 1244 // Create a proxy in top-level RenderFrameHostManager, pointing to the |
1245 // SiteInstance of the outer WebContents. The proxy will be used to send | 1245 // 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... |
1319 params.main_frame_routing_id != MSG_ROUTING_NONE)); | 1319 params.main_frame_routing_id != MSG_ROUTING_NONE)); |
1320 GetRenderManager()->Init( | 1320 GetRenderManager()->Init( |
1321 params.browser_context, params.site_instance, params.routing_id, | 1321 params.browser_context, params.site_instance, params.routing_id, |
1322 params.main_frame_routing_id); | 1322 params.main_frame_routing_id); |
1323 frame_tree_.root()->SetFrameName(params.main_frame_name); | 1323 frame_tree_.root()->SetFrameName(params.main_frame_name); |
1324 | 1324 |
1325 WebContentsViewDelegate* delegate = | 1325 WebContentsViewDelegate* delegate = |
1326 GetContentClient()->browser()->GetWebContentsViewDelegate(this); | 1326 GetContentClient()->browser()->GetWebContentsViewDelegate(this); |
1327 | 1327 |
1328 if (browser_plugin_guest_ && | 1328 if (browser_plugin_guest_ && |
1329 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1329 !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { |
1330 switches::kSitePerProcess)) { | |
1331 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( | 1330 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( |
1332 this, delegate, &render_view_host_delegate_view_)); | 1331 this, delegate, &render_view_host_delegate_view_)); |
1333 | 1332 |
1334 WebContentsViewGuest* rv = new WebContentsViewGuest( | 1333 WebContentsViewGuest* rv = new WebContentsViewGuest( |
1335 this, browser_plugin_guest_.get(), platform_view.Pass(), | 1334 this, browser_plugin_guest_.get(), platform_view.Pass(), |
1336 render_view_host_delegate_view_); | 1335 render_view_host_delegate_view_); |
1337 render_view_host_delegate_view_ = rv; | 1336 render_view_host_delegate_view_ = rv; |
1338 view_.reset(rv); | 1337 view_.reset(rv); |
1339 } else { | 1338 } else { |
1340 // Regular WebContentsView. | 1339 // Regular WebContentsView. |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 int route_id, | 1620 int route_id, |
1622 int main_frame_route_id, | 1621 int main_frame_route_id, |
1623 const ViewHostMsg_CreateWindow_Params& params, | 1622 const ViewHostMsg_CreateWindow_Params& params, |
1624 SessionStorageNamespace* session_storage_namespace) { | 1623 SessionStorageNamespace* session_storage_namespace) { |
1625 // We usually create the new window in the same BrowsingInstance (group of | 1624 // We usually create the new window in the same BrowsingInstance (group of |
1626 // script-related windows), by passing in the current SiteInstance. However, | 1625 // script-related windows), by passing in the current SiteInstance. However, |
1627 // if the opener is being suppressed (in a non-guest), we create a new | 1626 // if the opener is being suppressed (in a non-guest), we create a new |
1628 // SiteInstance in its own BrowsingInstance. | 1627 // SiteInstance in its own BrowsingInstance. |
1629 bool is_guest = BrowserPluginGuest::IsGuest(this); | 1628 bool is_guest = BrowserPluginGuest::IsGuest(this); |
1630 | 1629 |
1631 if (is_guest && | 1630 if (is_guest && BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { |
1632 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1633 switches::kSitePerProcess)) { | |
1634 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> | 1631 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> |
1635 // yet. | 1632 // yet. |
1636 NOTREACHED(); | 1633 NOTREACHED(); |
1637 } | 1634 } |
1638 | 1635 |
1639 // If the opener is to be suppressed, the new window can be in any process. | 1636 // If the opener is to be suppressed, the new window can be in any process. |
1640 // Since routing ids are process specific, we must not have one passed in | 1637 // Since routing ids are process specific, we must not have one passed in |
1641 // as argument here. | 1638 // as argument here. |
1642 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); | 1639 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); |
1643 | 1640 |
(...skipping 2391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4035 | 4032 |
4036 void WebContentsImpl::EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) { | 4033 void WebContentsImpl::EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) { |
4037 WebContentsImpl* source_web_contents = static_cast<WebContentsImpl*>( | 4034 WebContentsImpl* source_web_contents = static_cast<WebContentsImpl*>( |
4038 WebContents::FromRenderFrameHost(source_rfh)); | 4035 WebContents::FromRenderFrameHost(source_rfh)); |
4039 | 4036 |
4040 if (source_web_contents) { | 4037 if (source_web_contents) { |
4041 // If this message is going to outer WebContents from inner WebContents, | 4038 // If this message is going to outer WebContents from inner WebContents, |
4042 // then we should not create a RenderView. AttachToOuterWebContentsFrame() | 4039 // then we should not create a RenderView. AttachToOuterWebContentsFrame() |
4043 // already created a RenderFrameProxyHost for that purpose. | 4040 // already created a RenderFrameProxyHost for that purpose. |
4044 if (GetBrowserPluginEmbedder() && | 4041 if (GetBrowserPluginEmbedder() && |
4045 base::CommandLine::ForCurrentProcess()->HasSwitch( | 4042 BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { |
4046 switches::kSitePerProcess)) { | |
4047 return; | 4043 return; |
4048 } | 4044 } |
4049 | 4045 |
4050 if (GetBrowserPluginGuest()) { | 4046 if (GetBrowserPluginGuest()) { |
4051 // We create a swapped out RenderView for the embedder in the guest's | 4047 // We create a swapped out RenderView for the embedder in the guest's |
4052 // render process but we intentionally do not expose the embedder's | 4048 // render process but we intentionally do not expose the embedder's |
4053 // opener chain to it. | 4049 // opener chain to it. |
4054 source_web_contents->CreateSwappedOutRenderView(GetSiteInstance()); | 4050 source_web_contents->CreateSwappedOutRenderView(GetSiteInstance()); |
4055 } else { | 4051 } else { |
4056 RenderFrameHostImpl* source_rfhi = | 4052 RenderFrameHostImpl* source_rfhi = |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4261 TRACE_EVENT0("browser,navigation", | 4257 TRACE_EVENT0("browser,navigation", |
4262 "WebContentsImpl::CreateRenderViewForRenderManager"); | 4258 "WebContentsImpl::CreateRenderViewForRenderManager"); |
4263 // Can be NULL during tests. | 4259 // Can be NULL during tests. |
4264 RenderWidgetHostViewBase* rwh_view; | 4260 RenderWidgetHostViewBase* rwh_view; |
4265 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary | 4261 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary |
4266 // until RenderWidgetHost is attached to RenderFrameHost. We need to special | 4262 // until RenderWidgetHost is attached to RenderFrameHost. We need to special |
4267 // case this because RWH is still a base class of RenderViewHost, and child | 4263 // case this because RWH is still a base class of RenderViewHost, and child |
4268 // frame RWHVs are unique in that they do not have their own WebContents. | 4264 // frame RWHVs are unique in that they do not have their own WebContents. |
4269 bool is_guest_in_site_per_process = | 4265 bool is_guest_in_site_per_process = |
4270 !!browser_plugin_guest_.get() && | 4266 !!browser_plugin_guest_.get() && |
4271 base::CommandLine::ForCurrentProcess()->HasSwitch( | 4267 BrowserPluginGuestMode::UseCrossProcessFramesForGuests(); |
4272 switches::kSitePerProcess); | |
4273 if (!for_main_frame_navigation || is_guest_in_site_per_process) { | 4268 if (!for_main_frame_navigation || is_guest_in_site_per_process) { |
4274 RenderWidgetHostViewChildFrame* rwh_view_child = | 4269 RenderWidgetHostViewChildFrame* rwh_view_child = |
4275 new RenderWidgetHostViewChildFrame(render_view_host); | 4270 new RenderWidgetHostViewChildFrame(render_view_host); |
4276 rwh_view = rwh_view_child; | 4271 rwh_view = rwh_view_child; |
4277 } else { | 4272 } else { |
4278 rwh_view = view_->CreateViewForWidget(render_view_host, false); | 4273 rwh_view = view_->CreateViewForWidget(render_view_host, false); |
4279 } | 4274 } |
4280 | 4275 |
4281 // Now that the RenderView has been created, we need to tell it its size. | 4276 // Now that the RenderView has been created, we need to tell it its size. |
4282 if (rwh_view) | 4277 if (rwh_view) |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4523 player_map->erase(it); | 4518 player_map->erase(it); |
4524 } | 4519 } |
4525 | 4520 |
4526 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4521 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4527 force_disable_overscroll_content_ = force_disable; | 4522 force_disable_overscroll_content_ = force_disable; |
4528 if (view_) | 4523 if (view_) |
4529 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4524 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4530 } | 4525 } |
4531 | 4526 |
4532 } // namespace content | 4527 } // namespace content |
OLD | NEW |