[M47_2526] Chromium upversion to m47_2526 branch
[platform/framework/web/chromium-efl.git] / tizen_src / chromium_impl / content / browser / web_contents / web_contents_impl_efl.cc
index 945d0fb..8dde692 100644 (file)
 
 namespace content {
 
+bool FindMatchingProcess(int render_process_id,
+                         bool* did_match_process,
+                         FrameTreeNode* node) {
+  if (node->current_frame_host()->GetProcess()->GetID() == render_process_id) {
+    *did_match_process = true;
+    return false;
+  }
+  return true;
+}
+
 WebContentsImplEfl::WebContentsImplEfl(BrowserContext* browser_context,
-                                       WebContentsImpl* opener,
                                        void* platform_data)
-    : WebContentsImpl(browser_context, opener)
+    : WebContentsImpl(browser_context)
     , platform_data_(platform_data) {
 }
 
@@ -100,7 +109,7 @@ void WebContentsImplEfl::SetUserAgentOverride(const std::string& override) {
 }
 
 void WebContentsImplEfl::CreateNewWindow(
-    int render_process_id,
+    SiteInstance* source_site_instance,
     int route_id,
     int main_frame_route_id,
     const ViewHostMsg_CreateWindow_Params& params,
@@ -119,13 +128,17 @@ void WebContentsImplEfl::CreateNewWindow(
   scoped_refptr<SiteInstance> site_instance =
       params.opener_suppressed && !is_guest ?
       SiteInstance::CreateForURL(GetBrowserContext(), params.target_url) :
-      GetSiteInstance();
+      source_site_instance;
 
   // 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);
+  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(
@@ -242,7 +255,8 @@ WebContents* WebContentsImplEfl::HandleNewWebContentsCreate(
   CreateParams create_params(GetBrowserContext(), site_instance.get());
   create_params.routing_id = route_id;
   create_params.main_frame_routing_id = main_frame_route_id;
-  create_params.opener = this;
+  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)
     create_params.initially_hidden = true;
@@ -252,7 +266,7 @@ WebContents* WebContentsImplEfl::HandleNewWebContentsCreate(
     create_params.context = view_->GetNativeView();
     create_params.initial_size = GetContainerBounds().size();
     new_contents = new WebContentsImplEfl(
-        create_params.browser_context, NULL, platform_data);
+        create_params.browser_context, platform_data);
     new_contents->Init(create_params);
   }  else {
     new_contents = static_cast<WebContentsImplEfl*>(