| 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 "chrome/common/sandbox_policy.h" | 5 #include "chrome/common/sandbox_policy.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 type = ChildProcessInfo::NACL_BROKER_PROCESS; | 594 type = ChildProcessInfo::NACL_BROKER_PROCESS; |
| 595 } else if (type_str == switches::kGpuProcess) { | 595 } else if (type_str == switches::kGpuProcess) { |
| 596 type = ChildProcessInfo::GPU_PROCESS; | 596 type = ChildProcessInfo::GPU_PROCESS; |
| 597 } else if (type_str == switches::kPpapiPluginProcess) { | 597 } else if (type_str == switches::kPpapiPluginProcess) { |
| 598 type = ChildProcessInfo::PPAPI_PLUGIN_PROCESS; | 598 type = ChildProcessInfo::PPAPI_PLUGIN_PROCESS; |
| 599 } else { | 599 } else { |
| 600 NOTREACHED(); | 600 NOTREACHED(); |
| 601 return 0; | 601 return 0; |
| 602 } | 602 } |
| 603 | 603 |
| 604 TRACE_EVENT_BEGIN("StartProcessWithAccess", 0, type_str); | 604 TRACE_EVENT_BEGIN_ETW("StartProcessWithAccess", 0, type_str); |
| 605 | 605 |
| 606 // To decide if the process is going to be sandboxed we have two cases. | 606 // To decide if the process is going to be sandboxed we have two cases. |
| 607 // First case: all process types except the nacl broker, and the plugin | 607 // First case: all process types except the nacl broker, and the plugin |
| 608 // process are sandboxed by default. | 608 // process are sandboxed by default. |
| 609 bool in_sandbox = | 609 bool in_sandbox = |
| 610 (type != ChildProcessInfo::NACL_BROKER_PROCESS) && | 610 (type != ChildProcessInfo::NACL_BROKER_PROCESS) && |
| 611 (type != ChildProcessInfo::PLUGIN_PROCESS); | 611 (type != ChildProcessInfo::PLUGIN_PROCESS); |
| 612 | 612 |
| 613 // Second case: If it is the plugin process then it depends on it being | 613 // Second case: If it is the plugin process then it depends on it being |
| 614 // the built-in flash, the user forcing plugins into sandbox or the | 614 // the built-in flash, the user forcing plugins into sandbox or the |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 exposed_files.value().c_str()); | 701 exposed_files.value().c_str()); |
| 702 if (result != sandbox::SBOX_ALL_OK) | 702 if (result != sandbox::SBOX_ALL_OK) |
| 703 return 0; | 703 return 0; |
| 704 } | 704 } |
| 705 | 705 |
| 706 if (!AddGenericPolicy(policy)) { | 706 if (!AddGenericPolicy(policy)) { |
| 707 NOTREACHED(); | 707 NOTREACHED(); |
| 708 return 0; | 708 return 0; |
| 709 } | 709 } |
| 710 | 710 |
| 711 TRACE_EVENT_BEGIN("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); | 711 TRACE_EVENT_BEGIN_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); |
| 712 | 712 |
| 713 result = g_broker_services->SpawnTarget( | 713 result = g_broker_services->SpawnTarget( |
| 714 cmd_line->GetProgram().value().c_str(), | 714 cmd_line->GetProgram().value().c_str(), |
| 715 cmd_line->command_line_string().c_str(), | 715 cmd_line->command_line_string().c_str(), |
| 716 policy, &target); | 716 policy, &target); |
| 717 policy->Release(); | 717 policy->Release(); |
| 718 | 718 |
| 719 TRACE_EVENT_END("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); | 719 TRACE_EVENT_END_ETW("StartProcessWithAccess::LAUNCHPROCESS", 0, 0); |
| 720 | 720 |
| 721 if (sandbox::SBOX_ALL_OK != result) | 721 if (sandbox::SBOX_ALL_OK != result) |
| 722 return 0; | 722 return 0; |
| 723 | 723 |
| 724 ResumeThread(target.hThread); | 724 ResumeThread(target.hThread); |
| 725 CloseHandle(target.hThread); | 725 CloseHandle(target.hThread); |
| 726 process = target.hProcess; | 726 process = target.hProcess; |
| 727 | 727 |
| 728 // Help the process a little. It can't start the debugger by itself if | 728 // Help the process a little. It can't start the debugger by itself if |
| 729 // the process is in a sandbox. | 729 // the process is in a sandbox. |
| 730 if (child_needs_help) | 730 if (child_needs_help) |
| 731 base::debug::SpawnDebuggerOnProcess(target.dwProcessId); | 731 base::debug::SpawnDebuggerOnProcess(target.dwProcessId); |
| 732 | 732 |
| 733 return process; | 733 return process; |
| 734 } | 734 } |
| 735 | 735 |
| 736 } // namespace sandbox | 736 } // namespace sandbox |
| OLD | NEW |