diff options
author | pinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-09 20:28:44 +0000 |
---|---|---|
committer | pinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-09 20:28:44 +0000 |
commit | a1a130f7da9191abecf15b3c27e2aa7ee1faacb3 (patch) | |
tree | 3a9c6ad25ec53f05a4380ffac1a7932f66107a0d /chrome/common/sandbox_init_wrapper.cc | |
parent | fd26b925c589b600c7d12f55554ad1097bad6b87 (diff) | |
download | chromium_src-a1a130f7da9191abecf15b3c27e2aa7ee1faacb3.zip chromium_src-a1a130f7da9191abecf15b3c27e2aa7ee1faacb3.tar.gz chromium_src-a1a130f7da9191abecf15b3c27e2aa7ee1faacb3.tar.bz2 |
remove chrome dependencies from win sandboxing headers. Wrap sandbox code to
make the main routine a little cleaner. Unify the parameters of each of the "main" entry points so we can more easily abstract platform differences in the future. BUG=5323
Review URL: http://codereview.chromium.org/17426
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7825 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/sandbox_init_wrapper.cc')
-rw-r--r-- | chrome/common/sandbox_init_wrapper.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/chrome/common/sandbox_init_wrapper.cc b/chrome/common/sandbox_init_wrapper.cc new file mode 100644 index 0000000..f72c2df --- /dev/null +++ b/chrome/common/sandbox_init_wrapper.cc @@ -0,0 +1,50 @@ +// 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" + +#if defined(OS_MACOSX) +extern "C" { +#include <sandbox.h> +} +#endif + +#if defined(OS_WIN) + +void SandboxInitWrapper::SetServices(sandbox::SandboxInterfaceInfo* info) { + if (info) { + broker_services_ = info->broker_services; + target_services_ = info->target_services; + } +} + +#endif + +void SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, + const std::wstring& process_type) { +#if defined(OS_WIN) + if (!target_services_) + return; +#endif + if (!command_line.HasSwitch(switches::kNoSandbox)) { + if ((process_type == switches::kRendererProcess) || + (process_type == switches::kPluginProcess && + command_line.HasSwitch(switches::kSafePlugins))) { +#if defined(OS_WIN) + target_services_->Init(); +#elif defined(OS_MACOSX) + // TODO(pinkerton): note, this leaks |error_buff|. What do we want to + // do with the error? Pass it back to main? + char* error_buff; + int error = sandbox_init(kSBXProfilePureComputation, SANDBOX_NAMED, + &error_buff); + if (error) + exit(-1); +#endif + } + } +} |