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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/debug/debugger.h" | 6 #include "base/debug/debugger.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "content/common/child_process.h" | 10 #include "content/common/child_process.h" |
11 #include "content/ppapi_plugin/ppapi_thread.h" | 11 #include "content/ppapi_plugin/ppapi_thread.h" |
12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
13 #include "content/public/common/main_function_params.h" | 13 #include "content/public/common/main_function_params.h" |
14 #include "ppapi/proxy/proxy_module.h" | 14 #include "ppapi/proxy/proxy_module.h" |
15 | 15 |
16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
17 #include "sandbox/src/sandbox.h" | 17 #include "sandbox/src/sandbox.h" |
18 #endif | 18 #endif |
19 | 19 |
| 20 #if defined(OS_LINUX) |
| 21 #include "content/public/common/sandbox_init.h" |
| 22 #endif |
| 23 |
20 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
21 sandbox::TargetServices* g_target_services = NULL; | 25 sandbox::TargetServices* g_target_services = NULL; |
22 #else | 26 #else |
23 void* g_target_services = 0; | 27 void* g_target_services = 0; |
24 #endif | 28 #endif |
25 | 29 |
26 // Main function for starting the PPAPI plugin process. | 30 // Main function for starting the PPAPI plugin process. |
27 int PpapiPluginMain(const content::MainFunctionParams& parameters) { | 31 int PpapiPluginMain(const content::MainFunctionParams& parameters) { |
28 const CommandLine& command_line = parameters.command_line; | 32 const CommandLine& command_line = parameters.command_line; |
29 | 33 |
30 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
31 g_target_services = parameters.sandbox_info->target_services; | 35 g_target_services = parameters.sandbox_info->target_services; |
32 #endif | 36 #endif |
33 | 37 |
34 // If |g_target_services| is not null this process is sandboxed. One side | 38 // If |g_target_services| is not null this process is sandboxed. One side |
35 // effect is that we can't pop dialogs like ChildProcess::WaitForDebugger() | 39 // effect is that we can't pop dialogs like ChildProcess::WaitForDebugger() |
36 // does. | 40 // does. |
37 if (command_line.HasSwitch(switches::kPpapiStartupDialog)) { | 41 if (command_line.HasSwitch(switches::kPpapiStartupDialog)) { |
38 if (g_target_services) | 42 if (g_target_services) |
39 base::debug::WaitForDebugger(2*60, false); | 43 base::debug::WaitForDebugger(2*60, false); |
40 else | 44 else |
41 ChildProcess::WaitForDebugger("Ppapi"); | 45 ChildProcess::WaitForDebugger("Ppapi"); |
42 } | 46 } |
43 | 47 |
44 MessageLoop main_message_loop; | 48 MessageLoop main_message_loop; |
45 base::PlatformThread::SetName("CrPPAPIMain"); | 49 base::PlatformThread::SetName("CrPPAPIMain"); |
46 | 50 |
| 51 #if defined(OS_LINUX) |
| 52 content::InitializeSandbox(); |
| 53 #endif |
| 54 |
47 ChildProcess ppapi_process; | 55 ChildProcess ppapi_process; |
48 ppapi_process.set_main_thread(new PpapiThread(false)); // Not a broker. | 56 ppapi_process.set_main_thread(new PpapiThread(false)); // Not a broker. |
49 | 57 |
50 ppapi::proxy::ProxyModule::GetInstance()->SetFlashCommandLineArgs( | 58 ppapi::proxy::ProxyModule::GetInstance()->SetFlashCommandLineArgs( |
51 command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs)); | 59 command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs)); |
52 | 60 |
53 main_message_loop.Run(); | 61 main_message_loop.Run(); |
54 return 0; | 62 return 0; |
55 } | 63 } |
OLD | NEW |