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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 ->render_manager() | 201 ->render_manager() |
| 202 ->GetRenderWidgetHostView(); | 202 ->GetRenderWidgetHostView(); |
| 203 set->insert(rwhv); | 203 set->insert(rwhv); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void SetAccessibilityModeOnFrame(AccessibilityMode mode, | 206 void SetAccessibilityModeOnFrame(AccessibilityMode mode, |
| 207 RenderFrameHost* frame_host) { | 207 RenderFrameHost* frame_host) { |
| 208 static_cast<RenderFrameHostImpl*>(frame_host)->SetAccessibilityMode(mode); | 208 static_cast<RenderFrameHostImpl*>(frame_host)->SetAccessibilityMode(mode); |
| 209 } | 209 } |
| 210 | 210 |
| 211 bool FindMatchingProcess(int render_process_id, | |
|
Charlie Reis
2015/07/09 23:42:51
nit: Put this up below CollectSites.
alexmos
2015/07/10 18:35:00
Done.
| |
| 212 bool* did_match_process, | |
| 213 FrameTreeNode* node) { | |
| 214 if (node->current_frame_host()->GetProcess()->GetID() == render_process_id) { | |
| 215 *did_match_process = true; | |
| 216 return false; | |
| 217 } | |
| 218 return true; | |
| 219 } | |
| 220 | |
| 211 } // namespace | 221 } // namespace |
| 212 | 222 |
| 213 WebContents* WebContents::Create(const WebContents::CreateParams& params) { | 223 WebContents* WebContents::Create(const WebContents::CreateParams& params) { |
| 214 FrameTreeNode* opener_node = nullptr; | 224 FrameTreeNode* opener_node = nullptr; |
| 215 if (params.opener_render_frame_id != MSG_ROUTING_NONE) { | 225 if (params.opener_render_frame_id != MSG_ROUTING_NONE) { |
| 216 RenderFrameHostImpl* opener_rfh = RenderFrameHostImpl::FromID( | 226 RenderFrameHostImpl* opener_rfh = RenderFrameHostImpl::FromID( |
| 217 params.opener_render_process_id, params.opener_render_frame_id); | 227 params.opener_render_process_id, params.opener_render_frame_id); |
| 218 if (opener_rfh) | 228 if (opener_rfh) |
| 219 opener_node = opener_rfh->frame_tree_node(); | 229 opener_node = opener_rfh->frame_tree_node(); |
| 220 } | 230 } |
| (...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1598 GotResponseToLockMouseRequest(false); | 1608 GotResponseToLockMouseRequest(false); |
| 1599 } | 1609 } |
| 1600 } | 1610 } |
| 1601 | 1611 |
| 1602 void WebContentsImpl::LostMouseLock() { | 1612 void WebContentsImpl::LostMouseLock() { |
| 1603 if (delegate_) | 1613 if (delegate_) |
| 1604 delegate_->LostMouseLock(); | 1614 delegate_->LostMouseLock(); |
| 1605 } | 1615 } |
| 1606 | 1616 |
| 1607 void WebContentsImpl::CreateNewWindow( | 1617 void WebContentsImpl::CreateNewWindow( |
| 1608 int render_process_id, | 1618 SiteInstance* source_site_instance, |
| 1609 int route_id, | 1619 int route_id, |
| 1610 int main_frame_route_id, | 1620 int main_frame_route_id, |
| 1611 const ViewHostMsg_CreateWindow_Params& params, | 1621 const ViewHostMsg_CreateWindow_Params& params, |
| 1612 SessionStorageNamespace* session_storage_namespace) { | 1622 SessionStorageNamespace* session_storage_namespace) { |
| 1613 // We usually create the new window in the same BrowsingInstance (group of | 1623 // We usually create the new window in the same BrowsingInstance (group of |
| 1614 // script-related windows), by passing in the current SiteInstance. However, | 1624 // script-related windows), by passing in the current SiteInstance. However, |
| 1615 // if the opener is being suppressed (in a non-guest), we create a new | 1625 // if the opener is being suppressed (in a non-guest), we create a new |
| 1616 // SiteInstance in its own BrowsingInstance. | 1626 // SiteInstance in its own BrowsingInstance. |
| 1617 bool is_guest = BrowserPluginGuest::IsGuest(this); | 1627 bool is_guest = BrowserPluginGuest::IsGuest(this); |
| 1618 | 1628 |
| 1619 if (is_guest && | 1629 if (is_guest && |
| 1620 base::CommandLine::ForCurrentProcess()->HasSwitch( | 1630 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1621 switches::kSitePerProcess)) { | 1631 switches::kSitePerProcess)) { |
| 1622 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> | 1632 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> |
| 1623 // yet. | 1633 // yet. |
| 1624 NOTREACHED(); | 1634 NOTREACHED(); |
| 1625 } | 1635 } |
| 1626 | 1636 |
| 1627 // If the opener is to be suppressed, the new window can be in any process. | 1637 // If the opener is to be suppressed, the new window can be in any process. |
| 1628 // Since routing ids are process specific, we must not have one passed in | 1638 // Since routing ids are process specific, we must not have one passed in |
| 1629 // as argument here. | 1639 // as argument here. |
| 1630 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); | 1640 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); |
| 1631 | 1641 |
| 1632 scoped_refptr<SiteInstance> site_instance = | 1642 scoped_refptr<SiteInstance> site_instance = |
| 1633 params.opener_suppressed && !is_guest ? | 1643 params.opener_suppressed && !is_guest |
| 1634 SiteInstance::CreateForURL(GetBrowserContext(), params.target_url) : | 1644 ? SiteInstance::CreateForURL(GetBrowserContext(), params.target_url) |
| 1635 GetSiteInstance(); | 1645 : source_site_instance; |
| 1636 | 1646 |
| 1637 // A message to create a new window can only come from the active process for | 1647 // A message to create a new window can only come from a process for a frame |
| 1638 // this WebContentsImpl instance. If any other process sends the request, | 1648 // in this WebContents' FrameTree. If any other process sends the request, it |
| 1639 // it is invalid and the process must be terminated. | 1649 // is invalid and the process must be terminated. |
| 1640 if (GetRenderProcessHost()->GetID() != render_process_id) { | 1650 int render_process_id = source_site_instance->GetProcess()->GetID(); |
| 1641 RenderProcessHost* rph = RenderProcessHost::FromID(render_process_id); | 1651 bool did_match_process = false; |
| 1652 frame_tree_.ForEach( | |
| 1653 base::Bind(&FindMatchingProcess, render_process_id, &did_match_process)); | |
| 1654 if (!did_match_process) { | |
| 1655 RenderProcessHost* rph = source_site_instance->GetProcess(); | |
| 1642 base::ProcessHandle process_handle = rph->GetHandle(); | 1656 base::ProcessHandle process_handle = rph->GetHandle(); |
| 1643 if (process_handle != base::kNullProcessHandle) { | 1657 if (process_handle != base::kNullProcessHandle) { |
| 1644 RecordAction( | 1658 RecordAction( |
| 1645 base::UserMetricsAction("Terminate_ProcessMismatch_CreateNewWindow")); | 1659 base::UserMetricsAction("Terminate_ProcessMismatch_CreateNewWindow")); |
| 1646 rph->Shutdown(RESULT_CODE_KILLED, false); | 1660 rph->Shutdown(RESULT_CODE_KILLED, false); |
| 1647 } | 1661 } |
| 1648 return; | 1662 return; |
| 1649 } | 1663 } |
| 1650 | 1664 |
| 1651 // We must assign the SessionStorageNamespace before calling Init(). | 1665 // We must assign the SessionStorageNamespace before calling Init(). |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1683 main_frame_route_id); | 1697 main_frame_route_id); |
| 1684 return; | 1698 return; |
| 1685 } | 1699 } |
| 1686 | 1700 |
| 1687 // Create the new web contents. This will automatically create the new | 1701 // Create the new web contents. This will automatically create the new |
| 1688 // WebContentsView. In the future, we may want to create the view separately. | 1702 // WebContentsView. In the future, we may want to create the view separately. |
| 1689 CreateParams create_params(GetBrowserContext(), site_instance.get()); | 1703 CreateParams create_params(GetBrowserContext(), site_instance.get()); |
| 1690 create_params.routing_id = route_id; | 1704 create_params.routing_id = route_id; |
| 1691 create_params.main_frame_routing_id = main_frame_route_id; | 1705 create_params.main_frame_routing_id = main_frame_route_id; |
| 1692 create_params.main_frame_name = params.frame_name; | 1706 create_params.main_frame_name = params.frame_name; |
| 1693 create_params.opener_render_process_id = GetRenderProcessHost()->GetID(); | 1707 create_params.opener_render_process_id = render_process_id; |
| 1694 create_params.opener_render_frame_id = params.opener_render_frame_id; | 1708 create_params.opener_render_frame_id = params.opener_render_frame_id; |
| 1695 create_params.opener_suppressed = params.opener_suppressed; | 1709 create_params.opener_suppressed = params.opener_suppressed; |
| 1696 if (params.disposition == NEW_BACKGROUND_TAB) | 1710 if (params.disposition == NEW_BACKGROUND_TAB) |
| 1697 create_params.initially_hidden = true; | 1711 create_params.initially_hidden = true; |
| 1698 create_params.renderer_initiated_creation = | 1712 create_params.renderer_initiated_creation = |
| 1699 main_frame_route_id != MSG_ROUTING_NONE; | 1713 main_frame_route_id != MSG_ROUTING_NONE; |
| 1700 | 1714 |
| 1701 WebContentsImpl* new_contents = NULL; | 1715 WebContentsImpl* new_contents = NULL; |
| 1702 if (!is_guest) { | 1716 if (!is_guest) { |
| 1703 create_params.context = view_->GetNativeView(); | 1717 create_params.context = view_->GetNativeView(); |
| (...skipping 2772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4476 player_map->erase(it); | 4490 player_map->erase(it); |
| 4477 } | 4491 } |
| 4478 | 4492 |
| 4479 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4493 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4480 force_disable_overscroll_content_ = force_disable; | 4494 force_disable_overscroll_content_ = force_disable; |
| 4481 if (view_) | 4495 if (view_) |
| 4482 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4496 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4483 } | 4497 } |
| 4484 | 4498 |
| 4485 } // namespace content | 4499 } // namespace content |
| OLD | NEW |