| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/common/sandbox_policy.h" | 9 #include "content/common/sandbox_policy.h" |
| 10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| 11 #include "sandbox/win/src/sandbox.h" | 11 #include "sandbox/win/src/sandbox.h" |
| 12 #include "sandbox/win/src/sandbox_types.h" | 12 #include "sandbox/win/src/sandbox_types.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 | 15 |
| 16 bool InitializeSandbox( | 16 bool InitializeSandbox(sandbox::SandboxInterfaceInfo* sandbox_info) { |
| 17 sandbox::SandboxInterfaceInfo* sandbox_info) { | |
| 18 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 17 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 19 std::string process_type = | 18 std::string process_type = |
| 20 command_line.GetSwitchValueASCII(switches::kProcessType); | 19 command_line.GetSwitchValueASCII(switches::kProcessType); |
| 21 sandbox::BrokerServices* broker_services = sandbox_info->broker_services; | 20 sandbox::BrokerServices* broker_services = sandbox_info->broker_services; |
| 22 if (broker_services && (process_type.empty() || | 21 if (broker_services && (process_type.empty() || |
| 23 process_type == switches::kNaClBrokerProcess || | 22 process_type == switches::kNaClBrokerProcess || |
| 24 process_type == switches::kServiceProcess)) { | 23 process_type == switches::kServiceProcess)) { |
| 25 if (!sandbox::InitBrokerServices(broker_services)) | 24 if (!InitBrokerServices(broker_services)) |
| 26 return false; | 25 return false; |
| 27 } | 26 } |
| 28 | 27 |
| 29 if (process_type.empty() || process_type == switches::kNaClBrokerProcess) { | 28 if (process_type.empty() || process_type == switches::kNaClBrokerProcess) { |
| 30 // IMPORTANT: This piece of code needs to run as early as possible in the | 29 // IMPORTANT: This piece of code needs to run as early as possible in the |
| 31 // process because it will initialize the sandbox broker, which requires the | 30 // process because it will initialize the sandbox broker, which requires the |
| 32 // process to swap its window station. During this time all the UI will be | 31 // process to swap its window station. During this time all the UI will be |
| 33 // broken. This has to run before threads and windows are created. | 32 // broken. This has to run before threads and windows are created. |
| 34 if (broker_services) { | 33 if (broker_services) { |
| 35 if (!command_line.HasSwitch(switches::kNoSandbox)) { | 34 if (!command_line.HasSwitch(switches::kNoSandbox)) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 56 // The above five process types must be sandboxed unless --no-sandbox | 55 // The above five process types must be sandboxed unless --no-sandbox |
| 57 // is present in the command line. | 56 // is present in the command line. |
| 58 if (!target_services) | 57 if (!target_services) |
| 59 return false; | 58 return false; |
| 60 } else { | 59 } else { |
| 61 // Other process types might or might not be sandboxed. | 60 // Other process types might or might not be sandboxed. |
| 62 // TODO(cpu): clean this mess. | 61 // TODO(cpu): clean this mess. |
| 63 if (!target_services) | 62 if (!target_services) |
| 64 return true; | 63 return true; |
| 65 } | 64 } |
| 66 return sandbox::InitTargetServices(target_services); | 65 return InitTargetServices(target_services); |
| 67 } | 66 } |
| 68 | 67 |
| 69 } // namespace content | 68 } // namespace content |
| OLD | NEW |