diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-05 23:10:31 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-05 23:10:31 +0000 |
commit | 7d3c02c0eaf7d4cf7becfe869c6b4030ded6293a (patch) | |
tree | 83cb9e4813a07021c771e625d036a5d0a9188dfe /chrome/plugin | |
parent | f3692bc59a04276845ae33f0d2e98f4738b38525 (diff) | |
download | chromium_src-7d3c02c0eaf7d4cf7becfe869c6b4030ded6293a.zip chromium_src-7d3c02c0eaf7d4cf7becfe869c6b4030ded6293a.tar.gz chromium_src-7d3c02c0eaf7d4cf7becfe869c6b4030ded6293a.tar.bz2 |
Update Mac plugins for SetFocus changes, and remove old workaround messages
Now that WebKit is sending unfocus events, rework Mac plugins to correctly track plugin focus as a function of WebKit element focus and window-level view focus. Remove message plumbing for the old workarounds that were used to partially simulate focus switching for Mac plugins.
Windows and Linux will currently ignore the new focus loss notifications so their behavior is unchanged.
BUG=32721
TEST=Mac plugins should stop reacting to keyboard events once another control on the page, or the omnibox, is focused. They should also regain keyboard focus when switching back to their tab if they had it when the tab was hidden.
Review URL: http://codereview.chromium.org/1736007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46516 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin')
-rw-r--r-- | chrome/plugin/plugin_thread.cc | 19 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.cc | 26 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.h | 3 |
3 files changed, 9 insertions, 39 deletions
diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc index fb24e3f..e74e95e 100644 --- a/chrome/plugin/plugin_thread.cc +++ b/chrome/plugin/plugin_thread.cc @@ -135,10 +135,6 @@ void PluginThread::OnControlMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(PluginProcessMsg_PluginMessage, OnPluginMessage) IPC_MESSAGE_HANDLER(PluginProcessMsg_NotifyRenderersOfPendingShutdown, OnNotifyRenderersOfPendingShutdown) -#if defined(OS_MACOSX) - IPC_MESSAGE_HANDLER(PluginProcessMsg_PluginFocusNotify, - OnPluginFocusNotify) -#endif IPC_END_MESSAGE_MAP() } @@ -177,21 +173,6 @@ void PluginThread::OnNotifyRenderersOfPendingShutdown() { PluginChannel::NotifyRenderersOfPendingShutdown(); } -#if defined(OS_MACOSX) -void PluginThread::OnPluginFocusNotify(uint32 instance_id) { - WebPluginDelegateImpl* focused_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++) { - WebPluginDelegateImpl* instance = *iter; - instance->FocusChanged(instance == focused_instance); - } -} -#endif - namespace webkit_glue { #if defined(OS_WIN) diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc index 104c8b9..c0de5d2 100644 --- a/chrome/plugin/webplugin_delegate_stub.cc +++ b/chrome/plugin/webplugin_delegate_stub.cc @@ -46,22 +46,6 @@ 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), @@ -123,6 +107,7 @@ void WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { OnSendJavaScriptStream) #if defined(OS_MACOSX) IPC_MESSAGE_HANDLER(PluginMsg_SetWindowFocus, OnSetWindowFocus) + IPC_MESSAGE_HANDLER(PluginMsg_SetContentAreaFocus, OnSetContentAreaFocus) IPC_MESSAGE_HANDLER(PluginMsg_ContainerHidden, OnContainerHidden) IPC_MESSAGE_HANDLER(PluginMsg_ContainerShown, OnContainerShown) IPC_MESSAGE_HANDLER(PluginMsg_WindowFrameChanged, OnWindowFrameChanged) @@ -197,7 +182,6 @@ void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, webplugin_, params.load_manually); #if defined(OS_MACOSX) - delegate_->SetFocusNotifier(FocusNotifier); delegate_->WindowFrameChanged(params.containing_window_frame, params.containing_content_frame); delegate_->SetWindowHasFocus(params.containing_window_has_focus); @@ -258,8 +242,8 @@ void WebPluginDelegateStub::OnDidFinishLoadWithReason( delegate_->DidFinishLoadWithReason(url, reason, notify_id); } -void WebPluginDelegateStub::OnSetFocus() { - delegate_->SetFocus(); +void WebPluginDelegateStub::OnSetFocus(bool focused) { + delegate_->SetFocus(focused); } void WebPluginDelegateStub::OnHandleInputEvent( @@ -352,6 +336,10 @@ void WebPluginDelegateStub::OnSetWindowFocus(bool has_focus) { delegate_->SetWindowHasFocus(has_focus); } +void WebPluginDelegateStub::OnSetContentAreaFocus(bool has_focus) { + delegate_->SetContentAreaHasFocus(has_focus); +} + void WebPluginDelegateStub::OnContainerHidden() { delegate_->SetContainerVisibility(false); } diff --git a/chrome/plugin/webplugin_delegate_stub.h b/chrome/plugin/webplugin_delegate_stub.h index 5a7be5d..9c9d0b4 100644 --- a/chrome/plugin/webplugin_delegate_stub.h +++ b/chrome/plugin/webplugin_delegate_stub.h @@ -65,7 +65,7 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, void OnDidFinishLoading(int id); void OnDidFail(int id); void OnDidFinishLoadWithReason(const GURL& url, int reason, int notify_id); - void OnSetFocus(); + void OnSetFocus(bool focused); void OnHandleInputEvent(const WebKit::WebInputEvent* event, bool* handled, WebCursor* cursor); void OnPaint(const gfx::Rect& damaged_rect); @@ -80,6 +80,7 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, #if defined(OS_MACOSX) void OnSetWindowFocus(bool has_focus); + void OnSetContentAreaFocus(bool has_focus); void OnContainerHidden(); void OnContainerShown(gfx::Rect window_frame, gfx::Rect view_frame, bool has_focus); |