| 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 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 WebContents* WebContentsImpl::GetWebContents() { | 1336 WebContents* WebContentsImpl::GetWebContents() { |
| 1337 return this; | 1337 return this; |
| 1338 } | 1338 } |
| 1339 | 1339 |
| 1340 void WebContentsImpl::Init(const WebContents::CreateParams& params) { | 1340 void WebContentsImpl::Init(const WebContents::CreateParams& params) { |
| 1341 // This is set before initializing the render manager since | 1341 // This is set before initializing the render manager since |
| 1342 // RenderFrameHostManager::Init calls back into us via its delegate to ask if | 1342 // RenderFrameHostManager::Init calls back into us via its delegate to ask if |
| 1343 // it should be hidden. | 1343 // it should be hidden. |
| 1344 should_normally_be_visible_ = !params.initially_hidden; | 1344 should_normally_be_visible_ = !params.initially_hidden; |
| 1345 | 1345 |
| 1346 // Either both routing ids can be given, or neither can be. | 1346 // The routing ids must either all be set or all be unset. |
| 1347 DCHECK((params.routing_id == MSG_ROUTING_NONE && | 1347 DCHECK((params.routing_id == MSG_ROUTING_NONE && |
| 1348 params.main_frame_routing_id == MSG_ROUTING_NONE) || | 1348 params.main_frame_routing_id == MSG_ROUTING_NONE && |
| 1349 params.main_frame_widget_routing_id == MSG_ROUTING_NONE) || |
| 1349 (params.routing_id != MSG_ROUTING_NONE && | 1350 (params.routing_id != MSG_ROUTING_NONE && |
| 1350 params.main_frame_routing_id != MSG_ROUTING_NONE)); | 1351 params.main_frame_routing_id != MSG_ROUTING_NONE && |
| 1351 GetRenderManager()->Init(params.browser_context, params.site_instance, | 1352 params.main_frame_widget_routing_id != MSG_ROUTING_NONE)); |
| 1352 params.routing_id, params.main_frame_routing_id, | 1353 |
| 1353 MSG_ROUTING_NONE); | 1354 scoped_refptr<SiteInstance> site_instance = params.site_instance; |
| 1355 if (!site_instance) |
| 1356 site_instance = SiteInstance::Create(params.browser_context); |
| 1357 |
| 1358 // A main RenderFrameHost always has a RenderWidgetHost, since it is always a |
| 1359 // local root by definition. |
| 1360 // TODO(avi): Once RenderViewHostImpl has-a RenderWidgetHostImpl, it will no |
| 1361 // longer be necessary to eagerly grab a routing ID for the view. |
| 1362 // https://crbug.com/545684 |
| 1363 int32 view_routing_id = params.routing_id; |
| 1364 int32 main_frame_widget_routing_id = params.main_frame_widget_routing_id; |
| 1365 if (main_frame_widget_routing_id == MSG_ROUTING_NONE) { |
| 1366 view_routing_id = main_frame_widget_routing_id = |
| 1367 site_instance->GetProcess()->GetNextRoutingID(); |
| 1368 } |
| 1369 |
| 1370 GetRenderManager()->Init(site_instance.get(), view_routing_id, |
| 1371 params.main_frame_routing_id, |
| 1372 main_frame_widget_routing_id); |
| 1354 frame_tree_.root()->SetFrameName(params.main_frame_name); | 1373 frame_tree_.root()->SetFrameName(params.main_frame_name); |
| 1355 | 1374 |
| 1356 WebContentsViewDelegate* delegate = | 1375 WebContentsViewDelegate* delegate = |
| 1357 GetContentClient()->browser()->GetWebContentsViewDelegate(this); | 1376 GetContentClient()->browser()->GetWebContentsViewDelegate(this); |
| 1358 | 1377 |
| 1359 if (browser_plugin_guest_ && | 1378 if (browser_plugin_guest_ && |
| 1360 !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 1379 !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { |
| 1361 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( | 1380 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( |
| 1362 this, delegate, &render_view_host_delegate_view_)); | 1381 this, delegate, &render_view_host_delegate_view_)); |
| 1363 | 1382 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 } | 1663 } |
| 1645 } | 1664 } |
| 1646 | 1665 |
| 1647 void WebContentsImpl::LostMouseLock() { | 1666 void WebContentsImpl::LostMouseLock() { |
| 1648 if (delegate_) | 1667 if (delegate_) |
| 1649 delegate_->LostMouseLock(); | 1668 delegate_->LostMouseLock(); |
| 1650 } | 1669 } |
| 1651 | 1670 |
| 1652 void WebContentsImpl::CreateNewWindow( | 1671 void WebContentsImpl::CreateNewWindow( |
| 1653 SiteInstance* source_site_instance, | 1672 SiteInstance* source_site_instance, |
| 1654 int route_id, | 1673 int32 route_id, |
| 1655 int main_frame_route_id, | 1674 int32 main_frame_route_id, |
| 1675 int32 main_frame_widget_route_id, |
| 1656 const ViewHostMsg_CreateWindow_Params& params, | 1676 const ViewHostMsg_CreateWindow_Params& params, |
| 1657 SessionStorageNamespace* session_storage_namespace) { | 1677 SessionStorageNamespace* session_storage_namespace) { |
| 1658 // We usually create the new window in the same BrowsingInstance (group of | 1678 // We usually create the new window in the same BrowsingInstance (group of |
| 1659 // script-related windows), by passing in the current SiteInstance. However, | 1679 // script-related windows), by passing in the current SiteInstance. However, |
| 1660 // if the opener is being suppressed (in a non-guest), we create a new | 1680 // if the opener is being suppressed (in a non-guest), we create a new |
| 1661 // SiteInstance in its own BrowsingInstance. | 1681 // SiteInstance in its own BrowsingInstance. |
| 1662 bool is_guest = BrowserPluginGuest::IsGuest(this); | 1682 bool is_guest = BrowserPluginGuest::IsGuest(this); |
| 1663 | 1683 |
| 1664 if (is_guest && BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 1684 if (is_guest && BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { |
| 1665 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> | 1685 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1704 site_instance->GetSiteURL()); | 1724 site_instance->GetSiteURL()); |
| 1705 StoragePartition* partition = BrowserContext::GetStoragePartition( | 1725 StoragePartition* partition = BrowserContext::GetStoragePartition( |
| 1706 GetBrowserContext(), site_instance.get()); | 1726 GetBrowserContext(), site_instance.get()); |
| 1707 DOMStorageContextWrapper* dom_storage_context = | 1727 DOMStorageContextWrapper* dom_storage_context = |
| 1708 static_cast<DOMStorageContextWrapper*>(partition->GetDOMStorageContext()); | 1728 static_cast<DOMStorageContextWrapper*>(partition->GetDOMStorageContext()); |
| 1709 SessionStorageNamespaceImpl* session_storage_namespace_impl = | 1729 SessionStorageNamespaceImpl* session_storage_namespace_impl = |
| 1710 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace); | 1730 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace); |
| 1711 CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context)); | 1731 CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context)); |
| 1712 | 1732 |
| 1713 if (delegate_ && | 1733 if (delegate_ && |
| 1714 !delegate_->ShouldCreateWebContents(this, | 1734 !delegate_->ShouldCreateWebContents( |
| 1715 route_id, | 1735 this, route_id, main_frame_route_id, main_frame_widget_route_id, |
| 1716 main_frame_route_id, | 1736 params.window_container_type, params.frame_name, params.target_url, |
| 1717 params.window_container_type, | 1737 partition_id, session_storage_namespace)) { |
| 1718 params.frame_name, | |
| 1719 params.target_url, | |
| 1720 partition_id, | |
| 1721 session_storage_namespace)) { | |
| 1722 if (route_id != MSG_ROUTING_NONE && | 1738 if (route_id != MSG_ROUTING_NONE && |
| 1723 !RenderViewHost::FromID(render_process_id, route_id)) { | 1739 !RenderViewHost::FromID(render_process_id, route_id)) { |
| 1724 // If the embedder didn't create a WebContents for this route, we need to | 1740 // If the embedder didn't create a WebContents for this route, we need to |
| 1725 // delete the RenderView that had already been created. | 1741 // delete the RenderView that had already been created. |
| 1726 Send(new ViewMsg_Close(route_id)); | 1742 Send(new ViewMsg_Close(route_id)); |
| 1727 } | 1743 } |
| 1728 GetRenderViewHost()->GetProcess()->ResumeRequestsForView(route_id); | 1744 GetRenderViewHost()->GetProcess()->ResumeRequestsForView(route_id); |
| 1729 GetRenderViewHost()->GetProcess()->ResumeRequestsForView( | 1745 GetRenderViewHost()->GetProcess()->ResumeRequestsForView( |
| 1730 main_frame_route_id); | 1746 main_frame_route_id); |
| 1747 GetRenderViewHost()->GetProcess()->ResumeRequestsForView( |
| 1748 main_frame_widget_route_id); |
| 1731 return; | 1749 return; |
| 1732 } | 1750 } |
| 1733 | 1751 |
| 1734 // Create the new web contents. This will automatically create the new | 1752 // Create the new web contents. This will automatically create the new |
| 1735 // WebContentsView. In the future, we may want to create the view separately. | 1753 // WebContentsView. In the future, we may want to create the view separately. |
| 1736 CreateParams create_params(GetBrowserContext(), site_instance.get()); | 1754 CreateParams create_params(GetBrowserContext(), site_instance.get()); |
| 1737 create_params.routing_id = route_id; | 1755 create_params.routing_id = route_id; |
| 1738 create_params.main_frame_routing_id = main_frame_route_id; | 1756 create_params.main_frame_routing_id = main_frame_route_id; |
| 1757 create_params.main_frame_widget_routing_id = main_frame_widget_route_id; |
| 1739 create_params.main_frame_name = params.frame_name; | 1758 create_params.main_frame_name = params.frame_name; |
| 1740 create_params.opener_render_process_id = render_process_id; | 1759 create_params.opener_render_process_id = render_process_id; |
| 1741 create_params.opener_render_frame_id = params.opener_render_frame_id; | 1760 create_params.opener_render_frame_id = params.opener_render_frame_id; |
| 1742 create_params.opener_suppressed = params.opener_suppressed; | 1761 create_params.opener_suppressed = params.opener_suppressed; |
| 1743 if (params.disposition == NEW_BACKGROUND_TAB) | 1762 if (params.disposition == NEW_BACKGROUND_TAB) |
| 1744 create_params.initially_hidden = true; | 1763 create_params.initially_hidden = true; |
| 1745 create_params.renderer_initiated_creation = | 1764 create_params.renderer_initiated_creation = |
| 1746 main_frame_route_id != MSG_ROUTING_NONE; | 1765 main_frame_route_id != MSG_ROUTING_NONE; |
| 1747 | 1766 |
| 1748 WebContentsImpl* new_contents = NULL; | 1767 WebContentsImpl* new_contents = NULL; |
| (...skipping 2891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4640 return NULL; | 4659 return NULL; |
| 4641 } | 4660 } |
| 4642 | 4661 |
| 4643 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4662 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4644 force_disable_overscroll_content_ = force_disable; | 4663 force_disable_overscroll_content_ = force_disable; |
| 4645 if (view_) | 4664 if (view_) |
| 4646 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4665 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4647 } | 4666 } |
| 4648 | 4667 |
| 4649 } // namespace content | 4668 } // namespace content |
| OLD | NEW |