diff options
author | gregoryd@google.com <gregoryd@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-26 01:22:10 +0000 |
---|---|---|
committer | gregoryd@google.com <gregoryd@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-26 01:22:10 +0000 |
commit | 08a3ef61e987b2347bdd1bacc6252aa2a323b5ad (patch) | |
tree | c1e3827e0884742b906bed0d005fcd931d570069 /chrome/nacl/nacl_main.cc | |
parent | d579d4cb281fd64e598454bcc3123fdb86c216b4 (diff) | |
download | chromium_src-08a3ef61e987b2347bdd1bacc6252aa2a323b5ad.zip chromium_src-08a3ef61e987b2347bdd1bacc6252aa2a323b5ad.tar.gz chromium_src-08a3ef61e987b2347bdd1bacc6252aa2a323b5ad.tar.bz2 |
First step towards NaCl-Chrome integration:1. NaCl plugin becomes a built-in plugin in Chrome and runs in the renderer process.2. Most of the changes are related to launching the NaCl process (that loads and runs the NaCl module) and establishing the initial communication between that process and the NaCl plugin.3. Command line flag "--internal-nacl" is required to enable the built-in NaCl plugin. NaCl still cannot run in Chrome sandbox, the flag automatically disables the sandbox
Review URL: http://codereview.chromium.org/153002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27315 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/nacl/nacl_main.cc')
-rw-r--r-- | chrome/nacl/nacl_main.cc | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/chrome/nacl/nacl_main.cc b/chrome/nacl/nacl_main.cc new file mode 100644 index 0000000..f519748 --- /dev/null +++ b/chrome/nacl/nacl_main.cc @@ -0,0 +1,73 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "build/build_config.h" + +#if defined(OS_WIN) +#include "app/win_util.h" +#include "chrome/test/injection_test_dll.h" +#include "sandbox/src/sandbox.h" +#endif + +#include "base/command_line.h" +#include "base/message_loop.h" +#include "base/string_util.h" +#include "base/system_monitor.h" +#include "chrome/common/child_process.h" +#include "chrome/common/chrome_constants.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/common/logging_chrome.h" +#include "chrome/common/main_function_params.h" +#include "chrome/nacl/nacl_thread.h" + +// main() routine for running as the sel_ldr process. +int NaClMain(const MainFunctionParams& parameters) { + // The main thread of the plugin services IO. + MessageLoopForIO main_message_loop; + std::wstring app_name = chrome::kBrowserAppName; + PlatformThread::SetName(WideToASCII(app_name + L"_NaClMain").c_str()); + + // Initialize the SystemMonitor + base::SystemMonitor::Start(); + +#if defined(OS_WIN) + const CommandLine& parsed_command_line = parameters.command_line_; + + sandbox::TargetServices* target_services = + parameters.sandbox_info_.TargetServices(); + + DLOG(INFO) << "Started plugin with " << + parsed_command_line.command_line_string(); + + HMODULE sandbox_test_module = NULL; + bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); + if (target_services && !no_sandbox) { + // The command line might specify a test plugin to load. + if (parsed_command_line.HasSwitch(switches::kTestSandbox)) { + std::wstring test_plugin_name = + parsed_command_line.GetSwitchValue(switches::kTestSandbox); + sandbox_test_module = LoadLibrary(test_plugin_name.c_str()); + DCHECK(sandbox_test_module); + } + } + +#else + NOTIMPLEMENTED() << " non-windows startup, plugin startup dialog etc."; +#endif + + { + ChildProcess nacl_process; + nacl_process.set_main_thread(new NaClThread()); +#if defined(OS_WIN) + if (!no_sandbox && target_services) + target_services->LowerToken(); +#endif + + MessageLoop::current()->Run(); + } + + return 0; +} + + |