Upstream version 11.39.244.0
[platform/framework/web/crosswalk.git] / src / xwalk / extensions / browser / xwalk_extension_process_host.cc
index 7b160fd..fd03fd5 100644 (file)
@@ -114,15 +114,16 @@ XWalkExtensionProcessHost::XWalkExtensionProcessHost(
     content::RenderProcessHost* render_process_host,
     const base::FilePath& external_extensions_path,
     XWalkExtensionProcessHost::Delegate* delegate,
-    const base::ValueMap& runtime_variables)
+    scoped_ptr<base::ValueMap> runtime_variables)
     : ep_rp_channel_handle_(""),
       render_process_host_(render_process_host),
       render_process_message_filter_(new RenderProcessMessageFilter(this)),
       external_extensions_path_(external_extensions_path),
       is_extension_process_channel_ready_(false),
       delegate_(delegate),
-      runtime_variables_(runtime_variables) {
-  render_process_host_->GetChannel()->AddFilter(render_process_message_filter_);
+      runtime_variables_(runtime_variables.Pass()) {
+  render_process_host_->GetChannel()->AddFilter(
+      render_process_message_filter_.get());
   BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
       base::Bind(&XWalkExtensionProcessHost::StartProcess,
       base::Unretained(this)));
@@ -152,13 +153,11 @@ void XWalkExtensionProcessHost::StartProcess() {
   CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
   CHECK(!process_ || !channel_);
 
-  CommandLine* cmd_line = CommandLine::ForCurrentProcess();
-  if (cmd_line->HasSwitch(switches::kXWalkRunAsService)) {
+#if defined(SHARED_PROCESS_MODE)
 #if defined(OS_LINUX)
     std::string channel_id =
         IPC::Channel::GenerateVerifiedChannelID(std::string());
-    channel_.reset(new IPC::Channel(
-          channel_id, IPC::Channel::MODE_SERVER, this));
+    channel_ = IPC::Channel::CreateServer(channel_id, this);
     if (!channel_->Connect())
       NOTREACHED();
     IPC::ChannelHandle channel_handle(channel_id,
@@ -171,8 +170,8 @@ void XWalkExtensionProcessHost::StartProcess() {
             channel_handle));
 #else
     NOTIMPLEMENTED();
-#endif
-  } else {
+#endif  // #if defined(OS_LINUX)
+#else
     process_.reset(content::BrowserChildProcessHost::Create(
         content::PROCESS_TYPE_CONTENT_END, this));
 
@@ -208,10 +207,10 @@ void XWalkExtensionProcessHost::StartProcess() {
     process_->Launch(
         new ExtensionSandboxedProcessLauncherDelegate(process_->GetHost()),
         cmd_line.release());
-  }
+#endif  // #if defined(SHARED_PROCESS_MODE)
 
   base::ListValue runtime_variables_lv;
-  ToListValue(&const_cast<base::ValueMap&>(runtime_variables_),
+  ToListValue(&const_cast<base::ValueMap&>(*runtime_variables_),
       &runtime_variables_lv);
   Send(new XWalkExtensionProcessMsg_RegisterExtensions(
         external_extensions_path_, runtime_variables_lv));
@@ -270,6 +269,8 @@ void XWalkExtensionProcessHost::OnRenderChannelCreated(
   is_extension_process_channel_ready_ = true;
   ep_rp_channel_handle_ = handle;
   ReplyChannelHandleToRenderProcess();
+  if (delegate_)
+    delegate_->OnRenderChannelCreated(render_process_host_->GetID());
 }
 
 void XWalkExtensionProcessHost::ReplyChannelHandleToRenderProcess() {