Fix build break
[chromium-blink-merge.git] / content / plugin / plugin_main.cc
blob2f0817ef830472190a9eaa9755e6dd0f507d3836
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
3 // found in the LICENSE file.
5 #include "build/build_config.h"
7 #if defined(OS_WIN)
8 #include <windows.h>
9 #endif
11 #include "base/bind.h"
12 #include "base/command_line.h"
13 #include "base/hi_res_timer_manager.h"
14 #include "base/message_loop.h"
15 #include "base/string_util.h"
16 #include "base/power_monitor/power_monitor.h"
17 #include "base/threading/platform_thread.h"
18 #include "content/common/child_process.h"
19 #include "content/plugin/plugin_thread.h"
20 #include "content/public/common/content_switches.h"
21 #include "content/public/common/main_function_params.h"
23 #if defined(OS_WIN)
24 #include "base/win/scoped_com_initializer.h"
25 #include "content/public/common/injection_test_win.h"
26 #include "sandbox/win/src/sandbox.h"
27 #elif defined(OS_POSIX) && !defined(OS_MACOSX)
28 #include "base/posix/global_descriptors.h"
29 #include "ipc/ipc_descriptors.h"
30 #endif
32 namespace content {
34 #if defined(OS_MACOSX)
35 // Removes our Carbon library interposing from the environment so that it
36 // doesn't carry into any processes that plugins might start.
37 void TrimInterposeEnvironment();
39 // Initializes the global Cocoa application object.
40 void InitializeChromeApplication();
41 #elif defined(OS_LINUX)
42 // Work around an unimplemented instruction in 64-bit Flash.
43 void WorkaroundFlashLAHF();
44 #endif
46 // main() routine for running as the plugin process.
47 int PluginMain(const MainFunctionParams& parameters) {
48 // The main thread of the plugin services UI.
49 #if defined(OS_MACOSX)
50 #if !defined(__LP64__)
51 TrimInterposeEnvironment();
52 #endif
53 InitializeChromeApplication();
54 #endif
55 MessageLoop main_message_loop(MessageLoop::TYPE_UI);
56 base::PlatformThread::SetName("CrPluginMain");
58 base::PowerMonitor power_monitor;
59 HighResolutionTimerManager high_resolution_timer_manager;
61 const CommandLine& parsed_command_line = parameters.command_line;
63 #if defined(OS_LINUX)
65 #if defined(ARCH_CPU_64_BITS)
66 WorkaroundFlashLAHF();
67 #endif
69 #elif defined(OS_WIN)
70 base::win::ScopedCOMInitializer com_initializer;
71 #endif
73 if (parsed_command_line.HasSwitch(switches::kPluginStartupDialog)) {
74 ChildProcess::WaitForDebugger("Plugin");
78 ChildProcess plugin_process;
79 plugin_process.set_main_thread(new PluginThread());
80 MessageLoop::current()->Run();
83 return 0;
86 } // namespace content