diff options
author | amanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-20 18:26:16 +0000 |
---|---|---|
committer | amanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-20 18:26:16 +0000 |
commit | 27f5a6c85610ac97a87bc64918ead7891f58fda5 (patch) | |
tree | 8454f2a3e2526b203628c0e434ebee62e563ad0b /chrome/plugin | |
parent | 8806b8a53168e161e8a2cbbf4051067c095832a9 (diff) | |
download | chromium_src-27f5a6c85610ac97a87bc64918ead7891f58fda5.zip chromium_src-27f5a6c85610ac97a87bc64918ead7891f58fda5.tar.gz chromium_src-27f5a6c85610ac97a87bc64918ead7891f58fda5.tar.bz2 |
Mac: Simulate the OS-level focus handling that windows and linux plugins
rely on to trigger NPAPI keyboard focus notifications.
BUG=26585
TEST=On pages with multiple Flash text entry fields, only one should have
a blinking caret at any time. Flash elements that use the ActionScript2
"Key.IsDown()" function should only detect keydowns when they are in a
visible tab and focused.
Review URL: http://codereview.chromium.org/399090
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32631 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin')
-rw-r--r-- | chrome/plugin/plugin_thread.cc | 19 | ||||
-rw-r--r-- | chrome/plugin/plugin_thread.h | 1 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.cc | 19 |
3 files changed, 39 insertions, 0 deletions
diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc index 914a8ce..9ef6c45 100644 --- a/chrome/plugin/plugin_thread.cc +++ b/chrome/plugin/plugin_thread.cc @@ -21,6 +21,7 @@ #include "net/base/net_errors.h" #include "webkit/glue/plugins/plugin_lib.h" #include "webkit/glue/webkit_glue.h" +#include "webkit/glue/plugins/webplugin_delegate_impl.h" static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls( base::LINKER_INITIALIZED); @@ -102,6 +103,10 @@ void PluginThread::OnControlMessageReceived(const IPC::Message& msg) { IPC_BEGIN_MESSAGE_MAP(PluginThread, msg) IPC_MESSAGE_HANDLER(PluginProcessMsg_CreateChannel, OnCreateChannel) IPC_MESSAGE_HANDLER(PluginProcessMsg_PluginMessage, OnPluginMessage) +#if defined(OS_MACOSX) + IPC_MESSAGE_HANDLER(PluginProcessMsg_PluginFocusNotify, + OnPluginFocusNotify) +#endif IPC_END_MESSAGE_MAP() } @@ -138,6 +143,20 @@ void PluginThread::OnPluginMessage(const std::vector<unsigned char> &data) { ChildProcess::current()->ReleaseProcess(); } +#if defined(OS_MACOSX) +void PluginThread::OnPluginFocusNotify(uint32 instance_id) { + WebPluginDelegateImpl* instance = + reinterpret_cast<WebPluginDelegateImpl*>(instance_id); + std::set<WebPluginDelegateImpl*> active_delegates = + WebPluginDelegateImpl::GetActiveDelegates(); + for (std::set<WebPluginDelegateImpl*>::iterator iter = + active_delegates.begin(); + iter != active_delegates.end(); iter++) { + (*iter)->FocusNotify(instance); + } +} +#endif + namespace webkit_glue { #if defined(OS_WIN) diff --git a/chrome/plugin/plugin_thread.h b/chrome/plugin/plugin_thread.h index 435d8c3..b5eeefc 100644 --- a/chrome/plugin/plugin_thread.h +++ b/chrome/plugin/plugin_thread.h @@ -37,6 +37,7 @@ class PluginThread : public ChildThread { void OnPluginMessage(const std::vector<uint8> &data); #if defined(OS_MACOSX) void OnAppActivated(); + void OnPluginFocusNotify(uint32 instance_id); #endif // The plugin module which is preloaded in Init diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc index a4dabfb..6807b7b 100644 --- a/chrome/plugin/webplugin_delegate_stub.cc +++ b/chrome/plugin/webplugin_delegate_stub.cc @@ -46,6 +46,22 @@ class FinishDestructionTask : public Task { WebPlugin* webplugin_; }; +#if defined(OS_MACOSX) +namespace { + +void FocusNotifier(WebPluginDelegateImpl *instance) { + uint32 process_id = getpid(); + uint32 instance_id = reinterpret_cast<uint32>(instance); + PluginThread* plugin_thread = PluginThread::current(); + if (plugin_thread) { + plugin_thread->Send( + new PluginProcessHostMsg_PluginReceivedFocus(process_id, instance_id)); + } +} + +} +#endif + WebPluginDelegateStub::WebPluginDelegateStub( const std::string& mime_type, int instance_id, PluginChannel* channel) : mime_type_(mime_type), @@ -164,6 +180,9 @@ void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, params.arg_values, webplugin_, params.load_manually); +#if defined(OS_MACOSX) + delegate_->SetFocusNotifier(FocusNotifier); +#endif } } |