From f3ef7b1c17b3f9a1db703a7b099e697e401d21a9 Mon Sep 17 00:00:00 2001 From: "stuartmorgan@google.com" Date: Fri, 7 Aug 2009 22:03:17 +0000 Subject: Set up a interposing library for Carbon calls made by plugins. This gives us a library that's inserted into plugin process via DYLD_INSERT_LIBRARIES to intercept Carbon calls, and moves the window/process activation handling into that library (based on Carbon window activation/deactivation calls, rather than polling the front window). Over time we'll interpose more, but this gives us the foundation. This fixes both the "window loses focus when loading a page with plugins" and "can't click on YouTube controls" bugs. BUG=18203,18553 TEST=Clicking on Flash plugins should work much more reliably, opening a page with a plugin shouldn't cause the window to lose focus. Review URL: http://codereview.chromium.org/164100 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22799 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/plugin/plugin_main.cc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'chrome/plugin') diff --git a/chrome/plugin/plugin_main.cc b/chrome/plugin/plugin_main.cc index 63d295d..afc83a5 100644 --- a/chrome/plugin/plugin_main.cc +++ b/chrome/plugin/plugin_main.cc @@ -25,8 +25,45 @@ #elif defined(OS_LINUX) #include "base/global_descriptors_posix.h" #include "ipc/ipc_descriptors.h" +#elif defined(OS_MACOSX) +#include "chrome/common/plugin_carbon_interpose_constants_mac.h" #endif +#if defined(OS_MACOSX) +// Removes our Carbon library interposing from the environment so that it +// doesn't carry into any processes that plugins might start. +static void TrimInterposeEnvironment() { + const char* interpose_list = + getenv(plugin_interpose_strings::kDYLDInsertLibrariesKey); + if (!interpose_list) { + NOTREACHED() << "No interposing libraries set"; + return; + } + + // The list is a :-separated list of paths. Because we append our interpose + // library just before forking in plugin_process_host.cc, the only cases we + // need to handle are: + // 1) The whole string is "", so just clear it, or + // 2) ":" is the end of the string, so trim and re-set. + int suffix_offset = strlen(interpose_list) - + strlen(plugin_interpose_strings::kInterposeLibraryPath); + if (suffix_offset == 0 && + strcmp(interpose_list, + plugin_interpose_strings::kInterposeLibraryPath) == 0) { + unsetenv(plugin_interpose_strings::kDYLDInsertLibrariesKey); + } else if (suffix_offset > 0 && interpose_list[suffix_offset - 1] == ':' && + strcmp(interpose_list + suffix_offset, + plugin_interpose_strings::kInterposeLibraryPath) == 0) { + std::string trimmed_list = + std::string(interpose_list).substr(0, suffix_offset - 1); + setenv(plugin_interpose_strings::kDYLDInsertLibrariesKey, + trimmed_list.c_str(), 1); + } else { + NOTREACHED() << "Missing Carbon interposing library"; + } +} +#endif // OS_MACOSX + // main() routine for running as the plugin process. int PluginMain(const MainFunctionParams& parameters) { // The main thread of the plugin services UI. @@ -37,6 +74,10 @@ int PluginMain(const MainFunctionParams& parameters) { // Initialize the SystemMonitor base::SystemMonitor::Start(); +#if defined(OS_MACOSX) + TrimInterposeEnvironment(); +#endif + const CommandLine& parsed_command_line = parameters.command_line_; #if defined(OS_WIN) -- cgit v1.1