diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-18 00:02:34 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-18 00:02:34 +0000 |
commit | 784ea1ab3797a0aade739c3d80f9f12b41160aef (patch) | |
tree | c3abea80550ba03a41eab24e7579d9b0df1beb4f /chrome | |
parent | 9c0a58008e54678318d98d0a519bd47e9bd84f07 (diff) | |
download | chromium_src-784ea1ab3797a0aade739c3d80f9f12b41160aef.zip chromium_src-784ea1ab3797a0aade739c3d80f9f12b41160aef.tar.gz chromium_src-784ea1ab3797a0aade739c3d80f9f12b41160aef.tar.bz2 |
Extend improved windowless plugin focus handling to all platforms
Uses the same two-state focus tracking that the Mac currently uses on Windows and Linux as well, so focus is updated correctly when the content area itself gains and loses focus.
BUG=55607
TEST=Windowless plugins should handle key events when focused on all platforms.
Review URL: http://codereview.chromium.org/3397015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59877 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/common/plugin_messages_internal.h | 6 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.cc | 10 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.h | 2 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 14 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 7 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.cc | 18 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.h | 6 |
7 files changed, 30 insertions, 33 deletions
diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h index 29388a4..99e265a 100644 --- a/chrome/common/plugin_messages_internal.h +++ b/chrome/common/plugin_messages_internal.h @@ -221,11 +221,11 @@ IPC_BEGIN_MESSAGES(Plugin) bool /* handled */, WebCursor /* cursor type*/) -#if defined(OS_MACOSX) - IPC_MESSAGE_ROUTED1(PluginMsg_SetWindowFocus, + IPC_MESSAGE_ROUTED1(PluginMsg_SetContentAreaFocus, bool /* has_focus */) - IPC_MESSAGE_ROUTED1(PluginMsg_SetContentAreaFocus, +#if defined(OS_MACOSX) + IPC_MESSAGE_ROUTED1(PluginMsg_SetWindowFocus, bool /* has_focus */) IPC_MESSAGE_ROUTED0(PluginMsg_ContainerHidden) diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc index 0802d31..8e74aa7 100644 --- a/chrome/plugin/webplugin_delegate_stub.cc +++ b/chrome/plugin/webplugin_delegate_stub.cc @@ -116,9 +116,9 @@ void WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(PluginMsg_UpdateGeometrySync, OnUpdateGeometry) IPC_MESSAGE_HANDLER(PluginMsg_SendJavaScriptStream, OnSendJavaScriptStream) + IPC_MESSAGE_HANDLER(PluginMsg_SetContentAreaFocus, OnSetContentAreaFocus) #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) @@ -336,15 +336,15 @@ void WebPluginDelegateStub::OnSendJavaScriptStream(const GURL& url, delegate_->SendJavaScriptStream(url, result, success, notify_id); } +void WebPluginDelegateStub::OnSetContentAreaFocus(bool has_focus) { + delegate_->SetContentAreaHasFocus(has_focus); +} + #if defined(OS_MACOSX) 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 84b22a0..0c1101e 100644 --- a/chrome/plugin/webplugin_delegate_stub.h +++ b/chrome/plugin/webplugin_delegate_stub.h @@ -77,9 +77,9 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, bool success, int notify_id); + void OnSetContentAreaFocus(bool has_focus); #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); diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 9f1fcb6..9e33f83 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -597,23 +597,25 @@ WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame, return CreateNPAPIPlugin(frame, params, info.path, mime_type); } -#if defined(OS_MACOSX) void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { plugin_delegates_.insert(delegate); // If the renderer is visible, set initial visibility and focus state. if (!is_hidden()) { +#if defined(OS_MACOSX) delegate->SetContainerVisibility(true); if (webview() && webview()->isActive()) delegate->SetWindowFocus(true); - if (has_focus()) - delegate->SetContentAreaFocus(true); +#endif } + // Plugins start assuming the content has focus (so that they work in + // environments where RenderView isn't hosting them), so we always have to + // set the initial state. See webplugin_delegate_impl.h for details. + delegate->SetContentAreaFocus(has_focus()); } void RenderView::UnregisterPluginDelegate(WebPluginDelegateProxy* delegate) { plugin_delegates_.erase(delegate); } -#endif void RenderView::Init(gfx::NativeViewId parent_hwnd, int32 opener_id, @@ -5632,6 +5634,7 @@ void RenderView::OnWasRestored(bool needs_repainting) { (*plugin_it)->SetContainerVisibility(true); } } +#endif // OS_MACOSX void RenderView::OnSetFocus(bool enable) { RenderWidget::OnSetFocus(enable); @@ -5640,15 +5643,16 @@ void RenderView::OnSetFocus(bool enable) { std::set<WebPluginDelegateProxy*>::iterator plugin_it; for (plugin_it = plugin_delegates_.begin(); plugin_it != plugin_delegates_.end(); ++plugin_it) { +#if defined(OS_MACOSX) // RenderWidget's call to setFocus can cause the underlying webview's // activation state to change just like a call to setIsActive. if (enable) (*plugin_it)->SetWindowFocus(true); +#endif (*plugin_it)->SetContentAreaFocus(enable); } } } -#endif // OS_MACOSX void RenderView::EnsureDocumentTag() { // TODO(darin): There's actually no reason for this to be here. We should diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 0013ee9..01f9655 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -318,10 +318,10 @@ class RenderView : public RenderWidget, int32 height, TransportDIB::Handle transport_dib); void AcceleratedSurfaceBuffersSwapped(gfx::PluginWindowHandle window); +#endif void RegisterPluginDelegate(WebPluginDelegateProxy* delegate); void UnregisterPluginDelegate(WebPluginDelegateProxy* delegate); -#endif // IPC::Channel::Listener implementation ------------------------------------- @@ -610,9 +610,8 @@ class RenderView : public RenderWidget, virtual void DidFlushPaint(); virtual void DidHandleKeyEvent(); virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event); - -#if OS_MACOSX virtual void OnSetFocus(bool enable); +#if OS_MACOSX virtual void OnWasHidden(); virtual void OnWasRestored(bool needs_repainting); #endif @@ -1218,12 +1217,10 @@ class RenderView : public RenderWidget, PepperPluginDelegateImpl pepper_delegate_; -#if defined(OS_MACOSX) // All the currently active plugin delegates for this RenderView; kept so that // we can enumerate them to send updates about things like window location // or tab focus and visibily. These are non-owning references. std::set<WebPluginDelegateProxy*> plugin_delegates_; -#endif // A list of all Pepper v1 plugins that we've created that haven't been // destroyed yet. Pepper v2 plugins are tracked by the pepper_delegate_. diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index a5490af..2dd4581 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -204,10 +204,8 @@ void WebPluginDelegateProxy::PluginDestroyed() { if (window_) WillDestroyWindow(); -#if defined(OS_MACOSX) if (render_view_) render_view_->UnregisterPluginDelegate(this); -#endif if (channel_host_) { Send(new PluginMsg_DestroyInstance(instance_id_)); @@ -384,9 +382,7 @@ bool WebPluginDelegateProxy::Initialize(const GURL& url, IPC::Message* msg = new PluginMsg_Init(instance_id_, params, &result); Send(msg); -#if defined(OS_MACOSX) render_view_->RegisterPluginDelegate(this); -#endif return result; } @@ -983,19 +979,19 @@ int WebPluginDelegateProxy::GetProcessId() { return channel_host_->peer_pid(); } -#if defined(OS_MACOSX) -void WebPluginDelegateProxy::SetWindowFocus(bool window_has_focus) { - IPC::Message* msg = new PluginMsg_SetWindowFocus(instance_id_, - window_has_focus); +void WebPluginDelegateProxy::SetContentAreaFocus(bool has_focus) { + IPC::Message* msg = new PluginMsg_SetContentAreaFocus(instance_id_, + has_focus); // Make sure focus events are delivered in the right order relative to // sync messages they might interact with (Paint, HandleEvent, etc.). msg->set_unblock(true); Send(msg); } -void WebPluginDelegateProxy::SetContentAreaFocus(bool has_focus) { - IPC::Message* msg = new PluginMsg_SetContentAreaFocus(instance_id_, - has_focus); +#if defined(OS_MACOSX) +void WebPluginDelegateProxy::SetWindowFocus(bool window_has_focus) { + IPC::Message* msg = new PluginMsg_SetWindowFocus(instance_id_, + window_has_focus); // Make sure focus events are delivered in the right order relative to // sync messages they might interact with (Paint, HandleEvent, etc.). msg->set_unblock(true); diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h index 1660556..0cabc1b 100644 --- a/chrome/renderer/webplugin_delegate_proxy.h +++ b/chrome/renderer/webplugin_delegate_proxy.h @@ -78,12 +78,12 @@ class WebPluginDelegateProxy WebKit::WebCursorInfo* cursor); virtual int GetProcessId(); -#if defined(OS_MACOSX) - // Informs the plugin that its enclosing window has gained or lost focus. - virtual void SetWindowFocus(bool window_has_focus); // Informs the plugin that its containing content view has gained or lost // first responder status. virtual void SetContentAreaFocus(bool has_focus); +#if defined(OS_MACOSX) + // Informs the plugin that its enclosing window has gained or lost focus. + virtual void SetWindowFocus(bool window_has_focus); // Informs the plugin that its container (window/tab) has changed visibility. virtual void SetContainerVisibility(bool is_visible); // Informs the plugin that its enclosing window's frame has changed. |