diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-09 07:00:08 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-09 07:00:08 +0000 |
commit | 999045921ee2c3139d02353fa63882b34301e8fe (patch) | |
tree | deb22c51c2dc56516670a581308d7ad5c0bead50 /chrome/browser | |
parent | 62356ddf68e44aa92655ed2c5a8971e7dc2050eb (diff) | |
download | chromium_src-999045921ee2c3139d02353fa63882b34301e8fe.zip chromium_src-999045921ee2c3139d02353fa63882b34301e8fe.tar.gz chromium_src-999045921ee2c3139d02353fa63882b34301e8fe.tar.bz2 |
Fix issue where the size of notification on linux/views gets created bigger than max size.
BUG=none
TEST=manual: run linux/view build or chromeos build and create a web notification. The size of balloon should be same as one in Windows.
Review URL: http://codereview.chromium.org/1631007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44062 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
5 files changed, 22 insertions, 11 deletions
diff --git a/chrome/browser/chromeos/notifications/balloon_collection_impl.cc b/chrome/browser/chromeos/notifications/balloon_collection_impl.cc index 732edbc..19932ec 100644 --- a/chrome/browser/chromeos/notifications/balloon_collection_impl.cc +++ b/chrome/browser/chromeos/notifications/balloon_collection_impl.cc @@ -46,6 +46,9 @@ class NotificationMatcher { namespace chromeos { +const int BalloonCollectionImpl::kBalloonWidth = 300; +const int BalloonCollectionImpl::kBalloonMinHeight = 24; + BalloonCollectionImpl::BalloonCollectionImpl() : notification_ui_(new NotificationPanel()) { registrar_.Add(this, NotificationType::BROWSER_CLOSED, @@ -159,6 +162,7 @@ Balloon* BalloonCollectionImpl::MakeBalloon(const Notification& notification, Profile* profile) { Balloon* new_balloon = new Balloon(notification, profile, this); new_balloon->set_view(new chromeos::BalloonViewImpl(false, true)); + new_balloon->set_content_size(gfx::Size(kBalloonWidth, kBalloonMinHeight)); return new_balloon; } diff --git a/chrome/browser/chromeos/notifications/balloon_collection_impl.h b/chrome/browser/chromeos/notifications/balloon_collection_impl.h index a7c2051..6547561 100644 --- a/chrome/browser/chromeos/notifications/balloon_collection_impl.h +++ b/chrome/browser/chromeos/notifications/balloon_collection_impl.h @@ -84,6 +84,10 @@ class BalloonCollectionImpl : public BalloonCollection, return notification_ui_.get(); } + // The width and the minimum hight of a balloon. + static const int kBalloonWidth; + static const int kBalloonMinHeight; + protected: // Creates a new balloon. Overridable by unit tests. The caller is // responsible for freeing the pointer returned. diff --git a/chrome/browser/chromeos/notifications/notification_panel.cc b/chrome/browser/chromeos/notifications/notification_panel.cc index b055510..ec3b66f 100644 --- a/chrome/browser/chromeos/notifications/notification_panel.cc +++ b/chrome/browser/chromeos/notifications/notification_panel.cc @@ -19,10 +19,7 @@ #define SET_STATE(state) SetState(state, __PRETTY_FUNCTION__) namespace { -// Minimum and maximum size of balloon content. -const int kBalloonMinWidth = 300; -const int kBalloonMaxWidth = 300; -const int kBalloonMinHeight = 24; +// Maximum size of balloon's height. const int kBalloonMaxHeight = 120; // Maximum height of the notification panel. @@ -189,7 +186,7 @@ namespace chromeos { class BalloonContainer : public views::View { public: - BalloonContainer(int margin) + explicit BalloonContainer(int margin) : margin_(margin), sticky_container_(new BalloonSubContainer(margin)), non_sticky_container_(new BalloonSubContainer(margin)) { @@ -335,7 +332,9 @@ NotificationPanel::NotificationPanel() : balloon_container_(NULL), state_(CLOSED), task_factory_(this), - min_bounds_(0, 0, kBalloonMinWidth, kBalloonMinHeight), + min_bounds_(0, 0, + BalloonCollectionImpl::kBalloonWidth, + BalloonCollectionImpl::kBalloonMinHeight), stale_timeout_(1000 * kStaleTimeoutInSeconds) { Init(); } @@ -364,7 +363,9 @@ void NotificationPanel::Show() { panel_controller_.reset( new PanelController(this, GTK_WINDOW(panel_widget_->GetNativeView()), - gfx::Rect(0, 0, kBalloonMinWidth, 1))); + gfx::Rect(0, 0, + BalloonCollectionImpl::kBalloonWidth, + 1))); registrar_.Add(this, NotificationType::PANEL_STATE_CHANGED, Source<PanelController>(panel_controller_.get())); } @@ -431,9 +432,8 @@ void NotificationPanel::ResizeNotification( Balloon* balloon, const gfx::Size& size) { // restrict to the min & max sizes gfx::Size real_size( - std::max(kBalloonMinWidth, - std::min(kBalloonMaxWidth, size.width())), - std::max(kBalloonMinHeight, + BalloonCollectionImpl::kBalloonWidth, + std::max(BalloonCollectionImpl::kBalloonMinHeight, std::min(kBalloonMaxHeight, size.height()))); balloon->set_content_size(real_size); static_cast<BalloonViewImpl*>(balloon->view())->Layout(); @@ -532,7 +532,7 @@ void NotificationPanel::UpdatePanel(bool contents_changed) { balloon_container_->UpdateBounds(); scroll_view_->Layout(); } - switch(state_) { + switch (state_) { case KEEP_SIZE: { gfx::Rect min_bounds = GetPreferredBounds(); gfx::Rect panel_bounds; diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h index 521d898..29f3d33 100644 --- a/chrome/browser/notifications/balloon_host.h +++ b/chrome/browser/notifications/balloon_host.h @@ -115,6 +115,8 @@ class BalloonHost : public RenderViewHostDelegate, // Owned pointer to the host for the renderer process. RenderViewHost* render_view_host_; + const Balloon* balloon() const { return balloon_; } + private: // Called to send an event that the balloon has been disconnected from // a renderer (if should_notify_on_disconnect_ is true). diff --git a/chrome/browser/views/notifications/balloon_view_host.cc b/chrome/browser/views/notifications/balloon_view_host.cc index aa45a83..bfb02fa 100644 --- a/chrome/browser/views/notifications/balloon_view_host.cc +++ b/chrome/browser/views/notifications/balloon_view_host.cc @@ -75,6 +75,7 @@ void BalloonViewHost::InitRenderWidgetHostView() { static_cast<RenderWidgetHostViewGtk*>(render_widget_host_view_); view_gtk->InitAsChild(); native_host_->Attach(view_gtk->native_view()); + view_gtk->SetSize(balloon()->content_size()); #else NOTIMPLEMENTED(); #endif |