| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/common/sandbox_init_wrapper.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "chrome/common/chrome_switches.h" |
| 9 |
| 10 #if defined(OS_MACOSX) |
| 11 extern "C" { |
| 12 #include <sandbox.h> |
| 13 } |
| 14 #endif |
| 15 |
| 16 #if defined(OS_WIN) |
| 17 |
| 18 void SandboxInitWrapper::SetServices(sandbox::SandboxInterfaceInfo* info) { |
| 19 if (info) { |
| 20 broker_services_ = info->broker_services; |
| 21 target_services_ = info->target_services; |
| 22 } |
| 23 } |
| 24 |
| 25 #endif |
| 26 |
| 27 void SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, |
| 28 const std::wstring& process_type) { |
| 29 #if defined(OS_WIN) |
| 30 if (!target_services_) |
| 31 return; |
| 32 #endif |
| 33 if (!command_line.HasSwitch(switches::kNoSandbox)) { |
| 34 if ((process_type == switches::kRendererProcess) || |
| 35 (process_type == switches::kPluginProcess && |
| 36 command_line.HasSwitch(switches::kSafePlugins))) { |
| 37 #if defined(OS_WIN) |
| 38 target_services_->Init(); |
| 39 #elif defined(OS_MACOSX) |
| 40 // TODO(pinkerton): note, this leaks |error_buff|. What do we want to |
| 41 // do with the error? Pass it back to main? |
| 42 char* error_buff; |
| 43 int error = sandbox_init(kSBXProfilePureComputation, SANDBOX_NAMED, |
| 44 &error_buff); |
| 45 if (error) |
| 46 exit(-1); |
| 47 #endif |
| 48 } |
| 49 } |
| 50 } |
| OLD | NEW |