| 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 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 !GetRenderViewHost()->SuddenTerminationAllowed(); | 1232 !GetRenderViewHost()->SuddenTerminationAllowed(); |
| 1232 } | 1233 } |
| 1233 | 1234 |
| 1234 void WebContentsImpl::DispatchBeforeUnload(bool for_cross_site_transition) { | 1235 void WebContentsImpl::DispatchBeforeUnload(bool for_cross_site_transition) { |
| 1235 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition); | 1236 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition); |
| 1236 } | 1237 } |
| 1237 | 1238 |
| 1238 void WebContentsImpl::AttachToOuterWebContentsFrame( | 1239 void WebContentsImpl::AttachToOuterWebContentsFrame( |
| 1239 WebContents* outer_web_contents, | 1240 WebContents* outer_web_contents, |
| 1240 RenderFrameHost* outer_contents_frame) { | 1241 RenderFrameHost* outer_contents_frame) { |
| 1241 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1242 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); |
| 1242 switches::kSitePerProcess)); | |
| 1243 // Create a link to our outer WebContents. | 1243 // Create a link to our outer WebContents. |
| 1244 node_.reset(new WebContentsTreeNode()); | 1244 node_.reset(new WebContentsTreeNode()); |
| 1245 node_->ConnectToOuterWebContents( | 1245 node_->ConnectToOuterWebContents( |
| 1246 static_cast<WebContentsImpl*>(outer_web_contents), | 1246 static_cast<WebContentsImpl*>(outer_web_contents), |
| 1247 static_cast<RenderFrameHostImpl*>(outer_contents_frame)); | 1247 static_cast<RenderFrameHostImpl*>(outer_contents_frame)); |
| 1248 | 1248 |
| 1249 DCHECK(outer_contents_frame); | 1249 DCHECK(outer_contents_frame); |
| 1250 | 1250 |
| 1251 // Create a proxy in top-level RenderFrameHostManager, pointing to the | 1251 // Create a proxy in top-level RenderFrameHostManager, pointing to the |
| 1252 // SiteInstance of the outer WebContents. The proxy will be used to send | 1252 // 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... |
| 1326 params.main_frame_routing_id != MSG_ROUTING_NONE)); | 1326 params.main_frame_routing_id != MSG_ROUTING_NONE)); |
| 1327 GetRenderManager()->Init( | 1327 GetRenderManager()->Init( |
| 1328 params.browser_context, params.site_instance, params.routing_id, | 1328 params.browser_context, params.site_instance, params.routing_id, |
| 1329 params.main_frame_routing_id); | 1329 params.main_frame_routing_id); |
| 1330 frame_tree_.root()->SetFrameName(params.main_frame_name); | 1330 frame_tree_.root()->SetFrameName(params.main_frame_name); |
| 1331 | 1331 |
| 1332 WebContentsViewDelegate* delegate = | 1332 WebContentsViewDelegate* delegate = |
| 1333 GetContentClient()->browser()->GetWebContentsViewDelegate(this); | 1333 GetContentClient()->browser()->GetWebContentsViewDelegate(this); |
| 1334 | 1334 |
| 1335 if (browser_plugin_guest_ && | 1335 if (browser_plugin_guest_ && |
| 1336 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 1336 !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { |
| 1337 switches::kSitePerProcess)) { | |
| 1338 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( | 1337 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( |
| 1339 this, delegate, &render_view_host_delegate_view_)); | 1338 this, delegate, &render_view_host_delegate_view_)); |
| 1340 | 1339 |
| 1341 WebContentsViewGuest* rv = new WebContentsViewGuest( | 1340 WebContentsViewGuest* rv = new WebContentsViewGuest( |
| 1342 this, browser_plugin_guest_.get(), platform_view.Pass(), | 1341 this, browser_plugin_guest_.get(), platform_view.Pass(), |
| 1343 render_view_host_delegate_view_); | 1342 render_view_host_delegate_view_); |
| 1344 render_view_host_delegate_view_ = rv; | 1343 render_view_host_delegate_view_ = rv; |
| 1345 view_.reset(rv); | 1344 view_.reset(rv); |
| 1346 } else { | 1345 } else { |
| 1347 // Regular WebContentsView. | 1346 // Regular WebContentsView. |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1628 int route_id, | 1627 int route_id, |
| 1629 int main_frame_route_id, | 1628 int main_frame_route_id, |
| 1630 const ViewHostMsg_CreateWindow_Params& params, | 1629 const ViewHostMsg_CreateWindow_Params& params, |
| 1631 SessionStorageNamespace* session_storage_namespace) { | 1630 SessionStorageNamespace* session_storage_namespace) { |
| 1632 // We usually create the new window in the same BrowsingInstance (group of | 1631 // We usually create the new window in the same BrowsingInstance (group of |
| 1633 // script-related windows), by passing in the current SiteInstance. However, | 1632 // script-related windows), by passing in the current SiteInstance. However, |
| 1634 // if the opener is being suppressed (in a non-guest), we create a new | 1633 // if the opener is being suppressed (in a non-guest), we create a new |
| 1635 // SiteInstance in its own BrowsingInstance. | 1634 // SiteInstance in its own BrowsingInstance. |
| 1636 bool is_guest = BrowserPluginGuest::IsGuest(this); | 1635 bool is_guest = BrowserPluginGuest::IsGuest(this); |
| 1637 | 1636 |
| 1638 if (is_guest && | 1637 if (is_guest && BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { |
| 1639 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1640 switches::kSitePerProcess)) { | |
| 1641 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> | 1638 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> |
| 1642 // yet. | 1639 // yet. |
| 1643 NOTREACHED(); | 1640 NOTREACHED(); |
| 1644 } | 1641 } |
| 1645 | 1642 |
| 1646 // If the opener is to be suppressed, the new window can be in any process. | 1643 // If the opener is to be suppressed, the new window can be in any process. |
| 1647 // Since routing ids are process specific, we must not have one passed in | 1644 // Since routing ids are process specific, we must not have one passed in |
| 1648 // as argument here. | 1645 // as argument here. |
| 1649 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); | 1646 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); |
| 1650 | 1647 |
| (...skipping 2393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4044 | 4041 |
| 4045 void WebContentsImpl::EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) { | 4042 void WebContentsImpl::EnsureOpenerProxiesExist(RenderFrameHost* source_rfh) { |
| 4046 WebContentsImpl* source_web_contents = static_cast<WebContentsImpl*>( | 4043 WebContentsImpl* source_web_contents = static_cast<WebContentsImpl*>( |
| 4047 WebContents::FromRenderFrameHost(source_rfh)); | 4044 WebContents::FromRenderFrameHost(source_rfh)); |
| 4048 | 4045 |
| 4049 if (source_web_contents) { | 4046 if (source_web_contents) { |
| 4050 // If this message is going to outer WebContents from inner WebContents, | 4047 // If this message is going to outer WebContents from inner WebContents, |
| 4051 // then we should not create a RenderView. AttachToOuterWebContentsFrame() | 4048 // then we should not create a RenderView. AttachToOuterWebContentsFrame() |
| 4052 // already created a RenderFrameProxyHost for that purpose. | 4049 // already created a RenderFrameProxyHost for that purpose. |
| 4053 if (GetBrowserPluginEmbedder() && | 4050 if (GetBrowserPluginEmbedder() && |
| 4054 base::CommandLine::ForCurrentProcess()->HasSwitch( | 4051 BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { |
| 4055 switches::kSitePerProcess)) { | |
| 4056 return; | 4052 return; |
| 4057 } | 4053 } |
| 4058 | 4054 |
| 4059 if (GetBrowserPluginGuest()) { | 4055 if (GetBrowserPluginGuest()) { |
| 4060 // We create a swapped out RenderView for the embedder in the guest's | 4056 // We create a swapped out RenderView for the embedder in the guest's |
| 4061 // render process but we intentionally do not expose the embedder's | 4057 // render process but we intentionally do not expose the embedder's |
| 4062 // opener chain to it. | 4058 // opener chain to it. |
| 4063 source_web_contents->CreateSwappedOutRenderView(GetSiteInstance()); | 4059 source_web_contents->CreateSwappedOutRenderView(GetSiteInstance()); |
| 4064 } else { | 4060 } else { |
| 4065 RenderFrameHostImpl* source_rfhi = | 4061 RenderFrameHostImpl* source_rfhi = |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4270 TRACE_EVENT0("browser,navigation", | 4266 TRACE_EVENT0("browser,navigation", |
| 4271 "WebContentsImpl::CreateRenderViewForRenderManager"); | 4267 "WebContentsImpl::CreateRenderViewForRenderManager"); |
| 4272 // Can be NULL during tests. | 4268 // Can be NULL during tests. |
| 4273 RenderWidgetHostViewBase* rwh_view; | 4269 RenderWidgetHostViewBase* rwh_view; |
| 4274 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary | 4270 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary |
| 4275 // until RenderWidgetHost is attached to RenderFrameHost. We need to special | 4271 // until RenderWidgetHost is attached to RenderFrameHost. We need to special |
| 4276 // case this because RWH is still a base class of RenderViewHost, and child | 4272 // case this because RWH is still a base class of RenderViewHost, and child |
| 4277 // frame RWHVs are unique in that they do not have their own WebContents. | 4273 // frame RWHVs are unique in that they do not have their own WebContents. |
| 4278 bool is_guest_in_site_per_process = | 4274 bool is_guest_in_site_per_process = |
| 4279 !!browser_plugin_guest_.get() && | 4275 !!browser_plugin_guest_.get() && |
| 4280 base::CommandLine::ForCurrentProcess()->HasSwitch( | 4276 BrowserPluginGuestMode::UseCrossProcessFramesForGuests(); |
| 4281 switches::kSitePerProcess); | |
| 4282 if (!for_main_frame_navigation || is_guest_in_site_per_process) { | 4277 if (!for_main_frame_navigation || is_guest_in_site_per_process) { |
| 4283 RenderWidgetHostViewChildFrame* rwh_view_child = | 4278 RenderWidgetHostViewChildFrame* rwh_view_child = |
| 4284 new RenderWidgetHostViewChildFrame(render_view_host); | 4279 new RenderWidgetHostViewChildFrame(render_view_host); |
| 4285 rwh_view = rwh_view_child; | 4280 rwh_view = rwh_view_child; |
| 4286 } else { | 4281 } else { |
| 4287 rwh_view = view_->CreateViewForWidget(render_view_host, false); | 4282 rwh_view = view_->CreateViewForWidget(render_view_host, false); |
| 4288 } | 4283 } |
| 4289 | 4284 |
| 4290 // Now that the RenderView has been created, we need to tell it its size. | 4285 // Now that the RenderView has been created, we need to tell it its size. |
| 4291 if (rwh_view) | 4286 if (rwh_view) |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4532 player_map->erase(it); | 4527 player_map->erase(it); |
| 4533 } | 4528 } |
| 4534 | 4529 |
| 4535 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4530 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4536 force_disable_overscroll_content_ = force_disable; | 4531 force_disable_overscroll_content_ = force_disable; |
| 4537 if (view_) | 4532 if (view_) |
| 4538 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4533 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4539 } | 4534 } |
| 4540 | 4535 |
| 4541 } // namespace content | 4536 } // namespace content |
| OLD | NEW |