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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/debug/debugger.h"
7 #include "base/message_loop.h"
8 #include "base/threading/platform_thread.h"
9 #include "build/build_config.h"
10 #include "content/common/child_process.h"
11 #include "content/common/content_switches.h"
12 #include "content/common/main_function_params.h"
13 #include "content/ppapi_plugin/ppapi_thread.h"
14 #include "ppapi/proxy/proxy_module.h"
17 #include "sandbox/src/sandbox.h"
20 #if defined(OS_MACOSX)
21 #include "third_party/WebKit/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.h"
25 sandbox::TargetServices
* g_target_services
= NULL
;
27 void* g_target_services
= 0;
30 // Main function for starting the PPAPI plugin process.
31 int PpapiPluginMain(const MainFunctionParams
& parameters
) {
32 const CommandLine
& command_line
= parameters
.command_line_
;
35 g_target_services
= parameters
.sandbox_info_
.TargetServices();
38 // If |g_target_services| is not null this process is sandboxed. One side
39 // effect is that we can't pop dialogs like ChildProcess::WaitForDebugger()
41 if (command_line
.HasSwitch(switches::kPpapiStartupDialog
)) {
42 if (g_target_services
)
43 base::debug::WaitForDebugger(2*60, false);
45 ChildProcess::WaitForDebugger("Ppapi");
48 #if defined(OS_MACOSX)
49 // TODO(viettrungluu): This is called in different places in processes that
50 // will run WebKit. This is stupid and error-prone.
51 InitWebCoreSystemInterface();
54 MessageLoop main_message_loop
;
55 base::PlatformThread::SetName("CrPPAPIMain");
57 ChildProcess ppapi_process
;
58 ppapi_process
.set_main_thread(new PpapiThread(false)); // Not a broker.
60 ppapi::proxy::ProxyModule::GetInstance()->SetFlashCommandLineArgs(
61 command_line
.GetSwitchValueASCII(switches::kPpapiFlashArgs
));
63 main_message_loop
.Run();