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/files/file_path.h" | 8 #include "base/files/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" |
(...skipping 13 matching lines...) Expand all Loading... |
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 base::FilePath* allowed_dir) { | 27 base::FilePath* allowed_dir) { |
28 DCHECK(sandbox_type); | 28 DCHECK(sandbox_type); |
29 DCHECK(allowed_dir); | 29 DCHECK(allowed_dir); |
30 | 30 |
31 *sandbox_type = -1; | 31 *sandbox_type = -1; |
32 *allowed_dir = base::FilePath(); // Empty by default. | 32 *allowed_dir = base::FilePath(); // Empty by default. |
33 | 33 |
34 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 34 const base::CommandLine& command_line = |
| 35 *base::CommandLine::ForCurrentProcess(); |
35 if (command_line.HasSwitch(switches::kNoSandbox)) | 36 if (command_line.HasSwitch(switches::kNoSandbox)) |
36 return false; | 37 return false; |
37 | 38 |
38 std::string process_type = | 39 std::string process_type = |
39 command_line.GetSwitchValueASCII(switches::kProcessType); | 40 command_line.GetSwitchValueASCII(switches::kProcessType); |
40 if (process_type.empty()) { | 41 if (process_type.empty()) { |
41 // Browser process isn't sandboxed. | 42 // Browser process isn't sandboxed. |
42 return false; | 43 return false; |
43 } else if (process_type == switches::kRendererProcess) { | 44 } else if (process_type == switches::kRendererProcess) { |
44 *sandbox_type = SANDBOX_TYPE_RENDERER; | 45 *sandbox_type = SANDBOX_TYPE_RENDERER; |
(...skipping 28 matching lines...) Expand all Loading... |
73 base::FilePath allowed_dir; | 74 base::FilePath allowed_dir; |
74 if (!GetSandboxTypeFromCommandLine(&sandbox_type, &allowed_dir)) | 75 if (!GetSandboxTypeFromCommandLine(&sandbox_type, &allowed_dir)) |
75 return true; | 76 return true; |
76 return InitializeSandbox(sandbox_type, allowed_dir); | 77 return InitializeSandbox(sandbox_type, allowed_dir); |
77 } | 78 } |
78 | 79 |
79 extern const char kBootstrapPortNameForNPAPIPlugins[] = | 80 extern const char kBootstrapPortNameForNPAPIPlugins[] = |
80 "org.chromium.sandbox.real_bootstrap_server"; | 81 "org.chromium.sandbox.real_bootstrap_server"; |
81 | 82 |
82 } // namespace content | 83 } // namespace content |
OLD | NEW |