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_t view_routing_id = params.routing_id; |
| 1364 int32_t 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 } | 1673 } |
1655 } | 1674 } |
1656 | 1675 |
1657 void WebContentsImpl::LostMouseLock() { | 1676 void WebContentsImpl::LostMouseLock() { |
1658 if (delegate_) | 1677 if (delegate_) |
1659 delegate_->LostMouseLock(); | 1678 delegate_->LostMouseLock(); |
1660 } | 1679 } |
1661 | 1680 |
1662 void WebContentsImpl::CreateNewWindow( | 1681 void WebContentsImpl::CreateNewWindow( |
1663 SiteInstance* source_site_instance, | 1682 SiteInstance* source_site_instance, |
1664 int route_id, | 1683 int32_t route_id, |
1665 int main_frame_route_id, | 1684 int32_t main_frame_route_id, |
| 1685 int32_t main_frame_widget_route_id, |
1666 const ViewHostMsg_CreateWindow_Params& params, | 1686 const ViewHostMsg_CreateWindow_Params& params, |
1667 SessionStorageNamespace* session_storage_namespace) { | 1687 SessionStorageNamespace* session_storage_namespace) { |
1668 // We usually create the new window in the same BrowsingInstance (group of | 1688 // We usually create the new window in the same BrowsingInstance (group of |
1669 // script-related windows), by passing in the current SiteInstance. However, | 1689 // script-related windows), by passing in the current SiteInstance. However, |
1670 // if the opener is being suppressed (in a non-guest), we create a new | 1690 // if the opener is being suppressed (in a non-guest), we create a new |
1671 // SiteInstance in its own BrowsingInstance. | 1691 // SiteInstance in its own BrowsingInstance. |
1672 bool is_guest = BrowserPluginGuest::IsGuest(this); | 1692 bool is_guest = BrowserPluginGuest::IsGuest(this); |
1673 | 1693 |
1674 if (is_guest && BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 1694 if (is_guest && BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { |
1675 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> | 1695 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 site_instance->GetSiteURL()); | 1734 site_instance->GetSiteURL()); |
1715 StoragePartition* partition = BrowserContext::GetStoragePartition( | 1735 StoragePartition* partition = BrowserContext::GetStoragePartition( |
1716 GetBrowserContext(), site_instance.get()); | 1736 GetBrowserContext(), site_instance.get()); |
1717 DOMStorageContextWrapper* dom_storage_context = | 1737 DOMStorageContextWrapper* dom_storage_context = |
1718 static_cast<DOMStorageContextWrapper*>(partition->GetDOMStorageContext()); | 1738 static_cast<DOMStorageContextWrapper*>(partition->GetDOMStorageContext()); |
1719 SessionStorageNamespaceImpl* session_storage_namespace_impl = | 1739 SessionStorageNamespaceImpl* session_storage_namespace_impl = |
1720 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace); | 1740 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace); |
1721 CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context)); | 1741 CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context)); |
1722 | 1742 |
1723 if (delegate_ && | 1743 if (delegate_ && |
1724 !delegate_->ShouldCreateWebContents(this, | 1744 !delegate_->ShouldCreateWebContents( |
1725 route_id, | 1745 this, route_id, main_frame_route_id, main_frame_widget_route_id, |
1726 main_frame_route_id, | 1746 params.window_container_type, params.frame_name, params.target_url, |
1727 params.window_container_type, | 1747 partition_id, session_storage_namespace)) { |
1728 params.frame_name, | |
1729 params.target_url, | |
1730 partition_id, | |
1731 session_storage_namespace)) { | |
1732 if (route_id != MSG_ROUTING_NONE && | 1748 if (route_id != MSG_ROUTING_NONE && |
1733 !RenderViewHost::FromID(render_process_id, route_id)) { | 1749 !RenderViewHost::FromID(render_process_id, route_id)) { |
1734 // If the embedder didn't create a WebContents for this route, we need to | 1750 // If the embedder didn't create a WebContents for this route, we need to |
1735 // delete the RenderView that had already been created. | 1751 // delete the RenderView that had already been created. |
1736 Send(new ViewMsg_Close(route_id)); | 1752 Send(new ViewMsg_Close(route_id)); |
1737 } | 1753 } |
1738 GetRenderViewHost()->GetProcess()->ResumeRequestsForView(route_id); | 1754 GetRenderViewHost()->GetProcess()->ResumeRequestsForView(route_id); |
1739 GetRenderViewHost()->GetProcess()->ResumeRequestsForView( | 1755 GetRenderViewHost()->GetProcess()->ResumeRequestsForView( |
1740 main_frame_route_id); | 1756 main_frame_route_id); |
| 1757 GetRenderViewHost()->GetProcess()->ResumeRequestsForView( |
| 1758 main_frame_widget_route_id); |
1741 return; | 1759 return; |
1742 } | 1760 } |
1743 | 1761 |
1744 // Create the new web contents. This will automatically create the new | 1762 // Create the new web contents. This will automatically create the new |
1745 // WebContentsView. In the future, we may want to create the view separately. | 1763 // WebContentsView. In the future, we may want to create the view separately. |
1746 CreateParams create_params(GetBrowserContext(), site_instance.get()); | 1764 CreateParams create_params(GetBrowserContext(), site_instance.get()); |
1747 create_params.routing_id = route_id; | 1765 create_params.routing_id = route_id; |
1748 create_params.main_frame_routing_id = main_frame_route_id; | 1766 create_params.main_frame_routing_id = main_frame_route_id; |
| 1767 create_params.main_frame_widget_routing_id = main_frame_widget_route_id; |
1749 create_params.main_frame_name = params.frame_name; | 1768 create_params.main_frame_name = params.frame_name; |
1750 create_params.opener_render_process_id = render_process_id; | 1769 create_params.opener_render_process_id = render_process_id; |
1751 create_params.opener_render_frame_id = params.opener_render_frame_id; | 1770 create_params.opener_render_frame_id = params.opener_render_frame_id; |
1752 create_params.opener_suppressed = params.opener_suppressed; | 1771 create_params.opener_suppressed = params.opener_suppressed; |
1753 if (params.disposition == NEW_BACKGROUND_TAB) | 1772 if (params.disposition == NEW_BACKGROUND_TAB) |
1754 create_params.initially_hidden = true; | 1773 create_params.initially_hidden = true; |
1755 create_params.renderer_initiated_creation = | 1774 create_params.renderer_initiated_creation = |
1756 main_frame_route_id != MSG_ROUTING_NONE; | 1775 main_frame_route_id != MSG_ROUTING_NONE; |
1757 | 1776 |
1758 WebContentsImpl* new_contents = NULL; | 1777 WebContentsImpl* new_contents = NULL; |
(...skipping 2891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4650 return NULL; | 4669 return NULL; |
4651 } | 4670 } |
4652 | 4671 |
4653 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4672 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4654 force_disable_overscroll_content_ = force_disable; | 4673 force_disable_overscroll_content_ = force_disable; |
4655 if (view_) | 4674 if (view_) |
4656 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4675 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4657 } | 4676 } |
4658 | 4677 |
4659 } // namespace content | 4678 } // namespace content |
OLD | NEW |