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

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

Issue 164100: Set up a interposing library for Carbon calls made by plugins. (Closed)
Patch Set: Review comments and files that were lost in the move 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
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include "app/win_util.h" 8 #include "app/win_util.h"
9 #endif 9 #endif
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/system_monitor.h" 13 #include "base/system_monitor.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/common/child_process.h" 15 #include "chrome/common/child_process.h"
16 #include "chrome/common/chrome_constants.h" 16 #include "chrome/common/chrome_constants.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/logging_chrome.h" 18 #include "chrome/common/logging_chrome.h"
19 #include "chrome/common/main_function_params.h" 19 #include "chrome/common/main_function_params.h"
20 #include "chrome/plugin/plugin_thread.h" 20 #include "chrome/plugin/plugin_thread.h"
21 21
22 #if defined(OS_WIN) 22 #if defined(OS_WIN)
23 #include "chrome/test/injection_test_dll.h" 23 #include "chrome/test/injection_test_dll.h"
24 #include "sandbox/src/sandbox.h" 24 #include "sandbox/src/sandbox.h"
25 #elif defined(OS_LINUX) 25 #elif defined(OS_LINUX)
26 #include "base/global_descriptors_posix.h" 26 #include "base/global_descriptors_posix.h"
27 #include "ipc/ipc_descriptors.h" 27 #include "ipc/ipc_descriptors.h"
28 #elif defined(OS_MACOSX)
29 #include "chrome/common/plugin_carbon_interpose_constants_mac.h"
28 #endif 30 #endif
29 31
32 #if defined(OS_MACOSX)
33 // Removes our Carbon library interposing from the environment so that it
34 // doesn't carry into any processes that plugins might start.
35 static void TrimInterposeEnvironment() {
36 const char* interpose_list =
37 getenv(plugin_interpose_strings::kDYLDInsertLibrariesKey);
38 if (!interpose_list) {
39 NOTREACHED() << "No interposing libraries set";
40 return;
41 }
42
43 // The list is a :-separated list of paths. Because we append our interpose
44 // library just before forking in plugin_process_host.cc, the only cases we
45 // need to handle are:
46 // 1) The whole string is "<kInterposeLibraryPath>", so just clear it, or
47 // 2) ":<kInterposeLibraryPath>" is the end of the string, so trim and re-set.
48 int suffix_offset = strlen(interpose_list) -
49 strlen(plugin_interpose_strings::kInterposeLibraryPath);
50 if (suffix_offset == 0 &&
51 strcmp(interpose_list,
52 plugin_interpose_strings::kInterposeLibraryPath) == 0) {
53 unsetenv(plugin_interpose_strings::kDYLDInsertLibrariesKey);
54 } else if (suffix_offset > 0 && interpose_list[suffix_offset - 1] == ':' &&
55 strcmp(interpose_list + suffix_offset,
56 plugin_interpose_strings::kInterposeLibraryPath) == 0) {
57 std::string trimmed_list =
58 std::string(interpose_list).substr(0, suffix_offset - 1);
59 setenv(plugin_interpose_strings::kDYLDInsertLibrariesKey,
60 trimmed_list.c_str(), 1);
61 } else {
62 NOTREACHED() << "Missing Carbon interposing library";
63 }
64 }
65 #endif // OS_MACOSX
66
30 // main() routine for running as the plugin process. 67 // main() routine for running as the plugin process.
31 int PluginMain(const MainFunctionParams& parameters) { 68 int PluginMain(const MainFunctionParams& parameters) {
32 // The main thread of the plugin services UI. 69 // The main thread of the plugin services UI.
33 MessageLoop main_message_loop(MessageLoop::TYPE_UI); 70 MessageLoop main_message_loop(MessageLoop::TYPE_UI);
34 std::wstring app_name = chrome::kBrowserAppName; 71 std::wstring app_name = chrome::kBrowserAppName;
35 PlatformThread::SetName(WideToASCII(app_name + L"_PluginMain").c_str()); 72 PlatformThread::SetName(WideToASCII(app_name + L"_PluginMain").c_str());
36 73
37 // Initialize the SystemMonitor 74 // Initialize the SystemMonitor
38 base::SystemMonitor::Start(); 75 base::SystemMonitor::Start();
39 76
77 #if defined(OS_MACOSX)
78 TrimInterposeEnvironment();
79 #endif
80
40 const CommandLine& parsed_command_line = parameters.command_line_; 81 const CommandLine& parsed_command_line = parameters.command_line_;
41 82
42 #if defined(OS_WIN) 83 #if defined(OS_WIN)
43 sandbox::TargetServices* target_services = 84 sandbox::TargetServices* target_services =
44 parameters.sandbox_info_.TargetServices(); 85 parameters.sandbox_info_.TargetServices();
45 86
46 CoInitialize(NULL); 87 CoInitialize(NULL);
47 DLOG(INFO) << "Started plugin with " << 88 DLOG(INFO) << "Started plugin with " <<
48 parsed_command_line.command_line_string(); 89 parsed_command_line.command_line_string();
49 90
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 146
106 MessageLoop::current()->Run(); 147 MessageLoop::current()->Run();
107 } 148 }
108 149
109 #if defined(OS_WIN) 150 #if defined(OS_WIN)
110 CoUninitialize(); 151 CoUninitialize();
111 #endif 152 #endif
112 153
113 return 0; 154 return 0;
114 } 155 }
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