Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(577)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1224363002: OOPIF: Fix window.open to work from frames with remote parent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove internal:: from ToRenderFrameHost Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 166
167 // Helper function for retrieving all the sites in a frame tree. 167 // Helper function for retrieving all the sites in a frame tree.
168 bool CollectSites(BrowserContext* context, 168 bool CollectSites(BrowserContext* context,
169 std::set<GURL>* sites, 169 std::set<GURL>* sites,
170 FrameTreeNode* node) { 170 FrameTreeNode* node) {
171 sites->insert(SiteInstance::GetSiteForURL(context, node->current_url())); 171 sites->insert(SiteInstance::GetSiteForURL(context, node->current_url()));
172 return true; 172 return true;
173 } 173 }
174 174
175 bool FindMatchingProcess(int render_process_id,
176 bool* did_match_process,
177 FrameTreeNode* node) {
178 if (node->current_frame_host()->GetProcess()->GetID() == render_process_id) {
179 *did_match_process = true;
180 return false;
181 }
182 return true;
183 }
184
175 bool ForEachFrameInternal( 185 bool ForEachFrameInternal(
176 const base::Callback<void(RenderFrameHost*)>& on_frame, 186 const base::Callback<void(RenderFrameHost*)>& on_frame,
177 FrameTreeNode* node) { 187 FrameTreeNode* node) {
178 on_frame.Run(node->current_frame_host()); 188 on_frame.Run(node->current_frame_host());
179 return true; 189 return true;
180 } 190 }
181 191
182 bool ForEachPendingFrameInternal( 192 bool ForEachPendingFrameInternal(
183 const base::Callback<void(RenderFrameHost*)>& on_frame, 193 const base::Callback<void(RenderFrameHost*)>& on_frame,
184 FrameTreeNode* node) { 194 FrameTreeNode* node) {
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 GotResponseToLockMouseRequest(false); 1610 GotResponseToLockMouseRequest(false);
1601 } 1611 }
1602 } 1612 }
1603 1613
1604 void WebContentsImpl::LostMouseLock() { 1614 void WebContentsImpl::LostMouseLock() {
1605 if (delegate_) 1615 if (delegate_)
1606 delegate_->LostMouseLock(); 1616 delegate_->LostMouseLock();
1607 } 1617 }
1608 1618
1609 void WebContentsImpl::CreateNewWindow( 1619 void WebContentsImpl::CreateNewWindow(
1610 int render_process_id, 1620 SiteInstance* source_site_instance,
1611 int route_id, 1621 int route_id,
1612 int main_frame_route_id, 1622 int main_frame_route_id,
1613 const ViewHostMsg_CreateWindow_Params& params, 1623 const ViewHostMsg_CreateWindow_Params& params,
1614 SessionStorageNamespace* session_storage_namespace) { 1624 SessionStorageNamespace* session_storage_namespace) {
1615 // We usually create the new window in the same BrowsingInstance (group of 1625 // We usually create the new window in the same BrowsingInstance (group of
1616 // script-related windows), by passing in the current SiteInstance. However, 1626 // script-related windows), by passing in the current SiteInstance. However,
1617 // if the opener is being suppressed (in a non-guest), we create a new 1627 // if the opener is being suppressed (in a non-guest), we create a new
1618 // SiteInstance in its own BrowsingInstance. 1628 // SiteInstance in its own BrowsingInstance.
1619 bool is_guest = BrowserPluginGuest::IsGuest(this); 1629 bool is_guest = BrowserPluginGuest::IsGuest(this);
1620 1630
1621 if (is_guest && 1631 if (is_guest &&
1622 base::CommandLine::ForCurrentProcess()->HasSwitch( 1632 base::CommandLine::ForCurrentProcess()->HasSwitch(
1623 switches::kSitePerProcess)) { 1633 switches::kSitePerProcess)) {
1624 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview> 1634 // TODO(lazyboy): CreateNewWindow doesn't work for OOPIF-based <webview>
1625 // yet. 1635 // yet.
1626 NOTREACHED(); 1636 NOTREACHED();
1627 } 1637 }
1628 1638
1629 // If the opener is to be suppressed, the new window can be in any process. 1639 // If the opener is to be suppressed, the new window can be in any process.
1630 // Since routing ids are process specific, we must not have one passed in 1640 // Since routing ids are process specific, we must not have one passed in
1631 // as argument here. 1641 // as argument here.
1632 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); 1642 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE);
1633 1643
1634 scoped_refptr<SiteInstance> site_instance = 1644 scoped_refptr<SiteInstance> site_instance =
1635 params.opener_suppressed && !is_guest ? 1645 params.opener_suppressed && !is_guest
1636 SiteInstance::CreateForURL(GetBrowserContext(), params.target_url) : 1646 ? SiteInstance::CreateForURL(GetBrowserContext(), params.target_url)
1637 GetSiteInstance(); 1647 : source_site_instance;
1638 1648
1639 // A message to create a new window can only come from the active process for 1649 // A message to create a new window can only come from a process for a frame
1640 // this WebContentsImpl instance. If any other process sends the request, 1650 // in this WebContents' FrameTree. If any other process sends the request, it
1641 // it is invalid and the process must be terminated. 1651 // is invalid and the process must be terminated.
1642 if (GetRenderProcessHost()->GetID() != render_process_id) { 1652 int render_process_id = source_site_instance->GetProcess()->GetID();
1643 RenderProcessHost* rph = RenderProcessHost::FromID(render_process_id); 1653 bool did_match_process = false;
1654 frame_tree_.ForEach(
1655 base::Bind(&FindMatchingProcess, render_process_id, &did_match_process));
1656 if (!did_match_process) {
1657 RenderProcessHost* rph = source_site_instance->GetProcess();
1644 base::ProcessHandle process_handle = rph->GetHandle(); 1658 base::ProcessHandle process_handle = rph->GetHandle();
1645 if (process_handle != base::kNullProcessHandle) { 1659 if (process_handle != base::kNullProcessHandle) {
1646 RecordAction( 1660 RecordAction(
1647 base::UserMetricsAction("Terminate_ProcessMismatch_CreateNewWindow")); 1661 base::UserMetricsAction("Terminate_ProcessMismatch_CreateNewWindow"));
1648 rph->Shutdown(RESULT_CODE_KILLED, false); 1662 rph->Shutdown(RESULT_CODE_KILLED, false);
1649 } 1663 }
1650 return; 1664 return;
1651 } 1665 }
1652 1666
1653 // We must assign the SessionStorageNamespace before calling Init(). 1667 // We must assign the SessionStorageNamespace before calling Init().
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 main_frame_route_id); 1699 main_frame_route_id);
1686 return; 1700 return;
1687 } 1701 }
1688 1702
1689 // Create the new web contents. This will automatically create the new 1703 // Create the new web contents. This will automatically create the new
1690 // WebContentsView. In the future, we may want to create the view separately. 1704 // WebContentsView. In the future, we may want to create the view separately.
1691 CreateParams create_params(GetBrowserContext(), site_instance.get()); 1705 CreateParams create_params(GetBrowserContext(), site_instance.get());
1692 create_params.routing_id = route_id; 1706 create_params.routing_id = route_id;
1693 create_params.main_frame_routing_id = main_frame_route_id; 1707 create_params.main_frame_routing_id = main_frame_route_id;
1694 create_params.main_frame_name = params.frame_name; 1708 create_params.main_frame_name = params.frame_name;
1695 create_params.opener_render_process_id = GetRenderProcessHost()->GetID(); 1709 create_params.opener_render_process_id = render_process_id;
1696 create_params.opener_render_frame_id = params.opener_render_frame_id; 1710 create_params.opener_render_frame_id = params.opener_render_frame_id;
1697 create_params.opener_suppressed = params.opener_suppressed; 1711 create_params.opener_suppressed = params.opener_suppressed;
1698 if (params.disposition == NEW_BACKGROUND_TAB) 1712 if (params.disposition == NEW_BACKGROUND_TAB)
1699 create_params.initially_hidden = true; 1713 create_params.initially_hidden = true;
1700 create_params.renderer_initiated_creation = 1714 create_params.renderer_initiated_creation =
1701 main_frame_route_id != MSG_ROUTING_NONE; 1715 main_frame_route_id != MSG_ROUTING_NONE;
1702 1716
1703 WebContentsImpl* new_contents = NULL; 1717 WebContentsImpl* new_contents = NULL;
1704 if (!is_guest) { 1718 if (!is_guest) {
1705 create_params.context = view_->GetNativeView(); 1719 create_params.context = view_->GetNativeView();
(...skipping 2802 matching lines...) Expand 10 before | Expand all | Expand 10 after
4508 player_map->erase(it); 4522 player_map->erase(it);
4509 } 4523 }
4510 4524
4511 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4525 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4512 force_disable_overscroll_content_ = force_disable; 4526 force_disable_overscroll_content_ = force_disable;
4513 if (view_) 4527 if (view_)
4514 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4528 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4515 } 4529 }
4516 4530
4517 } // namespace content 4531 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698