diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-03 22:55:27 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-03 22:55:27 +0000 |
commit | b0258ab1379d432f00b41d67bf19c182d45c823e (patch) | |
tree | 6a23675d21f24ede8582353f601abc61ba6be89a /chrome/plugin | |
parent | 040f0b84613e1b760aecbf1a0bc0428f4369012b (diff) | |
download | chromium_src-b0258ab1379d432f00b41d67bf19c182d45c823e.zip chromium_src-b0258ab1379d432f00b41d67bf19c182d45c823e.tar.gz chromium_src-b0258ab1379d432f00b41d67bf19c182d45c823e.tar.bz2 |
Switch Mac plugins back to a UI runloop
This makes Cocoa-event plugins (e.g., Flash 10.1 preview) happier, and Carbon full-screen still gets key events.
BUG=28000
TEST=Flash 10.1 preview should play even without mouse movement. Flash 10 full screen should still accept keyboard commands (e.g., esc).
Review URL: http://codereview.chromium.org/460052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33743 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin')
-rw-r--r-- | chrome/plugin/plugin_main.cc | 50 | ||||
-rw-r--r-- | chrome/plugin/plugin_main_mac.mm | 42 |
2 files changed, 48 insertions, 44 deletions
diff --git a/chrome/plugin/plugin_main.cc b/chrome/plugin/plugin_main.cc index 9794305..5863621 100644 --- a/chrome/plugin/plugin_main.cc +++ b/chrome/plugin/plugin_main.cc @@ -25,8 +25,6 @@ #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(USE_LINUX_BREAKPAD) @@ -36,36 +34,10 @@ #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; - } +void TrimInterposeEnvironment(); - // 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 "<kInterposeLibraryPath>", so just clear it, or - // 2) ":<kInterposeLibraryPath>" 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"; - } -} +// Initializes the global Cocoa application object. +void InitializeChromeApplication(); #endif // OS_MACOSX // main() routine for running as the plugin process. @@ -77,26 +49,16 @@ int PluginMain(const MainFunctionParams& parameters) { // The main thread of the plugin services UI. #if defined(OS_MACOSX) - // For Mac NPAPI plugins, we don't want a MessageLoop::TYPE_UI because - // that will cause events to be dispatched via the Cocoa responder chain. - // If the plugin creates its own windows with Carbon APIs (for example, - // full screen mode in Flash), those windows would not receive events. - // Instead, WebPluginDelegateImpl::OnNullEvent will dispatch any pending - // system events directly to the plugin. - MessageLoop main_message_loop(MessageLoop::TYPE_DEFAULT); -#else - MessageLoop main_message_loop(MessageLoop::TYPE_UI); + TrimInterposeEnvironment(); + InitializeChromeApplication(); #endif + MessageLoop main_message_loop(MessageLoop::TYPE_UI); std::wstring app_name = chrome::kBrowserAppName; PlatformThread::SetName(WideToASCII(app_name + L"_PluginMain").c_str()); SystemMonitor system_monitor; HighResolutionTimerManager high_resolution_timer_manager; -#if defined(OS_MACOSX) - TrimInterposeEnvironment(); -#endif - const CommandLine& parsed_command_line = parameters.command_line_; #if defined(OS_WIN) diff --git a/chrome/plugin/plugin_main_mac.mm b/chrome/plugin/plugin_main_mac.mm new file mode 100644 index 0000000..af428e6 --- /dev/null +++ b/chrome/plugin/plugin_main_mac.mm @@ -0,0 +1,42 @@ +// Copyright (c) 2006-2008 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 "base/chrome_application_mac.h" +#include "base/string_util.h" +#include "chrome/common/plugin_carbon_interpose_constants_mac.h" + +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 "<kInterposeLibraryPath>", so just clear it, or + // 2) ":<kInterposeLibraryPath>" 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"; + } +} + +void InitializeChromeApplication() { + [CrApplication sharedApplication]; +} |