OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/common/sandbox_init_wrapper.h" | 5 #include "chrome/common/sandbox_init_wrapper.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 "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/sandbox_mac.h" | 11 #include "chrome/common/sandbox_mac.h" |
12 | 12 |
13 bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, | 13 bool SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, |
14 const std::string& process_type) { | 14 const std::string& process_type) { |
15 using sandbox::Sandbox; | 15 using sandbox::Sandbox; |
16 | 16 |
17 if (command_line.HasSwitch(switches::kNoSandbox)) | 17 if (command_line.HasSwitch(switches::kNoSandbox)) |
18 return true; | 18 return true; |
19 | 19 |
20 Sandbox::SandboxProcessType sandbox_process_type; | 20 Sandbox::SandboxProcessType sandbox_process_type; |
21 FilePath allowed_dir; // Empty by default. | 21 FilePath allowed_dir; // Empty by default. |
22 | 22 |
23 if (process_type.empty()) { | 23 if (process_type.empty()) { |
24 // Browser process isn't sandboxed. | 24 // Browser process isn't sandboxed. |
25 return true; | 25 return true; |
26 } else if (process_type == switches::kRendererProcess) { | 26 } else if (process_type == switches::kRendererProcess) { |
27 if (!command_line.HasSwitch(switches::kDisable3DAPIs) && | 27 if (!command_line.HasSwitch(switches::kDisableExperimentalWebGL) && |
28 !command_line.HasSwitch(switches::kDisableExperimentalWebGL) && | |
29 command_line.HasSwitch(switches::kInProcessWebGL)) { | 28 command_line.HasSwitch(switches::kInProcessWebGL)) { |
30 // TODO(kbr): this check seems to be necessary only on this | 29 // TODO(kbr): this check seems to be necessary only on this |
31 // platform because the sandbox is initialized later. Remove | 30 // platform because the sandbox is initialized later. Remove |
32 // this once this flag is removed. | 31 // this once this flag is removed. |
33 return true; | 32 return true; |
34 } else { | 33 } else { |
35 sandbox_process_type = Sandbox::SANDBOX_TYPE_RENDERER; | 34 sandbox_process_type = Sandbox::SANDBOX_TYPE_RENDERER; |
36 } | 35 } |
37 } else if (process_type == switches::kExtensionProcess) { | 36 } else if (process_type == switches::kExtensionProcess) { |
38 // Extension processes are just renderers [they use RenderMain()] with a | 37 // Extension processes are just renderers [they use RenderMain()] with a |
(...skipping 27 matching lines...) Expand all Loading... |
66 NOTREACHED(); | 65 NOTREACHED(); |
67 return true; | 66 return true; |
68 } | 67 } |
69 | 68 |
70 // Warm up APIs before turning on the sandbox. | 69 // Warm up APIs before turning on the sandbox. |
71 Sandbox::SandboxWarmup(sandbox_process_type); | 70 Sandbox::SandboxWarmup(sandbox_process_type); |
72 | 71 |
73 // Actually sandbox the process. | 72 // Actually sandbox the process. |
74 return Sandbox::EnableSandbox(sandbox_process_type, allowed_dir); | 73 return Sandbox::EnableSandbox(sandbox_process_type, allowed_dir); |
75 } | 74 } |
OLD | NEW |