Chromium Code Reviews| Index: content/browser/web_contents/web_contents_impl.cc |
| diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc |
| index 3df8edb12fb483d5ba4ad4ef7a8c350a20cee49d..6ee49c7069b616762c4e624a1d52d57922f80073 100644 |
| --- a/content/browser/web_contents/web_contents_impl.cc |
| +++ b/content/browser/web_contents/web_contents_impl.cc |
| @@ -208,6 +208,16 @@ void SetAccessibilityModeOnFrame(AccessibilityMode mode, |
| static_cast<RenderFrameHostImpl*>(frame_host)->SetAccessibilityMode(mode); |
| } |
| +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.
|
| + bool* did_match_process, |
| + FrameTreeNode* node) { |
| + if (node->current_frame_host()->GetProcess()->GetID() == render_process_id) { |
| + *did_match_process = true; |
| + return false; |
| + } |
| + return true; |
| +} |
| + |
| } // namespace |
| WebContents* WebContents::Create(const WebContents::CreateParams& params) { |
| @@ -1605,7 +1615,7 @@ void WebContentsImpl::LostMouseLock() { |
| } |
| void WebContentsImpl::CreateNewWindow( |
| - int render_process_id, |
| + SiteInstance* source_site_instance, |
| int route_id, |
| int main_frame_route_id, |
| const ViewHostMsg_CreateWindow_Params& params, |
| @@ -1630,15 +1640,19 @@ void WebContentsImpl::CreateNewWindow( |
| DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE); |
| scoped_refptr<SiteInstance> site_instance = |
| - params.opener_suppressed && !is_guest ? |
| - SiteInstance::CreateForURL(GetBrowserContext(), params.target_url) : |
| - GetSiteInstance(); |
| - |
| - // A message to create a new window can only come from the active process for |
| - // this WebContentsImpl instance. If any other process sends the request, |
| - // it is invalid and the process must be terminated. |
| - if (GetRenderProcessHost()->GetID() != render_process_id) { |
| - RenderProcessHost* rph = RenderProcessHost::FromID(render_process_id); |
| + params.opener_suppressed && !is_guest |
| + ? SiteInstance::CreateForURL(GetBrowserContext(), params.target_url) |
| + : source_site_instance; |
| + |
| + // A message to create a new window can only come from a process for a frame |
| + // in this WebContents' FrameTree. If any other process sends the request, it |
| + // is invalid and the process must be terminated. |
| + int render_process_id = source_site_instance->GetProcess()->GetID(); |
| + bool did_match_process = false; |
| + frame_tree_.ForEach( |
| + base::Bind(&FindMatchingProcess, render_process_id, &did_match_process)); |
| + if (!did_match_process) { |
| + RenderProcessHost* rph = source_site_instance->GetProcess(); |
| base::ProcessHandle process_handle = rph->GetHandle(); |
| if (process_handle != base::kNullProcessHandle) { |
| RecordAction( |
| @@ -1690,7 +1704,7 @@ void WebContentsImpl::CreateNewWindow( |
| create_params.routing_id = route_id; |
| create_params.main_frame_routing_id = main_frame_route_id; |
| create_params.main_frame_name = params.frame_name; |
| - create_params.opener_render_process_id = GetRenderProcessHost()->GetID(); |
| + create_params.opener_render_process_id = render_process_id; |
| create_params.opener_render_frame_id = params.opener_render_frame_id; |
| create_params.opener_suppressed = params.opener_suppressed; |
| if (params.disposition == NEW_BACKGROUND_TAB) |