diff options
-rw-r--r-- | chrome/common/plugin_messages_internal.h | 5 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.cc | 9 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.h | 5 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 18 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 12 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.cc | 14 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.h | 4 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_mac.mm | 6 |
8 files changed, 70 insertions, 3 deletions
diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h index f65816c..7c10168 100644 --- a/chrome/common/plugin_messages_internal.h +++ b/chrome/common/plugin_messages_internal.h @@ -225,6 +225,11 @@ IPC_BEGIN_MESSAGES(Plugin) bool /* handled */, WebCursor /* cursor type*/) +#if defined(OS_MACOSX) + IPC_SYNC_MESSAGE_ROUTED1_0(PluginMsg_SetWindowFocus, + bool /* has_focus */) +#endif + IPC_SYNC_MESSAGE_ROUTED2_0(PluginMsg_WillSendRequest, unsigned long /* id */, GURL /* url */) diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc index 1764366..253d7cf 100644 --- a/chrome/plugin/webplugin_delegate_stub.cc +++ b/chrome/plugin/webplugin_delegate_stub.cc @@ -121,6 +121,9 @@ void WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(PluginMsg_UpdateGeometrySync, OnUpdateGeometry) IPC_MESSAGE_HANDLER(PluginMsg_SendJavaScriptStream, OnSendJavaScriptStream) +#if defined(OS_MACOSX) + IPC_MESSAGE_HANDLER(PluginMsg_SetWindowFocus, OnSetWindowFocus) +#endif IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveManualResponse, OnDidReceiveManualResponse) IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveManualData, OnDidReceiveManualData) @@ -331,6 +334,12 @@ void WebPluginDelegateStub::OnSendJavaScriptStream(const GURL& url, delegate_->SendJavaScriptStream(url, result, success, notify_id); } +#if defined(OS_MACOSX) +void WebPluginDelegateStub::OnSetWindowFocus(bool has_focus) { + delegate_->SetWindowHasFocus(has_focus); +} +#endif + void WebPluginDelegateStub::OnDidReceiveManualResponse( const GURL& url, const PluginMsg_DidReceiveResponseParams& params) { diff --git a/chrome/plugin/webplugin_delegate_stub.h b/chrome/plugin/webplugin_delegate_stub.h index ddc8632..5728fdd 100644 --- a/chrome/plugin/webplugin_delegate_stub.h +++ b/chrome/plugin/webplugin_delegate_stub.h @@ -77,6 +77,11 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, const std::string& result, bool success, int notify_id); + +#if defined(OS_MACOSX) + void OnSetWindowFocus(bool has_focus); +#endif + void OnDidReceiveManualResponse( const GURL& url, const PluginMsg_DidReceiveResponseParams& params); diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 5eea4b3..388d934 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -399,6 +399,16 @@ void RenderView::PluginCrashed(const FilePath& plugin_path) { Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); } +#if defined(OS_MACOSX) +void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { + plugin_delegates_.insert(delegate); +} + +void RenderView::UnregisterPluginDelegate(WebPluginDelegateProxy* delegate) { + plugin_delegates_.erase(delegate); +} +#endif + void RenderView::Init(gfx::NativeViewId parent_hwnd, int32 opener_id, const RendererPreferences& renderer_prefs, @@ -3752,6 +3762,14 @@ void RenderView::OnSetBackground(const SkBitmap& background) { void RenderView::OnSetActive(bool active) { if (webview()) webview()->setIsActive(active); + +#if defined(OS_MACOSX) + std::set<WebPluginDelegateProxy*>::iterator plugin_it; + for (plugin_it = plugin_delegates_.begin(); + plugin_it != plugin_delegates_.end(); ++plugin_it) { + (*plugin_it)->SetWindowFocus(active); + } +#endif } void RenderView::SendExtensionRequest(const std::string& name, diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 3523238..25d598f 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -399,6 +399,11 @@ class RenderView : public RenderWidget, // Called when a plugin has crashed. void PluginCrashed(const FilePath& plugin_path); +#if defined(OS_MACOSX) + void RegisterPluginDelegate(WebPluginDelegateProxy* delegate); + void UnregisterPluginDelegate(WebPluginDelegateProxy* delegate); +#endif + // Called from JavaScript window.external.AddSearchProvider() to add a // keyword for a provider described in the given OpenSearch document. void AddSearchProvider(const std::string& url); @@ -1061,6 +1066,13 @@ class RenderView : public RenderWidget, TextTranslatorImpl text_translator_; scoped_ptr<PageTranslator> page_translator_; +#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 + DISALLOW_COPY_AND_ASSIGN(RenderView); }; diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 83666d5..94ddc2a 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -175,6 +175,10 @@ void WebPluginDelegateProxy::PluginDestroyed() { if (window_) WillDestroyWindow(); +#if defined(OS_MACOSX) + render_view_->UnregisterPluginDelegate(this); +#endif + if (channel_host_) { Send(new PluginMsg_DestroyInstance(instance_id_)); @@ -288,6 +292,10 @@ 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; } @@ -850,6 +858,12 @@ int WebPluginDelegateProxy::GetProcessId() { return channel_host_->peer_pid(); } +#if defined(OS_MACOSX) +void WebPluginDelegateProxy::SetWindowFocus(bool window_has_focus) { + Send(new PluginMsg_SetWindowFocus(instance_id_, window_has_focus)); +} +#endif // OS_MACOSX + void WebPluginDelegateProxy::OnSetWindow(gfx::PluginWindowHandle window) { windowless_ = !window; window_ = window; diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h index 510f977..7df5838 100644 --- a/chrome/renderer/webplugin_delegate_proxy.h +++ b/chrome/renderer/webplugin_delegate_proxy.h @@ -71,6 +71,10 @@ class WebPluginDelegateProxy WebKit::WebCursorInfo* cursor); virtual int GetProcessId(); +#if defined(OS_MACOSX) + virtual void SetWindowFocus(bool window_has_focus); +#endif + // IPC::Channel::Listener implementation: virtual void OnMessageReceived(const IPC::Message& msg); void OnChannelError(); diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm index 44800c9..0fe6ed6 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm @@ -450,9 +450,9 @@ void WebPluginDelegateImpl::WindowlessSetWindow(bool force_set_window) { NPError err = instance()->NPP_SetWindow(&window_); - // TODO(stuartmorgan): Once we are getting window information via IPC, use - // that to set the right value. For now, just pretend plugins are always in - // active windows so they don't throw away events. + // TODO(stuartmorgan): We need real window information when the plugin is + // initialized (location, window focus, visibility, etc.); for now, just + // start off assuming window focus. SetWindowHasFocus(true); DCHECK(err == NPERR_NO_ERROR); |