diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-01 21:23:43 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-01 21:23:43 +0000 |
commit | 941e455373dbbe837fe2e82d139af4dec1d35ddb (patch) | |
tree | 07cfc55341b2e0a62d38f821e0ca423db7f146ce /chrome/renderer | |
parent | b51cda7cb0bddadb1f4cca4c18eb27313300aa21 (diff) | |
download | chromium_src-941e455373dbbe837fe2e82d139af4dec1d35ddb.zip chromium_src-941e455373dbbe837fe2e82d139af4dec1d35ddb.tar.gz chromium_src-941e455373dbbe837fe2e82d139af4dec1d35ddb.tar.bz2 |
Add tab switch notification to the Mac plugin plumbing.
Using the new notification:
- Update plugin clip rect when it's not in a visible tab.
- Update plugin idle event rate when it's not in a visible tab.
- Switch the unfocus-on-tab-switch event to be based on the this new notification, instead of a browser-level broadcast.
Related changes:
- Stop sending redundant focus events to plugins.
- Send window activation to Carbon event plugins too, not just Cocoa.
- Now that plugins are getting window and tab de-focus events directly, remove the older hack to force all plugins to lose focus any window or tab loses focus.
BUG=29371, 32229, 30838
TEST=Flash should still only register keystrokes when it is in the active window+tab. Plugins in background tabs should use less CPU.
Review URL: http://codereview.chromium.org/548224
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37743 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/render_view.cc | 24 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 4 | ||||
-rw-r--r-- | chrome/renderer/render_widget.h | 4 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.cc | 18 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.h | 1 |
5 files changed, 48 insertions, 3 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 388d934..e959f14 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -4179,6 +4179,30 @@ void RenderView::DidHandleKeyEvent() { edit_commands_.clear(); } +#if defined(OS_MACOSX) +void RenderView::OnWasHidden() { + RenderWidget::OnWasHidden(); + + // Inform plugins that their container is no longer visible. + std::set<WebPluginDelegateProxy*>::iterator plugin_it; + for (plugin_it = plugin_delegates_.begin(); + plugin_it != plugin_delegates_.end(); ++plugin_it) { + (*plugin_it)->SetContainerVisibility(false); + } +} + +void RenderView::OnWasRestored(bool needs_repainting) { + RenderWidget::OnWasRestored(needs_repainting); + + // Inform plugins that their container is now visible. + std::set<WebPluginDelegateProxy*>::iterator plugin_it; + for (plugin_it = plugin_delegates_.begin(); + plugin_it != plugin_delegates_.end(); ++plugin_it) { + (*plugin_it)->SetContainerVisibility(true); + } +} +#endif // OS_MACOSX + void RenderView::EnsureDocumentTag() { // TODO(darin): There's actually no reason for this to be here. We should // have the browser side manage the document tag. diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 25d598f..dbf4440 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -476,6 +476,10 @@ class RenderView : public RenderWidget, const gfx::Rect& resizer_rect); virtual void DidPaint(); virtual void DidHandleKeyEvent(); +#if OS_MACOSX + virtual void OnWasHidden(); + virtual void OnWasRestored(bool needs_repainting); +#endif private: // For unit tests. diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h index 4cf033e..86f2a17 100644 --- a/chrome/renderer/render_widget.h +++ b/chrome/renderer/render_widget.h @@ -140,8 +140,8 @@ class RenderWidget : public IPC::Channel::Listener, void OnCreatingNewAck(gfx::NativeViewId parent); virtual void OnResize(const gfx::Size& new_size, const gfx::Rect& resizer_rect); - void OnWasHidden(); - void OnWasRestored(bool needs_repainting); + virtual void OnWasHidden(); + virtual void OnWasRestored(bool needs_repainting); void OnUpdateRectAck(); void OnRequestMoveAck(); void OnHandleInputEvent(const IPC::Message& message); diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 94ddc2a..da19300 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -860,7 +860,23 @@ int WebPluginDelegateProxy::GetProcessId() { #if defined(OS_MACOSX) void WebPluginDelegateProxy::SetWindowFocus(bool window_has_focus) { - Send(new PluginMsg_SetWindowFocus(instance_id_, window_has_focus)); + IPC::Message* msg = new PluginMsg_SetWindowFocus(instance_id_, + window_has_focus); + // Make sure visibility 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::SetContainerVisibility(bool is_visible) { + // TODO(stuartmorgan): Split this into two messages, and send location and + // focus information with the "became visible" version since the plugins in a + // hidden tab will not have been getting live updates. + IPC::Message* msg = new PluginMsg_SetWindowFocus(instance_id_, is_visible); + // Make sure visibility events are delivered in the right order relative to + // sync messages they might interact with (Paint, HandleEvent, etc.). + msg->set_unblock(true); + Send(msg); } #endif // OS_MACOSX diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h index 7df5838..c0ce498 100644 --- a/chrome/renderer/webplugin_delegate_proxy.h +++ b/chrome/renderer/webplugin_delegate_proxy.h @@ -73,6 +73,7 @@ class WebPluginDelegateProxy #if defined(OS_MACOSX) virtual void SetWindowFocus(bool window_has_focus); + virtual void SetContainerVisibility(bool is_visible); #endif // IPC::Channel::Listener implementation: |