| 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 if (command_line.HasSwitch(switches::kNoSandbox)) | 15 if (command_line.HasSwitch(switches::kNoSandbox)) |
| 16 return true; | 16 return true; |
| 17 | 17 |
| 18 sandbox::SandboxProcessType sandbox_process_type; | 18 sandbox::SandboxProcessType sandbox_process_type; |
| 19 FilePath allowed_dir; // Empty by default. | 19 FilePath allowed_dir; // Empty by default. |
| 20 | 20 |
| 21 if (process_type.empty()) { | 21 if (process_type.empty()) { |
| 22 // Browser process isn't sandboxed. | 22 // Browser process isn't sandboxed. |
| 23 return true; | 23 return true; |
| 24 } else if (process_type == switches::kRendererProcess) { | 24 } else if (process_type == switches::kRendererProcess) { |
| 25 if (command_line.HasSwitch(switches::kEnableExperimentalWebGL) && | 25 if (!command_line.HasSwitch(switches::kDisableExperimentalWebGL) && |
| 26 command_line.HasSwitch(switches::kInProcessWebGL)) { | 26 command_line.HasSwitch(switches::kInProcessWebGL)) { |
| 27 // TODO(kbr): this check seems to be necessary only on this | 27 // TODO(kbr): this check seems to be necessary only on this |
| 28 // platform because the sandbox is initialized later. Remove | 28 // platform because the sandbox is initialized later. Remove |
| 29 // this once this flag is removed. | 29 // this once this flag is removed. |
| 30 return true; | 30 return true; |
| 31 } else { | 31 } else { |
| 32 sandbox_process_type = sandbox::SANDBOX_TYPE_RENDERER; | 32 sandbox_process_type = sandbox::SANDBOX_TYPE_RENDERER; |
| 33 } | 33 } |
| 34 } else if (process_type == switches::kExtensionProcess) { | 34 } else if (process_type == switches::kExtensionProcess) { |
| 35 // Extension processes are just renderers [they use RenderMain()] with a | 35 // Extension processes are just renderers [they use RenderMain()] with a |
| (...skipping 26 matching lines...) Expand all Loading... |
| 62 NOTREACHED(); | 62 NOTREACHED(); |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| 65 | 65 |
| 66 // Warm up APIs before turning on the sandbox. | 66 // Warm up APIs before turning on the sandbox. |
| 67 sandbox::SandboxWarmup(); | 67 sandbox::SandboxWarmup(); |
| 68 | 68 |
| 69 // Actually sandbox the process. | 69 // Actually sandbox the process. |
| 70 return sandbox::EnableSandbox(sandbox_process_type, allowed_dir); | 70 return sandbox::EnableSandbox(sandbox_process_type, allowed_dir); |
| 71 } | 71 } |
| OLD | NEW |