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

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

Issue 165250: Merge 22799 - Set up a interposing library for Carbon calls made by plugins.... (Closed) Base URL: svn://chrome-svn/chrome/branches/197/src/
Patch Set: Created 11 years, 4 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 | Annotate | Revision Log
Property Changes:
Added: svn:mergeinfo
Merged /branches/chrome_webkit_merge_branch/chrome/plugin/plugin_main.cc:r69-2775
Merged /trunk/src/chrome/plugin/plugin_main.cc:r22799
OLDNEW
(Empty)
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
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 "build/build_config.h"
15 #include "chrome/common/child_process.h"
16 #include "chrome/common/chrome_constants.h"
17 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/logging_chrome.h"
19 #include "chrome/common/main_function_params.h"
20 #include "chrome/plugin/plugin_thread.h"
21
22 #if defined(OS_WIN)
23 #include "chrome/test/injection_test_dll.h"
24 #include "sandbox/src/sandbox.h"
25 #elif defined(OS_LINUX)
26 #include "base/global_descriptors_posix.h"
27 #include "ipc/ipc_descriptors.h"
28 #endif
29
30 // main() routine for running as the plugin process.
31 int PluginMain(const MainFunctionParams& parameters) {
32 // The main thread of the plugin services UI.
33 MessageLoop main_message_loop(MessageLoop::TYPE_UI);
34 std::wstring app_name = chrome::kBrowserAppName;
35 PlatformThread::SetName(WideToASCII(app_name + L"_PluginMain").c_str());
36
37 // Initialize the SystemMonitor
38 base::SystemMonitor::Start();
39
40 const CommandLine& parsed_command_line = parameters.command_line_;
41
42 #if defined(OS_WIN)
43 sandbox::TargetServices* target_services =
44 parameters.sandbox_info_.TargetServices();
45
46 CoInitialize(NULL);
47 DLOG(INFO) << "Started plugin with " <<
48 parsed_command_line.command_line_string();
49
50 HMODULE sandbox_test_module = NULL;
51 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox) ||
52 !parsed_command_line.HasSwitch(switches::kSafePlugins);
53 if (target_services && !no_sandbox) {
54 // The command line might specify a test plugin to load.
55 if (parsed_command_line.HasSwitch(switches::kTestSandbox)) {
56 std::wstring test_plugin_name =
57 parsed_command_line.GetSwitchValue(switches::kTestSandbox);
58 sandbox_test_module = LoadLibrary(test_plugin_name.c_str());
59 DCHECK(sandbox_test_module);
60 }
61 }
62 #endif
63 if (parsed_command_line.HasSwitch(switches::kPluginStartupDialog)) {
64 #if defined(OS_WIN)
65 std::wstring title = chrome::kBrowserAppName;
66 title += L" plugin"; // makes attaching to process easier
67 win_util::MessageBox(NULL, L"plugin starting...", title,
68 MB_OK | MB_SETFOREGROUND);
69 #elif defined(OS_MACOSX)
70 // TODO(playmobil): In the long term, overriding this flag doesn't seem
71 // right, either use our own flag or open a dialog we can use.
72 // This is just to ease debugging in the interim.
73 LOG(WARNING) << "Plugin ("
74 << getpid()
75 << ") paused waiting for debugger to attach @ pid";
76 pause();
77 #else
78 NOTIMPLEMENTED() << " non-windows startup, plugin startup dialog etc.";
79 #endif
80 }
81
82 {
83 ChildProcess plugin_process;
84 plugin_process.set_main_thread(new PluginThread());
85 #if defined(OS_WIN)
86 if (!no_sandbox && target_services)
87 target_services->LowerToken();
88
89 if (sandbox_test_module) {
90 RunRendererTests run_security_tests =
91 reinterpret_cast<RunPluginTests>(GetProcAddress(sandbox_test_module,
92 kPluginTestCall));
93 DCHECK(run_security_tests);
94 if (run_security_tests) {
95 int test_count = 0;
96 DLOG(INFO) << "Running plugin security tests";
97 BOOL result = run_security_tests(&test_count);
98 DCHECK(result) << "Test number " << test_count << " has failed.";
99 // If we are in release mode, crash or debug the process.
100 if (!result)
101 __debugbreak();
102 }
103 }
104 #endif
105
106 MessageLoop::current()->Run();
107 }
108
109 #if defined(OS_WIN)
110 CoUninitialize();
111 #endif
112
113 return 0;
114 }
OLDNEW
« no previous file with comments | « chrome/common/plugin_carbon_interpose_constants_mac.cc ('k') | webkit/glue/plugins/fake_plugin_window_tracker_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698