summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-04 20:21:13 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-04 20:21:13 +0000
commit204f1df524af03fa30c20b9d57c4c89ce0162b42 (patch)
treef0831574bacacd626ea124ec01cd2cd0e922a4e1 /content
parent8f104af0562fd65b427ebbb08cd98ad0caa14f5c (diff)
downloadchromium_src-204f1df524af03fa30c20b9d57c4c89ce0162b42.zip
chromium_src-204f1df524af03fa30c20b9d57c4c89ce0162b42.tar.gz
chromium_src-204f1df524af03fa30c20b9d57c4c89ce0162b42.tar.bz2
Hook up page visibility to the View info for a plugin.
TEST=manual (run audio example and switch tab visibility) BUG= Review URL: http://codereview.chromium.org/9022016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116370 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/renderer/pepper_plugin_delegate_impl.cc11
-rw-r--r--content/renderer/pepper_plugin_delegate_impl.h4
-rw-r--r--content/renderer/render_view_impl.cc10
-rw-r--r--content/renderer/render_widget.h3
4 files changed, 24 insertions, 4 deletions
diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc
index 0a15278..f69efe4 100644
--- a/content/renderer/pepper_plugin_delegate_impl.cc
+++ b/content/renderer/pepper_plugin_delegate_impl.cc
@@ -1349,6 +1349,13 @@ void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) {
(*i)->SetContentAreaFocus(has_focus);
}
+void PepperPluginDelegateImpl::PageVisibilityChanged(bool is_visible) {
+ for (std::set<webkit::ppapi::PluginInstance*>::iterator i =
+ active_instances_.begin();
+ i != active_instances_.end(); ++i)
+ (*i)->PageVisibilityChanged(is_visible);
+}
+
bool PepperPluginDelegateImpl::IsPluginFocused() const {
return focused_plugin_ != NULL;
}
@@ -2028,6 +2035,10 @@ bool PepperPluginDelegateImpl::IsInFullscreenMode() {
return render_view_->is_fullscreen();
}
+bool PepperPluginDelegateImpl::IsPageVisible() const {
+ return !render_view_->is_hidden();
+}
+
bool PepperPluginDelegateImpl::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PepperPluginDelegateImpl, message)
diff --git a/content/renderer/pepper_plugin_delegate_impl.h b/content/renderer/pepper_plugin_delegate_impl.h
index fc2e357..2ef8fb7 100644
--- a/content/renderer/pepper_plugin_delegate_impl.h
+++ b/content/renderer/pepper_plugin_delegate_impl.h
@@ -174,6 +174,9 @@ class PepperPluginDelegateImpl
// notifies all of the plugins.
void OnSetFocus(bool has_focus);
+ // Notification that the page visibility has changed. The default is visible.
+ void PageVisibilityChanged(bool is_visible);
+
// IME status.
bool IsPluginFocused() const;
gfx::Rect GetCaretBounds() const;
@@ -382,6 +385,7 @@ class PepperPluginDelegateImpl
virtual void DidReceiveMouseEvent(
webkit::ppapi::PluginInstance* instance) OVERRIDE;
virtual bool IsInFullscreenMode() OVERRIDE;
+ virtual bool IsPageVisible() const OVERRIDE;
// RenderViewObserver implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 80f0852..515ef64 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -4309,8 +4309,11 @@ void RenderViewImpl::OnWasHidden() {
webview()->setVisibilityState(visibilityState(), false);
}
+ // Inform PPAPI plugins that their page is no longer visible.
+ pepper_delegate_.PageVisibilityChanged(false);
+
#if defined(OS_MACOSX)
- // Inform plugins that their container is no longer visible.
+ // Inform NPAPI 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) {
@@ -4328,8 +4331,11 @@ void RenderViewImpl::OnWasRestored(bool needs_repainting) {
webview()->setVisibilityState(visibilityState(), false);
}
+ // Inform PPAPI plugins that their page is visible.
+ pepper_delegate_.PageVisibilityChanged(true);
+
#if defined(OS_MACOSX)
- // Inform plugins that their container is now visible.
+ // Inform NPAPI 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) {
diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h
index 5dc7962..d9c9535 100644
--- a/content/renderer/render_widget.h
+++ b/content/renderer/render_widget.h
@@ -98,6 +98,7 @@ class CONTENT_EXPORT RenderWidget
gfx::Size size() const { return size_; }
bool has_focus() const { return has_focus_; }
bool is_fullscreen() const { return is_fullscreen_; }
+ bool is_hidden() const { return is_hidden_; }
// IPC::Channel::Listener
virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
@@ -273,8 +274,6 @@ class CONTENT_EXPORT RenderWidget
// state.
void SetHidden(bool hidden);
- bool is_hidden() const { return is_hidden_; }
-
void WillToggleFullscreen();
void DidToggleFullscreen();