Chromium Code Reviews| 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 24 matching lines...) Expand all Loading... | |
| 35 #include "content/browser/download/mhtml_generation_manager.h" | 35 #include "content/browser/download/mhtml_generation_manager.h" |
| 36 #include "content/browser/download/save_package.h" | 36 #include "content/browser/download/save_package.h" |
| 37 #include "content/browser/frame_host/cross_process_frame_connector.h" | 37 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 38 #include "content/browser/frame_host/interstitial_page_impl.h" | 38 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 39 #include "content/browser/frame_host/navigation_entry_impl.h" | 39 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 40 #include "content/browser/frame_host/navigation_handle_impl.h" | 40 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 41 #include "content/browser/frame_host/navigator_impl.h" | 41 #include "content/browser/frame_host/navigator_impl.h" |
| 42 #include "content/browser/frame_host/render_frame_host_impl.h" | 42 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 43 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 43 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
| 44 #include "content/browser/geolocation/geolocation_service_context.h" | 44 #include "content/browser/geolocation/geolocation_service_context.h" |
| 45 #include "content/browser/gpu/gpu_surface_tracker.h" | |
| 45 #include "content/browser/host_zoom_map_impl.h" | 46 #include "content/browser/host_zoom_map_impl.h" |
| 46 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 47 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 47 #include "content/browser/manifest/manifest_manager_host.h" | 48 #include "content/browser/manifest/manifest_manager_host.h" |
| 48 #include "content/browser/media/audio_stream_monitor.h" | 49 #include "content/browser/media/audio_stream_monitor.h" |
| 49 #include "content/browser/media/capture/web_contents_audio_muter.h" | 50 #include "content/browser/media/capture/web_contents_audio_muter.h" |
| 50 #include "content/browser/message_port_message_filter.h" | 51 #include "content/browser/message_port_message_filter.h" |
| 51 #include "content/browser/plugin_content_origin_whitelist.h" | 52 #include "content/browser/plugin_content_origin_whitelist.h" |
| 52 #include "content/browser/power_save_blocker_impl.h" | 53 #include "content/browser/power_save_blocker_impl.h" |
| 53 #include "content/browser/renderer_host/render_process_host_impl.h" | 54 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 54 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 55 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
| (...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1324 WebContents* WebContentsImpl::GetWebContents() { | 1325 WebContents* WebContentsImpl::GetWebContents() { |
| 1325 return this; | 1326 return this; |
| 1326 } | 1327 } |
| 1327 | 1328 |
| 1328 void WebContentsImpl::Init(const WebContents::CreateParams& params) { | 1329 void WebContentsImpl::Init(const WebContents::CreateParams& params) { |
| 1329 // This is set before initializing the render manager since | 1330 // This is set before initializing the render manager since |
| 1330 // RenderFrameHostManager::Init calls back into us via its delegate to ask if | 1331 // RenderFrameHostManager::Init calls back into us via its delegate to ask if |
| 1331 // it should be hidden. | 1332 // it should be hidden. |
| 1332 should_normally_be_visible_ = !params.initially_hidden; | 1333 should_normally_be_visible_ = !params.initially_hidden; |
| 1333 | 1334 |
| 1334 // Either both routing ids can be given, or neither can be. | 1335 // The routing ids / surface id must either all be set or all be unset. |
| 1335 DCHECK((params.routing_id == MSG_ROUTING_NONE && | 1336 DCHECK((params.routing_id == MSG_ROUTING_NONE && |
| 1336 params.main_frame_routing_id == MSG_ROUTING_NONE) || | 1337 params.main_frame_routing_id == MSG_ROUTING_NONE && |
| 1338 params.main_frame_widget_routing_id == MSG_ROUTING_NONE && | |
| 1339 params.surface_id == 0) || | |
| 1337 (params.routing_id != MSG_ROUTING_NONE && | 1340 (params.routing_id != MSG_ROUTING_NONE && |
| 1338 params.main_frame_routing_id != MSG_ROUTING_NONE)); | 1341 params.main_frame_routing_id != MSG_ROUTING_NONE && |
| 1339 GetRenderManager()->Init(params.browser_context, params.site_instance, | 1342 params.main_frame_widget_routing_id != MSG_ROUTING_NONE && |
| 1340 params.routing_id, params.main_frame_routing_id, | 1343 params.surface_id != 0)); |
| 1341 MSG_ROUTING_NONE, 0 /* surface_id */); | 1344 |
| 1345 // TODO(dcheng): Perhaps |params| should be bassed by value rather than by | |
| 1346 // reference. That way, the members can be changed in-place, and other code in | |
| 1347 // this block won't accidentally use sentinel values. | |
|
ncarter (slow)
2015/09/03 20:24:37
I'm not totally sold on the content of the TODO --
dcheng
2015/09/03 21:29:24
TODO removed.
| |
| 1348 scoped_refptr<SiteInstance> site_instance = params.site_instance; | |
| 1349 if (!site_instance) | |
| 1350 site_instance = SiteInstance::Create(params.browser_context); | |
| 1351 | |
| 1352 // A main RenderFrameHost always has a RenderWidgetHost, since it is always a | |
| 1353 // local root by definition. | |
| 1354 int32 main_frame_widget_routing_id = params.main_frame_widget_routing_id; | |
| 1355 int32 surface_id = params.surface_id; | |
| 1356 if (main_frame_widget_routing_id == MSG_ROUTING_NONE) { | |
| 1357 main_frame_widget_routing_id = | |
| 1358 site_instance->GetProcess()->GetNextRoutingID(); | |
| 1359 surface_id = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( | |
| 1360 site_instance->GetProcess()->GetID(), main_frame_widget_routing_id); | |
| 1361 } | |
| 1362 | |
| 1363 GetRenderManager()->Init(site_instance.get(), params.routing_id, | |
| 1364 params.main_frame_routing_id, | |
| 1365 main_frame_widget_routing_id, surface_id); | |
| 1342 frame_tree_.root()->SetFrameName(params.main_frame_name); | 1366 frame_tree_.root()->SetFrameName(params.main_frame_name); |
| 1343 | 1367 |
| 1344 WebContentsViewDelegate* delegate = | 1368 WebContentsViewDelegate* delegate = |
| 1345 GetContentClient()->browser()->GetWebContentsViewDelegate(this); | 1369 GetContentClient()->browser()->GetWebContentsViewDelegate(this); |
| 1346 | 1370 |
| 1347 if (browser_plugin_guest_ && | 1371 if (browser_plugin_guest_ && |
| 1348 !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 1372 !BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { |
| 1349 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( | 1373 scoped_ptr<WebContentsView> platform_view(CreateWebContentsView( |
| 1350 this, delegate, &render_view_host_delegate_view_)); | 1374 this, delegate, &render_view_host_delegate_view_)); |
| 1351 | 1375 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1637 } | 1661 } |
| 1638 } | 1662 } |
| 1639 | 1663 |
| 1640 void WebContentsImpl::LostMouseLock() { | 1664 void WebContentsImpl::LostMouseLock() { |
| 1641 if (delegate_) | 1665 if (delegate_) |
| 1642 delegate_->LostMouseLock(); | 1666 delegate_->LostMouseLock(); |
| 1643 } | 1667 } |
| 1644 | 1668 |
| 1645 void WebContentsImpl::CreateNewWindow( | 1669 void WebContentsImpl::CreateNewWindow( |
| 1646 SiteInstance* source_site_instance, | 1670 SiteInstance* source_site_instance, |
| 1647 int route_id, | 1671 int32 route_id, |
| 1648 int main_frame_route_id, | 1672 int32 main_frame_route_id, |
| 1673 int32 main_frame_widget_route_id, | |
| 1674 int32 surface_id, | |
| 1649 const ViewHostMsg_CreateWindow_Params& params, | 1675 const ViewHostMsg_CreateWindow_Params& params, |
| 1650 SessionStorageNamespace* session_storage_namespace) { | 1676 SessionStorageNamespace* session_storage_namespace) { |
| 1651 // We usually create the new window in the same BrowsingInstance (group of | 1677 // We usually create the new window in the same BrowsingInstance (group of |
| 1652 // script-related windows), by passing in the current SiteInstance. However, | 1678 // script-related windows), by passing in the current SiteInstance. However, |
| 1653 // if the opener is being suppressed (in a non-guest), we create a new | 1679 // if the opener is being suppressed (in a non-guest), we create a new |
| 1654 // SiteInstance in its own BrowsingInstance. | 1680 // SiteInstance in its own BrowsingInstance. |
| 1655 bool is_guest = BrowserPluginGuest::IsGuest(this); | 1681 bool is_guest = BrowserPluginGuest::IsGuest(this); |
| 1656 | 1682 |
| 1657 if (is_guest && BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 1683 if (is_guest && BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { |
| 1658 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> | 1684 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1697 site_instance->GetSiteURL()); | 1723 site_instance->GetSiteURL()); |
| 1698 StoragePartition* partition = BrowserContext::GetStoragePartition( | 1724 StoragePartition* partition = BrowserContext::GetStoragePartition( |
| 1699 GetBrowserContext(), site_instance.get()); | 1725 GetBrowserContext(), site_instance.get()); |
| 1700 DOMStorageContextWrapper* dom_storage_context = | 1726 DOMStorageContextWrapper* dom_storage_context = |
| 1701 static_cast<DOMStorageContextWrapper*>(partition->GetDOMStorageContext()); | 1727 static_cast<DOMStorageContextWrapper*>(partition->GetDOMStorageContext()); |
| 1702 SessionStorageNamespaceImpl* session_storage_namespace_impl = | 1728 SessionStorageNamespaceImpl* session_storage_namespace_impl = |
| 1703 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace); | 1729 static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace); |
| 1704 CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context)); | 1730 CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context)); |
| 1705 | 1731 |
| 1706 if (delegate_ && | 1732 if (delegate_ && |
| 1707 !delegate_->ShouldCreateWebContents(this, | 1733 !delegate_->ShouldCreateWebContents( |
| 1708 route_id, | 1734 this, route_id, main_frame_route_id, main_frame_widget_route_id, |
| 1709 main_frame_route_id, | 1735 surface_id, params.window_container_type, params.frame_name, |
| 1710 params.window_container_type, | 1736 params.target_url, partition_id, session_storage_namespace)) { |
| 1711 params.frame_name, | |
| 1712 params.target_url, | |
| 1713 partition_id, | |
| 1714 session_storage_namespace)) { | |
| 1715 if (route_id != MSG_ROUTING_NONE && | 1737 if (route_id != MSG_ROUTING_NONE && |
| 1716 !RenderViewHost::FromID(render_process_id, route_id)) { | 1738 !RenderViewHost::FromID(render_process_id, route_id)) { |
| 1717 // If the embedder didn't create a WebContents for this route, we need to | 1739 // If the embedder didn't create a WebContents for this route, we need to |
| 1718 // delete the RenderView that had already been created. | 1740 // delete the RenderView that had already been created. |
| 1719 Send(new ViewMsg_Close(route_id)); | 1741 Send(new ViewMsg_Close(route_id)); |
| 1720 } | 1742 } |
| 1721 GetRenderViewHost()->GetProcess()->ResumeRequestsForView(route_id); | 1743 GetRenderViewHost()->GetProcess()->ResumeRequestsForView(route_id); |
| 1722 GetRenderViewHost()->GetProcess()->ResumeRequestsForView( | 1744 GetRenderViewHost()->GetProcess()->ResumeRequestsForView( |
| 1723 main_frame_route_id); | 1745 main_frame_route_id); |
| 1746 GetRenderViewHost()->GetProcess()->ResumeRequestsForView( | |
| 1747 main_frame_widget_route_id); | |
| 1724 return; | 1748 return; |
| 1725 } | 1749 } |
| 1726 | 1750 |
| 1727 // Create the new web contents. This will automatically create the new | 1751 // Create the new web contents. This will automatically create the new |
| 1728 // WebContentsView. In the future, we may want to create the view separately. | 1752 // WebContentsView. In the future, we may want to create the view separately. |
| 1729 CreateParams create_params(GetBrowserContext(), site_instance.get()); | 1753 CreateParams create_params(GetBrowserContext(), site_instance.get()); |
| 1730 create_params.routing_id = route_id; | 1754 create_params.routing_id = route_id; |
| 1731 create_params.main_frame_routing_id = main_frame_route_id; | 1755 create_params.main_frame_routing_id = main_frame_route_id; |
| 1756 create_params.main_frame_widget_routing_id = main_frame_widget_route_id; | |
| 1732 create_params.main_frame_name = params.frame_name; | 1757 create_params.main_frame_name = params.frame_name; |
| 1758 create_params.surface_id = surface_id; | |
| 1733 create_params.opener_render_process_id = render_process_id; | 1759 create_params.opener_render_process_id = render_process_id; |
| 1734 create_params.opener_render_frame_id = params.opener_render_frame_id; | 1760 create_params.opener_render_frame_id = params.opener_render_frame_id; |
| 1735 create_params.opener_suppressed = params.opener_suppressed; | 1761 create_params.opener_suppressed = params.opener_suppressed; |
| 1736 if (params.disposition == NEW_BACKGROUND_TAB) | 1762 if (params.disposition == NEW_BACKGROUND_TAB) |
| 1737 create_params.initially_hidden = true; | 1763 create_params.initially_hidden = true; |
| 1738 create_params.renderer_initiated_creation = | 1764 create_params.renderer_initiated_creation = |
| 1739 main_frame_route_id != MSG_ROUTING_NONE; | 1765 main_frame_route_id != MSG_ROUTING_NONE; |
| 1740 | 1766 |
| 1741 WebContentsImpl* new_contents = NULL; | 1767 WebContentsImpl* new_contents = NULL; |
| 1742 if (!is_guest) { | 1768 if (!is_guest) { |
| (...skipping 2891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4634 return NULL; | 4660 return NULL; |
| 4635 } | 4661 } |
| 4636 | 4662 |
| 4637 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4663 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4638 force_disable_overscroll_content_ = force_disable; | 4664 force_disable_overscroll_content_ = force_disable; |
| 4639 if (view_) | 4665 if (view_) |
| 4640 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4666 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4641 } | 4667 } |
| 4642 | 4668 |
| 4643 } // namespace content | 4669 } // namespace content |
| OLD | NEW |