[email protected] | 882f1d56 | 2009-11-05 14:04:48 | [diff] [blame] | 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 | void SandboxInitWrapper::SetServices(sandbox::SandboxInterfaceInfo* info) { |
| 11 | if (info) { |
| 12 | broker_services_ = info->broker_services; |
| 13 | target_services_ = info->target_services; |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, |
| 18 | const std::string& process_type) { |
| 19 | if (command_line.HasSwitch(switches::kNoSandbox)) |
| 20 | return true; |
| 21 | if ((process_type == switches::kRendererProcess) || |
[email protected] | f30a566d | 2009-11-13 22:06:41 | [diff] [blame] | 22 | (process_type == switches::kExtensionProcess) || |
[email protected] | 882f1d56 | 2009-11-05 14:04:48 | [diff] [blame] | 23 | (process_type == switches::kWorkerProcess) || |
[email protected] | 0b6e0a2 | 2010-01-30 00:29:54 | [diff] [blame] | 24 | (process_type == switches::kNaClProcess) || |
[email protected] | 882f1d56 | 2009-11-05 14:04:48 | [diff] [blame] | 25 | (process_type == switches::kUtilityProcess) || |
| 26 | (process_type == switches::kPluginProcess && |
| 27 | command_line.HasSwitch(switches::kSafePlugins))) { |
| 28 | if (!target_services_) |
| 29 | return false; |
| 30 | target_services_->Init(); |
| 31 | } |
| 32 | return true; |
| 33 | } |