Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(926)

Unified Diff: chrome/common/sandbox_init_wrapper_mac.cc

Issue 341033: Sandbox Worker process on the Mac. (Closed)
Patch Set: Fix latest round of comments Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/sandbox_init_wrapper_linux.cc ('k') | chrome/common/sandbox_init_wrapper_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/sandbox_init_wrapper_mac.cc
diff --git a/chrome/common/sandbox_init_wrapper_mac.cc b/chrome/common/sandbox_init_wrapper_mac.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1461080a00819606b06877162805f24785acb7a1
--- /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.
+
+ // Browser process isn't sandboxed.
+ if (process_type.empty()) {
+ 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);
+}
« no previous file with comments | « chrome/common/sandbox_init_wrapper_linux.cc ('k') | chrome/common/sandbox_init_wrapper_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698