Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: chrome/plugin/plugin_main.cc

Issue 79020: linux (and some posix): multiprocess plugins compiling. (Closed)
Patch Set: rebased Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/plugin/plugin_channel_base.cc ('k') | chrome/plugin/plugin_thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/system_monitor.h" 8 #include "base/system_monitor.h"
9 #include "build/build_config.h"
9 #include "chrome/common/child_process.h" 10 #include "chrome/common/child_process.h"
10 #include "chrome/common/chrome_constants.h" 11 #include "chrome/common/chrome_constants.h"
11 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/logging_chrome.h" 13 #include "chrome/common/logging_chrome.h"
13 #include "chrome/common/main_function_params.h" 14 #include "chrome/common/main_function_params.h"
15 #include "chrome/plugin/plugin_thread.h"
16
17 #if defined(OS_WIN)
14 #include "chrome/common/win_util.h" 18 #include "chrome/common/win_util.h"
15 #include "chrome/plugin/plugin_thread.h"
16 #include "chrome/test/injection_test_dll.h" 19 #include "chrome/test/injection_test_dll.h"
17 #include "sandbox/src/sandbox.h" 20 #include "sandbox/src/sandbox.h"
21 #endif
18 22
19 // mainline routine for running as the plugin process 23 // main() routine for running as the plugin process.
20 int PluginMain(const MainFunctionParams& parameters) { 24 int PluginMain(const MainFunctionParams& parameters) {
21 const CommandLine& parsed_command_line = parameters.command_line_;
22 sandbox::TargetServices* target_services =
23 parameters.sandbox_info_.TargetServices();
24
25 // The main thread of the plugin services IO. 25 // The main thread of the plugin services IO.
26 MessageLoopForIO main_message_loop; 26 MessageLoopForIO main_message_loop;
27 std::wstring app_name = chrome::kBrowserAppName; 27 std::wstring app_name = chrome::kBrowserAppName;
28 PlatformThread::SetName(WideToASCII(app_name + L"_PluginMain").c_str()); 28 PlatformThread::SetName(WideToASCII(app_name + L"_PluginMain").c_str());
29 29
30 // Initialize the SystemMonitor 30 // Initialize the SystemMonitor
31 base::SystemMonitor::Start(); 31 base::SystemMonitor::Start();
32 32
33 #if defined(OS_WIN)
34 const CommandLine& parsed_command_line = parameters.command_line_;
35
36 sandbox::TargetServices* target_services =
37 parameters.sandbox_info_.TargetServices();
38
33 CoInitialize(NULL); 39 CoInitialize(NULL);
34 DLOG(INFO) << "Started plugin with " << 40 DLOG(INFO) << "Started plugin with " <<
35 parsed_command_line.command_line_string(); 41 parsed_command_line.command_line_string();
36 42
37 HMODULE sandbox_test_module = NULL; 43 HMODULE sandbox_test_module = NULL;
38 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox) || 44 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox) ||
39 !parsed_command_line.HasSwitch(switches::kSafePlugins); 45 !parsed_command_line.HasSwitch(switches::kSafePlugins);
40 if (target_services && !no_sandbox) { 46 if (target_services && !no_sandbox) {
41 // The command line might specify a test plugin to load. 47 // The command line might specify a test plugin to load.
42 if (parsed_command_line.HasSwitch(switches::kTestSandbox)) { 48 if (parsed_command_line.HasSwitch(switches::kTestSandbox)) {
43 std::wstring test_plugin_name = 49 std::wstring test_plugin_name =
44 parsed_command_line.GetSwitchValue(switches::kTestSandbox); 50 parsed_command_line.GetSwitchValue(switches::kTestSandbox);
45 sandbox_test_module = LoadLibrary(test_plugin_name.c_str()); 51 sandbox_test_module = LoadLibrary(test_plugin_name.c_str());
46 DCHECK(sandbox_test_module); 52 DCHECK(sandbox_test_module);
47 } 53 }
48 } 54 }
49 55
50 if (parsed_command_line.HasSwitch(switches::kPluginStartupDialog)) { 56 if (parsed_command_line.HasSwitch(switches::kPluginStartupDialog)) {
51 std::wstring title = chrome::kBrowserAppName; 57 std::wstring title = chrome::kBrowserAppName;
52 title += L" plugin"; // makes attaching to process easier 58 title += L" plugin"; // makes attaching to process easier
53 win_util::MessageBox(NULL, L"plugin starting...", title, 59 win_util::MessageBox(NULL, L"plugin starting...", title,
54 MB_OK | MB_SETFOREGROUND); 60 MB_OK | MB_SETFOREGROUND);
55 } 61 }
62 #else
63 NOTIMPLEMENTED() << " non-windows startup, plugin startup dialog etc.";
64 #endif
56 65
57 { 66 {
58 ChildProcess plugin_process(new PluginThread()); 67 ChildProcess plugin_process(new PluginThread());
59 if (!no_sandbox && target_services) { 68 #if defined(OS_WIN)
69 if (!no_sandbox && target_services)
60 target_services->LowerToken(); 70 target_services->LowerToken();
61 }
62 71
63 if (sandbox_test_module) { 72 if (sandbox_test_module) {
64 RunRendererTests run_security_tests = 73 RunRendererTests run_security_tests =
65 reinterpret_cast<RunPluginTests>(GetProcAddress(sandbox_test_module, 74 reinterpret_cast<RunPluginTests>(GetProcAddress(sandbox_test_module,
66 kPluginTestCall)); 75 kPluginTestCall));
67 DCHECK(run_security_tests); 76 DCHECK(run_security_tests);
68 if (run_security_tests) { 77 if (run_security_tests) {
69 int test_count = 0; 78 int test_count = 0;
70 DLOG(INFO) << "Running plugin security tests"; 79 DLOG(INFO) << "Running plugin security tests";
71 BOOL result = run_security_tests(&test_count); 80 BOOL result = run_security_tests(&test_count);
72 DCHECK(result) << "Test number " << test_count << " has failed."; 81 DCHECK(result) << "Test number " << test_count << " has failed.";
73 // If we are in release mode, crash or debug the process. 82 // If we are in release mode, crash or debug the process.
74 if (!result) 83 if (!result)
75 __debugbreak(); 84 __debugbreak();
76 } 85 }
77 } 86 }
87 #endif
78 88
79 // Load the accelerator table from the browser executable and tell the
80 // message loop to use it when translating messages.
81 MessageLoop::current()->Run(); 89 MessageLoop::current()->Run();
82 } 90 }
83 91
92 #if defined(OS_WIN)
84 CoUninitialize(); 93 CoUninitialize();
94 #endif
95
85 return 0; 96 return 0;
86 } 97 }
OLDNEW
« no previous file with comments | « chrome/plugin/plugin_channel_base.cc ('k') | chrome/plugin/plugin_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698