Index: chrome/browser/notifications/balloon_host.cc |
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc |
index 04f0b89def08d5ed459953e1493bc48228675c4a..a7241a48fdb0007535b6a79c781624e620fb3356 100644 |
--- a/chrome/browser/notifications/balloon_host.cc |
+++ b/chrome/browser/notifications/balloon_host.cc |
@@ -20,6 +20,30 @@ |
#include "chrome/common/url_constants.h" |
#include "webkit/glue/webpreferences.h" |
+namespace { |
+class BalloonPaintObserver : public RenderWidgetHost::PaintObserver { |
+ public: |
+ explicit BalloonPaintObserver(BalloonHost* balloon_host) |
+ : balloon_host_(balloon_host) { |
+ } |
+ |
+ virtual void RenderWidgetHostWillPaint(RenderWidgetHost* rhw) {} |
+ virtual void RenderWidgetHostDidPaint(RenderWidgetHost* rwh); |
+ |
+ private: |
+ BalloonHost* balloon_host_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BalloonPaintObserver); |
+}; |
+ |
+void BalloonPaintObserver::RenderWidgetHostDidPaint(RenderWidgetHost* rwh) { |
+ balloon_host_->RenderWidgetHostDidPaint(); |
+ // WARNING: we may have been deleted (if the balloon host cleared the paint |
+ // observer). |
+} |
+ |
+} // namespace |
+ |
BalloonHost::BalloonHost(Balloon* balloon) |
: render_view_host_(NULL), |
balloon_(balloon), |
@@ -92,8 +116,10 @@ void BalloonHost::RenderViewCreated(RenderViewHost* render_view_host) { |
render_view_host->Send(new ViewMsg_DisableScrollbarsForSmallWindows( |
render_view_host->routing_id(), balloon_->min_scrollbar_size())); |
render_view_host->WasResized(); |
+#if !defined(OS_MACOSX) |
render_view_host->EnablePreferredSizeChangedMode( |
kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); |
+#endif |
} |
void BalloonHost::RenderViewReady(RenderViewHost* render_view_host) { |
@@ -198,6 +224,9 @@ void BalloonHost::Init() { |
rvh->set_view(render_widget_host_view()); |
rvh->CreateRenderView(string16()); |
+#if defined(OS_MACOSX) |
+ rvh->set_paint_observer(new BalloonPaintObserver(this)); |
+#endif |
rvh->NavigateToURL(balloon_->notification().content_url()); |
initialized_ = true; |
@@ -219,7 +248,15 @@ void BalloonHost::ClearInspectorSettings() { |
RenderViewHostDelegateHelper::ClearInspectorSettings(GetProfile()); |
} |
-BalloonHost::~BalloonHost() {} |
+void BalloonHost::RenderWidgetHostDidPaint() { |
+ render_view_host_->set_paint_observer(NULL); |
+ render_view_host_->EnablePreferredSizeChangedMode( |
+ kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow); |
+} |
+ |
+BalloonHost::~BalloonHost() { |
+ DCHECK(!render_view_host_); |
+} |
void BalloonHost::NotifyDisconnect() { |
if (!should_notify_on_disconnect_) |