diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 12:50:34 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 12:50:34 +0000 |
commit | 824083c52c5689198290e24938793ce4ccc6e683 (patch) | |
tree | a9a8145fff77340dc6c88ee787fa9653c421e35a /chrome/common/sandbox_init_wrapper_mac.cc | |
parent | 498fd8ed8d91dd428dab8b7d40029a62aa42734e (diff) | |
download | chromium_src-824083c52c5689198290e24938793ce4ccc6e683.zip chromium_src-824083c52c5689198290e24938793ce4ccc6e683.tar.gz chromium_src-824083c52c5689198290e24938793ce4ccc6e683.tar.bz2 |
Sandbox Worker process on the Mac.
* Add plumbing to allow multiple Sandbox profiles on OS X.
* Separate sandbox_init_wrapper into platform specific files.
* Sandbox Worker process & add plumbing to Sandbox utility process when we bring that up.
* Remove mention of stale bugs in utility process on Mac.
BUG=23582
TEST=Worker process should work.
Review URL: http://codereview.chromium.org/341033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/sandbox_init_wrapper_mac.cc')
-rw-r--r-- | chrome/common/sandbox_init_wrapper_mac.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/chrome/common/sandbox_init_wrapper_mac.cc b/chrome/common/sandbox_init_wrapper_mac.cc new file mode 100644 index 0000000..6ce09d3 --- /dev/null +++ b/chrome/common/sandbox_init_wrapper_mac.cc @@ -0,0 +1,49 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/sandbox_init_wrapper.h" + +#include "base/command_line.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/common/sandbox_mac.h" + +bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, + const std::string& process_type) { + if (command_line.HasSwitch(switches::kNoSandbox)) + return true; + + sandbox::SandboxProcessType sandbox_process_type; + FilePath allowed_dir; // Empty by default. + + if (process_type.empty()) { + // Browser process isn't sandboxed. + return true; + } else if (process_type == switches::kRendererProcess) { + // Renderer process sandbox. + sandbox_process_type = sandbox::SANDBOX_TYPE_RENDERER; + } else if (process_type == switches::kUtilityProcess) { + // Utility process sandbox. + sandbox_process_type = sandbox::SANDBOX_TYPE_UTILITY; + allowed_dir = FilePath::FromWStringHack( + command_line.GetSwitchValue(switches::kUtilityProcessAllowedDir)); + } else if (process_type == switches::kWorkerProcess) { + // Worker process sandbox. + sandbox_process_type = sandbox::SANDBOX_TYPE_WORKER; + } else if ((process_type == switches::kNaClProcess) || + (process_type == switches::kPluginProcess) || + (process_type == switches::kProfileImportProcess)) { + return true; + } else { + // Failsafe: If you hit an unreached here, is your new process type in need + // of sandboxing? + NOTREACHED(); + return true; + } + + // Warm up APIs before turning on the sandbox. + sandbox::SandboxWarmup(); + + // Actually sandbox the process. + return sandbox::EnableSandbox(sandbox_process_type, allowed_dir); +} |