summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm54
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view.h8
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.h1
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.mm7
-rw-r--r--chrome/browser/renderer_host/test/test_render_view_host.h1
-rw-r--r--chrome/common/render_messages_internal.h8
-rw-r--r--chrome/renderer/render_view.cc14
-rw-r--r--chrome/renderer/render_view.h4
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.cc3
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.h1
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h3
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm16
12 files changed, 115 insertions, 5 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index 64c9f26..aeb5cb6 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -331,6 +331,18 @@ willPositionSheet:(NSWindow*)sheet
// Create the bridge for the status bubble.
statusBubble_ = new StatusBubbleMac([self window], self);
+ // Register for application hide/unhide notifications.
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(applicationDidHide:)
+ name:NSApplicationDidHideNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(applicationDidUnhide:)
+ name:NSApplicationDidUnhideNotification
+ object:nil];
+
// We are done initializing now.
initializing_ = NO;
}
@@ -476,6 +488,48 @@ willPositionSheet:(NSWindow*)sheet
}
}
+// Called when we have been minimized.
+- (void)windowDidMiniaturize:(NSNotification *)notification {
+ // Let the selected RenderWidgetHostView know, so that it can tell plugins.
+ if (TabContents* contents = browser_->GetSelectedTabContents()) {
+ if (RenderWidgetHostView* rwhv = contents->render_widget_host_view())
+ rwhv->SetWindowVisibility(false);
+ }
+}
+
+// Called when we have been unminimized.
+- (void)windowDidDeminiaturize:(NSNotification *)notification {
+ // Let the selected RenderWidgetHostView know, so that it can tell plugins.
+ if (TabContents* contents = browser_->GetSelectedTabContents()) {
+ if (RenderWidgetHostView* rwhv = contents->render_widget_host_view())
+ rwhv->SetWindowVisibility(true);
+ }
+}
+
+// Called when the application has been hidden.
+- (void)applicationDidHide:(NSNotification *)notification {
+ // Let the selected RenderWidgetHostView know, so that it can tell plugins
+ // (unless we are minimized, in which case nothing has really changed).
+ if (![[self window] isMiniaturized]) {
+ if (TabContents* contents = browser_->GetSelectedTabContents()) {
+ if (RenderWidgetHostView* rwhv = contents->render_widget_host_view())
+ rwhv->SetWindowVisibility(false);
+ }
+ }
+}
+
+// Called when the application has been unhidden.
+- (void)applicationDidUnhide:(NSNotification *)notification {
+ // Let the selected RenderWidgetHostView know, so that it can tell plugins
+ // (unless we are minimized, in which case nothing has really changed).
+ if (![[self window] isMiniaturized]) {
+ if (TabContents* contents = browser_->GetSelectedTabContents()) {
+ if (RenderWidgetHostView* rwhv = contents->render_widget_host_view())
+ rwhv->SetWindowVisibility(true);
+ }
+ }
+}
+
// Called when the user clicks the zoom button (or selects it from the Window
// menu) to determine the "standard size" of the window, based on the content
// and other factors. If the current size/location differs nontrivally from the
diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h
index 2a87291..0a87d3d 100644
--- a/chrome/browser/renderer_host/render_widget_host_view.h
+++ b/chrome/browser/renderer_host/render_widget_host_view.h
@@ -158,6 +158,14 @@ class RenderWidgetHostView {
// Set the view's active state (i.e., tint state of controls).
virtual void SetActive(bool active) = 0;
+
+ // Notifies the view that its enclosing window has changed visibility
+ // (minimized/unminimized, app hidden/unhidden, etc).
+ // TODO(stuartmorgan): This is a temporary plugin-specific workaround for
+ // <http://crbug.com/34266>. Once that is fixed, this (and the corresponding
+ // message and renderer-side handling) can be removed in favor of using
+ // WasHidden/DidBecomeSelected.
+ virtual void SetWindowVisibility(bool visible) = 0;
#endif
#if defined(OS_LINUX)
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h
index e38071b..46e9e8a 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h
@@ -109,6 +109,7 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView {
virtual gfx::Rect GetWindowRect();
virtual gfx::Rect GetRootWindowRect();
virtual void SetActive(bool active);
+ virtual void SetWindowVisibility(bool visible);
virtual void SetBackground(const SkBitmap& background);
void KillSelf();
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
index fcf55eb..62eaa1e 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -491,6 +491,13 @@ void RenderWidgetHostViewMac::SetActive(bool active) {
render_widget_host_->SetActive(active);
}
+void RenderWidgetHostViewMac::SetWindowVisibility(bool visible) {
+ if (render_widget_host_) {
+ render_widget_host_->Send(new ViewMsg_SetWindowVisibility(
+ render_widget_host_->routing_id(), visible));
+ }
+}
+
void RenderWidgetHostViewMac::SetBackground(const SkBitmap& background) {
RenderWidgetHostView::SetBackground(background);
if (render_widget_host_)
diff --git a/chrome/browser/renderer_host/test/test_render_view_host.h b/chrome/browser/renderer_host/test/test_render_view_host.h
index ff3727e..7ec1304 100644
--- a/chrome/browser/renderer_host/test/test_render_view_host.h
+++ b/chrome/browser/renderer_host/test/test_render_view_host.h
@@ -77,6 +77,7 @@ class TestRenderWidgetHostView : public RenderWidgetHostView {
virtual gfx::Rect GetWindowRect();
virtual gfx::Rect GetRootWindowRect();
virtual void SetActive(bool active);
+ virtual void SetWindowVisibility(bool visible) {}
#endif
#if defined(OS_LINUX)
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 0438f15..1dcef7e 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -376,7 +376,7 @@ IPC_BEGIN_MESSAGES(View)
// displaying this host can update their content settings to match.
IPC_MESSAGE_CONTROL2(ViewMsg_SetContentSettingsForCurrentHost,
std::string /* host */,
- ContentSettings /* content_settings */)
+ ContentSettings /* content_settings */)
// Change encoding of page in the renderer.
IPC_MESSAGE_ROUTED1(ViewMsg_SetPageEncoding,
@@ -753,6 +753,12 @@ IPC_BEGIN_MESSAGES(View)
IPC_MESSAGE_ROUTED1(ViewMsg_SetActive,
bool /* active */)
+#if defined(OS_MACOSX)
+ // Let the RenderView know its window has changed visibility.
+ IPC_MESSAGE_ROUTED1(ViewMsg_SetWindowVisibility,
+ bool /* visibile */)
+#endif
+
// Response message to ViewHostMsg_CreateShared/DedicatedWorker.
// Sent when the worker has started.
IPC_MESSAGE_ROUTED0(ViewMsg_WorkerCreated)
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index c474e72..0594162 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -574,6 +574,9 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
OnNotifyRendererViewType)
IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt)
IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive)
+#if defined(OS_MACOSX)
+ IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility)
+#endif
IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent,
OnSetEditCommandsForNextKeyEvent)
IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCode,
@@ -3765,6 +3768,17 @@ void RenderView::OnSetActive(bool active) {
#endif
}
+#if defined(OS_MACOSX)
+void RenderView::OnSetWindowVisibility(bool visible) {
+ // Inform plugins that their container has changed visibility.
+ std::set<WebPluginDelegateProxy*>::iterator plugin_it;
+ for (plugin_it = plugin_delegates_.begin();
+ plugin_it != plugin_delegates_.end(); ++plugin_it) {
+ (*plugin_it)->SetContainerVisibility(visible);
+ }
+}
+#endif // OS_MACOSX
+
void RenderView::SendExtensionRequest(const std::string& name,
const ListValue& args,
int request_id,
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 0c5ad52..7545654 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -716,6 +716,10 @@ class RenderView : public RenderWidget,
// accordingly, etc.).
void OnSetActive(bool active);
+#if defined(OS_MACOSX)
+ void OnSetWindowVisibility(bool visible);
+#endif
+
// Execute custom context menu action.
void OnCustomContextMenuAction(unsigned action);
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc
index da19300..b71798e 100644
--- a/chrome/renderer/webplugin_delegate_proxy.cc
+++ b/chrome/renderer/webplugin_delegate_proxy.cc
@@ -872,7 +872,8 @@ 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);
+ IPC::Message* msg = new PluginMsg_SetContainerVisibility(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);
diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h
index c0ce498..6a71bdb 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);
+ // Inform the plugin that its container (window/tab) has changed visibility.
virtual void SetContainerVisibility(bool is_visible);
#endif
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index eb05e27..e6e5d20 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -132,7 +132,7 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
void SetWindowHasFocus(bool has_focus);
// Returns whether or not the window the plugin is in has focus.
bool GetWindowHasFocus() const { return containing_window_has_focus_; }
- // Informs the plugin that its tab has been hidden or shown.
+ // Informs the plugin that its tab or window has been hidden or shown.
void SetContainerVisibility(bool is_visible);
// Informs the delegate that the plugin set a Carbon ThemeCursor.
void SetThemeCursor(ThemeCursor cursor);
@@ -363,6 +363,7 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
bool containing_window_has_focus_;
bool container_is_visible_;
bool have_called_set_window_;
+ gfx::Rect cached_clip_rect_;
#endif
// Called by the message filter hook when the plugin enters a modal loop.
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index 02d1dcb..27aaf13 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -342,8 +342,10 @@ void WebPluginDelegateImpl::WindowlessUpdateGeometry(
const gfx::Rect& window_rect,
const gfx::Rect& clip_rect) {
bool old_clip_was_empty = clip_rect_.IsEmpty();
- bool new_clip_is_empty = clip_rect.IsEmpty();
- clip_rect_ = clip_rect;
+ cached_clip_rect_ = clip_rect;
+ if (container_is_visible_) // Remove check when cached_clip_rect_ is removed.
+ clip_rect_ = clip_rect;
+ bool new_clip_is_empty = clip_rect_.IsEmpty();
// Only resend to the instance if the geometry has changed (see note in
// WindowlesSetWindow for why we only care about the clip rect switching
@@ -550,6 +552,16 @@ void WebPluginDelegateImpl::SetContainerVisibility(bool is_visible) {
return;
container_is_visible_ = is_visible;
+ // TODO(stuartmorgan): This is a temporary workarond for
+ // <http://crbug.com/34266>. When that is fixed, the cached_clip_rect_ code
+ // should all be removed.
+ if (is_visible) {
+ clip_rect_ = cached_clip_rect_;
+ } else {
+ clip_rect_.set_width(0);
+ clip_rect_.set_height(0);
+ }
+
// TODO(stuartmorgan): We may need to remember whether we had focus, and
// restore it ourselves when we become visible again. Revisit once SetFocus
// is actually being called in all the cases it should be, at which point