Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6921)

Unified Diff: chrome/browser/notifications/balloon_host.cc

Issue 5361006: For OSX, make it so that notifications only start resizing after the first paint is done. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser
Patch Set: Fix ifdef. Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_)
« chrome/browser/notifications/balloon.cc ('K') | « chrome/browser/notifications/balloon_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698