OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 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. |
| 4 |
| 5 #include "base/command_line.h" |
| 6 #include "base/message_loop.h" |
| 7 #include "base/string_util.h" |
| 8 #include "base/system_monitor.h" |
| 9 #include "chrome/common/chrome_constants.h" |
| 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/common/logging_chrome.h" |
| 12 #include "chrome/common/main_function_params.h" |
| 13 #include "chrome/common/win_util.h" |
| 14 #include "chrome/worker/worker_process.h" |
| 15 #include "sandbox/src/sandbox.h" |
| 16 |
| 17 // Mainline routine for running as the worker process. |
| 18 int WorkerMain(const MainFunctionParams& parameters) { |
| 19 const CommandLine& parsed_command_line = parameters.command_line_; |
| 20 /* sandbox::TargetServices* target_services = |
| 21 parameters.sandbox_info_.TargetServices(); |
| 22 */ |
| 23 // The main thread of the plugin services IO. |
| 24 MessageLoopForIO main_message_loop; |
| 25 std::wstring app_name = chrome::kBrowserAppName; |
| 26 PlatformThread::SetName(WideToASCII(app_name + L"_WorkerMain").c_str()); |
| 27 |
| 28 // Initialize the SystemMonitor |
| 29 base::SystemMonitor::Start(); |
| 30 |
| 31 //CoInitialize(NULL); |
| 32 /* |
| 33 HMODULE sandbox_test_module = NULL; |
| 34 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox) || |
| 35 !parsed_command_line.HasSwitch(switches::kSafePlugins); |
| 36 if (target_services && !no_sandbox) { |
| 37 // The command line might specify a test plugin to load. |
| 38 if (parsed_command_line.HasSwitch(switches::kTestSandbox)) { |
| 39 std::wstring test_plugin_name = |
| 40 parsed_command_line.GetSwitchValue(switches::kTestSandbox); |
| 41 sandbox_test_module = LoadLibrary(test_plugin_name.c_str()); |
| 42 DCHECK(sandbox_test_module); |
| 43 } |
| 44 } |
| 45 |
| 46 if (parsed_command_line.HasSwitch(switches::kPluginStartupDialog)) { |
| 47 std::wstring title = chrome::kBrowserAppName; |
| 48 title += L" plugin"; // makes attaching to process easier |
| 49 win_util::MessageBox(NULL, L"plugin starting...", title, |
| 50 MB_OK | MB_SETFOREGROUND); |
| 51 } |
| 52 */ |
| 53 std::wstring channel_name = |
| 54 parsed_command_line.GetSwitchValue(switches::kProcessChannelID); |
| 55 |
| 56 if (WorkerProcess::GlobalInit(channel_name)) { |
| 57 /* if (!no_sandbox && target_services) { |
| 58 target_services->LowerToken(); |
| 59 } |
| 60 */ |
| 61 |
| 62 |
| 63 // Load the accelerator table from the browser executable and tell the |
| 64 // message loop to use it when translating messages. |
| 65 MessageLoop::current()->Run(); |
| 66 } |
| 67 WorkerProcess::GlobalCleanup(); |
| 68 |
| 69 //CoUninitialize(); |
| 70 return 0; |
| 71 } |
| 72 |
OLD | NEW |