| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/service/service_child_process_host.h" | 5 #include "chrome/service/service_child_process_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/common/result_codes.h" | 11 #include "chrome/common/result_codes.h" |
| 10 | 12 |
| 11 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
| 12 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 13 #include "chrome/common/sandbox_policy.h" | 15 #include "chrome/common/sandbox_policy.h" |
| 14 #endif // defined(OS_WIN) | 16 #endif // defined(OS_WIN) |
| 15 | 17 |
| 16 ServiceChildProcessHost::ServiceChildProcessHost(ProcessType type) | 18 ServiceChildProcessHost::ServiceChildProcessHost(ProcessType type) |
| 17 : ChildProcessInfo(type, -1) { | 19 : ChildProcessInfo(type, -1) { |
| 18 } | 20 } |
| 19 | 21 |
| 20 ServiceChildProcessHost::~ServiceChildProcessHost() { | 22 ServiceChildProcessHost::~ServiceChildProcessHost() { |
| 21 // We need to kill the child process when the host dies. | 23 // We need to kill the child process when the host dies. |
| 22 base::KillProcess(handle(), ResultCodes::NORMAL_EXIT, false); | 24 base::KillProcess(handle(), ResultCodes::NORMAL_EXIT, false); |
| 23 } | 25 } |
| 24 | 26 |
| 25 bool ServiceChildProcessHost::Launch(CommandLine* cmd_line, | 27 bool ServiceChildProcessHost::Launch(CommandLine* cmd_line, |
| 28 bool no_sandbox, |
| 26 const FilePath& exposed_dir) { | 29 const FilePath& exposed_dir) { |
| 27 #if !defined(OS_WIN) | 30 #if !defined(OS_WIN) |
| 28 // TODO(sanjeevr): Implement for non-Windows OSes. | 31 // TODO(sanjeevr): Implement for non-Windows OSes. |
| 29 NOTIMPLEMENTED(); | 32 NOTIMPLEMENTED(); |
| 30 return false; | 33 return false; |
| 31 #else // !defined(OS_WIN) | 34 #else // !defined(OS_WIN) |
| 32 set_handle(sandbox::StartProcessWithAccess(cmd_line, exposed_dir)); | 35 |
| 36 if (no_sandbox) { |
| 37 base::ProcessHandle process = base::kNullProcessHandle; |
| 38 cmd_line->AppendSwitch(switches::kNoSandbox); |
| 39 base::LaunchApp(*cmd_line, false, false, &process); |
| 40 set_handle(process); |
| 41 } else { |
| 42 set_handle(sandbox::StartProcessWithAccess(cmd_line, exposed_dir)); |
| 43 } |
| 33 return (handle() != base::kNullProcessHandle); | 44 return (handle() != base::kNullProcessHandle); |
| 34 #endif // !defined(OS_WIN) | 45 #endif // !defined(OS_WIN) |
| 35 } | 46 } |
| OLD | NEW |