OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2006-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 "build/build_config.h" |
| 6 |
| 7 #if defined(OS_WIN) |
| 8 #include "app/win_util.h" |
| 9 #endif |
| 10 #include "base/command_line.h" |
| 11 #include "base/message_loop.h" |
| 12 #include "base/string_util.h" |
| 13 #include "base/system_monitor.h" |
| 14 #include "chrome/common/child_process.h" |
| 15 #include "chrome/common/chrome_constants.h" |
| 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/logging_chrome.h" |
| 18 #include "chrome/common/main_function_params.h" |
| 19 #include "chrome/nacl/nacl_thread.h" |
| 20 |
| 21 #if defined(OS_WIN) |
| 22 #include "chrome/test/injection_test_dll.h" |
| 23 #include "sandbox/src/sandbox.h" |
| 24 #endif |
| 25 |
| 26 // main() routine for running as the sel_ldr process. |
| 27 int NaClMain(const MainFunctionParams& parameters) { |
| 28 // The main thread of the plugin services IO. |
| 29 MessageLoopForIO main_message_loop; |
| 30 std::wstring app_name = chrome::kBrowserAppName; |
| 31 PlatformThread::SetName(WideToASCII(app_name + L"_NaClMain").c_str()); |
| 32 |
| 33 // Initialize the SystemMonitor |
| 34 base::SystemMonitor::Start(); |
| 35 |
| 36 #if defined(OS_WIN) |
| 37 const CommandLine& parsed_command_line = parameters.command_line_; |
| 38 |
| 39 sandbox::TargetServices* target_services = |
| 40 parameters.sandbox_info_.TargetServices(); |
| 41 |
| 42 DLOG(INFO) << "Started plugin with " << |
| 43 parsed_command_line.command_line_string(); |
| 44 |
| 45 HMODULE sandbox_test_module = NULL; |
| 46 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); |
| 47 if (target_services && !no_sandbox) { |
| 48 // The command line might specify a test plugin to load. |
| 49 if (parsed_command_line.HasSwitch(switches::kTestSandbox)) { |
| 50 std::wstring test_plugin_name = |
| 51 parsed_command_line.GetSwitchValue(switches::kTestSandbox); |
| 52 sandbox_test_module = LoadLibrary(test_plugin_name.c_str()); |
| 53 DCHECK(sandbox_test_module); |
| 54 } |
| 55 } |
| 56 |
| 57 #else |
| 58 NOTIMPLEMENTED() << " non-windows startup, plugin startup dialog etc."; |
| 59 #endif |
| 60 |
| 61 { |
| 62 ChildProcess nacl_process; |
| 63 nacl_process.set_main_thread(new NaClThread()); |
| 64 #if defined(OS_WIN) |
| 65 if (!no_sandbox && target_services) |
| 66 target_services->LowerToken(); |
| 67 #endif |
| 68 |
| 69 MessageLoop::current()->Run(); |
| 70 } |
| 71 |
| 72 return 0; |
| 73 } |
| 74 |
| 75 |
OLD | NEW |