| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/common/sandbox_mac.h" | 9 #include "chrome/common/sandbox_mac.h" |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // different set of command line flags. | 34 // different set of command line flags. |
| 35 // If we ever get here it means something has changed in regards | 35 // If we ever get here it means something has changed in regards |
| 36 // to the extension process mechanics and we should probably reexamine | 36 // to the extension process mechanics and we should probably reexamine |
| 37 // how we sandbox extension processes since they are no longer identical | 37 // how we sandbox extension processes since they are no longer identical |
| 38 // to renderers. | 38 // to renderers. |
| 39 NOTREACHED(); | 39 NOTREACHED(); |
| 40 return true; | 40 return true; |
| 41 } else if (process_type == switches::kUtilityProcess) { | 41 } else if (process_type == switches::kUtilityProcess) { |
| 42 // Utility process sandbox. | 42 // Utility process sandbox. |
| 43 sandbox_process_type = sandbox::SANDBOX_TYPE_UTILITY; | 43 sandbox_process_type = sandbox::SANDBOX_TYPE_UTILITY; |
| 44 allowed_dir = FilePath::FromWStringHack( | 44 allowed_dir = |
| 45 command_line.GetSwitchValue(switches::kUtilityProcessAllowedDir)); | 45 command_line.GetSwitchValuePath(switches::kUtilityProcessAllowedDir); |
| 46 } else if (process_type == switches::kWorkerProcess) { | 46 } else if (process_type == switches::kWorkerProcess) { |
| 47 // Worker process sandbox. | 47 // Worker process sandbox. |
| 48 sandbox_process_type = sandbox::SANDBOX_TYPE_WORKER; | 48 sandbox_process_type = sandbox::SANDBOX_TYPE_WORKER; |
| 49 } else if (process_type == switches::kNaClLoaderProcess) { | 49 } else if (process_type == switches::kNaClLoaderProcess) { |
| 50 // Native Client sel_ldr (user untrusted code) sandbox. | 50 // Native Client sel_ldr (user untrusted code) sandbox. |
| 51 sandbox_process_type = sandbox::SANDBOX_TYPE_NACL_LOADER; | 51 sandbox_process_type = sandbox::SANDBOX_TYPE_NACL_LOADER; |
| 52 } else if ((process_type == switches::kPluginProcess) || | 52 } else if ((process_type == switches::kPluginProcess) || |
| 53 (process_type == switches::kProfileImportProcess) || | 53 (process_type == switches::kProfileImportProcess) || |
| 54 (process_type == switches::kGpuProcess) || | 54 (process_type == switches::kGpuProcess) || |
| 55 (process_type == switches::kServiceProcess)) { | 55 (process_type == switches::kServiceProcess)) { |
| 56 return true; | 56 return true; |
| 57 } else { | 57 } else { |
| 58 // Failsafe: If you hit an unreached here, is your new process type in need | 58 // Failsafe: If you hit an unreached here, is your new process type in need |
| 59 // of sandboxing? | 59 // of sandboxing? |
| 60 NOTREACHED(); | 60 NOTREACHED(); |
| 61 return true; | 61 return true; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Warm up APIs before turning on the sandbox. | 64 // Warm up APIs before turning on the sandbox. |
| 65 sandbox::SandboxWarmup(); | 65 sandbox::SandboxWarmup(); |
| 66 | 66 |
| 67 // Actually sandbox the process. | 67 // Actually sandbox the process. |
| 68 return sandbox::EnableSandbox(sandbox_process_type, allowed_dir); | 68 return sandbox::EnableSandbox(sandbox_process_type, allowed_dir); |
| 69 } | 69 } |
| OLD | NEW |