| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/public/common/sandbox_init.h" | 5 #include "content/public/common/sandbox_init.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/common/sandbox_mac.h" | 10 #include "content/common/sandbox_mac.h" |
| 11 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 bool InitializeSandbox(int sandbox_type, const FilePath& allowed_dir) { | 15 bool InitializeSandbox(int sandbox_type, const FilePath& allowed_dir) { |
| 16 // Warm up APIs before turning on the sandbox. | 16 // Warm up APIs before turning on the sandbox. |
| 17 sandbox::Sandbox::SandboxWarmup(sandbox_type); | 17 Sandbox::SandboxWarmup(sandbox_type); |
| 18 | 18 |
| 19 // Actually sandbox the process. | 19 // Actually sandbox the process. |
| 20 return sandbox::Sandbox::EnableSandbox(sandbox_type, allowed_dir); | 20 return Sandbox::EnableSandbox(sandbox_type, allowed_dir); |
| 21 } | 21 } |
| 22 | 22 |
| 23 // Fill in |sandbox_type| and |allowed_dir| based on the command line, returns | 23 // Fill in |sandbox_type| and |allowed_dir| based on the command line, returns |
| 24 // false if the current process type doesn't need to be sandboxed or if the | 24 // false if the current process type doesn't need to be sandboxed or if the |
| 25 // sandbox was disabled from the command line. | 25 // sandbox was disabled from the command line. |
| 26 bool GetSandboxTypeFromCommandLine(int* sandbox_type, | 26 bool GetSandboxTypeFromCommandLine(int* sandbox_type, |
| 27 FilePath* allowed_dir) { | 27 FilePath* allowed_dir) { |
| 28 DCHECK(sandbox_type); | 28 DCHECK(sandbox_type); |
| 29 DCHECK(allowed_dir); | 29 DCHECK(allowed_dir); |
| 30 | 30 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 bool InitializeSandbox() { | 79 bool InitializeSandbox() { |
| 80 int sandbox_type = 0; | 80 int sandbox_type = 0; |
| 81 FilePath allowed_dir; | 81 FilePath allowed_dir; |
| 82 if (!GetSandboxTypeFromCommandLine(&sandbox_type, &allowed_dir)) | 82 if (!GetSandboxTypeFromCommandLine(&sandbox_type, &allowed_dir)) |
| 83 return true; | 83 return true; |
| 84 return InitializeSandbox(sandbox_type, allowed_dir); | 84 return InitializeSandbox(sandbox_type, allowed_dir); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace content | 87 } // namespace content |
| OLD | NEW |