summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/notifications/balloon.cc16
-rw-r--r--chrome/browser/notifications/balloon_host.cc39
-rw-r--r--chrome/browser/notifications/balloon_host.h3
3 files changed, 56 insertions, 2 deletions
diff --git a/chrome/browser/notifications/balloon.cc b/chrome/browser/notifications/balloon.cc
index 96f3fca..86bf50a 100644
--- a/chrome/browser/notifications/balloon.cc
+++ b/chrome/browser/notifications/balloon.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/renderer_host/site_instance.h"
#include "gfx/rect.h"
+#include "gfx/size.h"
Balloon::Balloon(const Notification& notification, Profile* profile,
BalloonCollection* collection)
@@ -27,7 +28,20 @@ void Balloon::SetPosition(const gfx::Point& upper_left, bool reposition) {
}
void Balloon::SetContentPreferredSize(const gfx::Size& size) {
- collection_->ResizeBalloon(this, size);
+ gfx::Size new_size(size);
+#if defined(OS_MACOSX)
+ // TODO(levin): Make all of the code that went in with this change to be
+ // cross-platform. See http://crbug.com/64720
+ // Only allow the size of notifications to grow. This stops the balloon
+ // from jumping between sizes due to dynamic content. For example, the
+ // balloon's contents may adjust due to changes in
+ // document.body.clientHeight.
+ new_size.set_height(std::max(new_size.height(), content_size_.height()));
+
+ if (content_size_ == new_size)
+ return;
+#endif
+ collection_->ResizeBalloon(this, new_size);
}
void Balloon::set_view(BalloonView* balloon_view) {
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc
index ab2cb31..5fe8c4e 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),
@@ -93,8 +117,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) {
@@ -199,6 +225,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;
@@ -220,7 +249,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_)
diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h
index 4e51eba..c5a88e7 100644
--- a/chrome/browser/notifications/balloon_host.h
+++ b/chrome/browser/notifications/balloon_host.h
@@ -112,6 +112,9 @@ class BalloonHost : public RenderViewHostDelegate,
const std::string& value);
virtual void ClearInspectorSettings();
+ // Called when the render view has painted.
+ void RenderWidgetHostDidPaint();
+
protected:
virtual ~BalloonHost();
// Must override in platform specific implementations.