summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/cocoa/notifications/balloon_controller_unittest.mm1
-rw-r--r--chrome/browser/gtk/notifications/balloon_view_gtk.cc2
-rw-r--r--chrome/browser/gtk/notifications/balloon_view_gtk.h4
-rw-r--r--chrome/browser/notifications/balloon_collection.cc5
-rw-r--r--chrome/browser/notifications/balloon_collection.h3
-rw-r--r--chrome/browser/notifications/balloon_collection_impl.h1
-rw-r--r--chrome/browser/notifications/balloon_collection_linux.cc2
-rw-r--r--chrome/browser/notifications/balloon_collection_win.cc2
-rw-r--r--chrome/browser/notifications/desktop_notifications_unittest.h1
-rw-r--r--chrome/browser/views/notifications/balloon_view.cc9
-rw-r--r--chrome/browser/views/notifications/balloon_view.h11
11 files changed, 34 insertions, 7 deletions
diff --git a/chrome/browser/cocoa/notifications/balloon_controller_unittest.mm b/chrome/browser/cocoa/notifications/balloon_controller_unittest.mm
index bd5d1cd..d9f9c8f 100644
--- a/chrome/browser/cocoa/notifications/balloon_controller_unittest.mm
+++ b/chrome/browser/cocoa/notifications/balloon_controller_unittest.mm
@@ -21,6 +21,7 @@ class MockBalloonCollection : public BalloonCollection {
virtual bool Remove(const Notification& notification) { return false; }
virtual bool HasSpace() const { return true; }
virtual void ResizeBalloon(Balloon* balloon, const gfx::Size& size) {};
+ virtual void DisplayChanged() {}
virtual void OnBalloonClosed(Balloon* source) {};
};
diff --git a/chrome/browser/gtk/notifications/balloon_view_gtk.cc b/chrome/browser/gtk/notifications/balloon_view_gtk.cc
index dbae12a..e022b5e 100644
--- a/chrome/browser/gtk/notifications/balloon_view_gtk.cc
+++ b/chrome/browser/gtk/notifications/balloon_view_gtk.cc
@@ -83,7 +83,7 @@ const int kDefaultShelfHeight = 24;
} // namespace
-BalloonViewImpl::BalloonViewImpl()
+BalloonViewImpl::BalloonViewImpl(BalloonCollection* collection)
: balloon_(NULL),
frame_container_(NULL),
html_container_(NULL),
diff --git a/chrome/browser/gtk/notifications/balloon_view_gtk.h b/chrome/browser/gtk/notifications/balloon_view_gtk.h
index b0cf8ed..a6ea598 100644
--- a/chrome/browser/gtk/notifications/balloon_view_gtk.h
+++ b/chrome/browser/gtk/notifications/balloon_view_gtk.h
@@ -18,7 +18,7 @@
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
-
+class BalloonCollection;
class BalloonViewHost;
class MenuGtk;
class NineBox;
@@ -34,7 +34,7 @@ class BalloonViewImpl : public BalloonView,
public NotificationObserver,
public AnimationDelegate {
public:
- BalloonViewImpl();
+ explicit BalloonViewImpl(BalloonCollection* collection);
~BalloonViewImpl();
// BalloonView interface.
diff --git a/chrome/browser/notifications/balloon_collection.cc b/chrome/browser/notifications/balloon_collection.cc
index b8b7e9f..3d516ef 100644
--- a/chrome/browser/notifications/balloon_collection.cc
+++ b/chrome/browser/notifications/balloon_collection.cc
@@ -90,6 +90,11 @@ void BalloonCollectionImpl::ResizeBalloon(Balloon* balloon,
PositionBalloons(true);
}
+void BalloonCollectionImpl::DisplayChanged() {
+ layout_.RefreshSystemMetrics();
+ PositionBalloons(true);
+}
+
void BalloonCollectionImpl::OnBalloonClosed(Balloon* source) {
// We want to free the balloon when finished.
scoped_ptr<Balloon> closed(source);
diff --git a/chrome/browser/notifications/balloon_collection.h b/chrome/browser/notifications/balloon_collection.h
index ff37a12..998142b 100644
--- a/chrome/browser/notifications/balloon_collection.h
+++ b/chrome/browser/notifications/balloon_collection.h
@@ -48,6 +48,9 @@ class BalloonCollection {
// Request the resizing of a balloon.
virtual void ResizeBalloon(Balloon* balloon, const gfx::Size& size) = 0;
+ // Update for new screen dimensions.
+ virtual void DisplayChanged() = 0;
+
// Inform the collection that a balloon was closed.
virtual void OnBalloonClosed(Balloon* source) = 0;
diff --git a/chrome/browser/notifications/balloon_collection_impl.h b/chrome/browser/notifications/balloon_collection_impl.h
index c8eef59..ba54b51 100644
--- a/chrome/browser/notifications/balloon_collection_impl.h
+++ b/chrome/browser/notifications/balloon_collection_impl.h
@@ -29,6 +29,7 @@ class BalloonCollectionImpl : public BalloonCollection {
virtual bool Remove(const Notification& notification);
virtual bool HasSpace() const;
virtual void ResizeBalloon(Balloon* balloon, const gfx::Size& size);
+ virtual void DisplayChanged();
virtual void OnBalloonClosed(Balloon* source);
protected:
diff --git a/chrome/browser/notifications/balloon_collection_linux.cc b/chrome/browser/notifications/balloon_collection_linux.cc
index 5d0c2b7..54cd7ee 100644
--- a/chrome/browser/notifications/balloon_collection_linux.cc
+++ b/chrome/browser/notifications/balloon_collection_linux.cc
@@ -12,7 +12,7 @@ Balloon* BalloonCollectionImpl::MakeBalloon(const Notification& notification,
Profile* profile) {
Balloon* balloon = new Balloon(notification, profile, this);
- balloon->set_view(new BalloonViewImpl());
+ balloon->set_view(new BalloonViewImpl(this));
gfx::Size size(layout_.min_balloon_width(), layout_.min_balloon_height());
balloon->set_content_size(size);
return balloon;
diff --git a/chrome/browser/notifications/balloon_collection_win.cc b/chrome/browser/notifications/balloon_collection_win.cc
index 405ea04..e8b60e0 100644
--- a/chrome/browser/notifications/balloon_collection_win.cc
+++ b/chrome/browser/notifications/balloon_collection_win.cc
@@ -11,7 +11,7 @@
Balloon* BalloonCollectionImpl::MakeBalloon(const Notification& notification,
Profile* profile) {
Balloon* balloon = new Balloon(notification, profile, this);
- balloon->set_view(new BalloonViewImpl());
+ balloon->set_view(new BalloonViewImpl(this));
gfx::Size size(layout_.min_balloon_width(), layout_.min_balloon_height());
balloon->set_content_size(size);
return balloon;
diff --git a/chrome/browser/notifications/desktop_notifications_unittest.h b/chrome/browser/notifications/desktop_notifications_unittest.h
index 927e519..54131e5 100644
--- a/chrome/browser/notifications/desktop_notifications_unittest.h
+++ b/chrome/browser/notifications/desktop_notifications_unittest.h
@@ -71,6 +71,7 @@ class MockBalloonCollection : public BalloonCollectionImpl {
virtual bool HasSpace() const { return count() < kMockBalloonSpace; }
virtual Balloon* MakeBalloon(const Notification& notification,
Profile* profile);
+ virtual void DisplayChanged() {}
virtual void OnBalloonClosed(Balloon* source);
// Number of balloons being shown.
diff --git a/chrome/browser/views/notifications/balloon_view.cc b/chrome/browser/views/notifications/balloon_view.cc
index f101669..9292de4 100644
--- a/chrome/browser/views/notifications/balloon_view.cc
+++ b/chrome/browser/views/notifications/balloon_view.cc
@@ -15,6 +15,7 @@
#include "base/string_util.h"
#include "chrome/browser/browser_theme_provider.h"
#include "chrome/browser/notifications/balloon.h"
+#include "chrome/browser/notifications/balloon_collection.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_view_host.h"
@@ -95,8 +96,9 @@ class BalloonCloseButtonListener : public views::ButtonListener {
BalloonView* view_;
};
-BalloonViewImpl::BalloonViewImpl()
+BalloonViewImpl::BalloonViewImpl(BalloonCollection* collection)
: balloon_(NULL),
+ collection_(collection),
frame_container_(NULL),
html_container_(NULL),
html_contents_(NULL),
@@ -148,6 +150,10 @@ void BalloonViewImpl::RunMenu(views::View* source, const gfx::Point& pt) {
RunOptionsMenu(pt);
}
+void BalloonViewImpl::DisplayChanged() {
+ collection_->DisplayChanged();
+}
+
void BalloonViewImpl::DelayedClose(bool by_user) {
html_contents_->Shutdown();
html_container_->CloseNow();
@@ -315,6 +321,7 @@ void BalloonViewImpl::Show(Balloon* balloon) {
frame_container_ = Widget::CreatePopupWidget(Widget::Transparent,
Widget::AcceptEvents,
Widget::DeleteOnDestroy);
+ frame_container_->SetWidgetDelegate(this);
frame_container_->SetAlwaysOnTop(true);
frame_container_->Init(NULL, balloon_rect);
frame_container_->SetContentsView(this);
diff --git a/chrome/browser/views/notifications/balloon_view.h b/chrome/browser/views/notifications/balloon_view.h
index 84147ad..6d8da54 100644
--- a/chrome/browser/views/notifications/balloon_view.h
+++ b/chrome/browser/views/notifications/balloon_view.h
@@ -23,6 +23,7 @@
#include "views/controls/label.h"
#include "views/controls/menu/view_menu_delegate.h"
#include "views/view.h"
+#include "views/widget/widget_delegate.h"
namespace views {
class ButtonListener;
@@ -32,6 +33,7 @@ class WidgetWin;
class Menu2;
} // namespace views
+class BalloonCollection;
class BalloonViewHost;
class NotificationDetails;
class NotificationSource;
@@ -42,11 +44,12 @@ class SlideAnimation;
class BalloonViewImpl : public BalloonView,
public views::View,
public views::ViewMenuDelegate,
+ public views::WidgetDelegate,
public menus::SimpleMenuModel::Delegate,
public NotificationObserver,
public AnimationDelegate {
public:
- BalloonViewImpl();
+ explicit BalloonViewImpl(BalloonCollection* collection);
~BalloonViewImpl();
// BalloonView interface.
@@ -67,6 +70,9 @@ class BalloonViewImpl : public BalloonView,
// views::ViewMenuDelegate interface.
void RunMenu(views::View* source, const gfx::Point& pt);
+ // views::WidgetDelegate interface.
+ void DisplayChanged();
+
// menus::SimpleMenuModel::Delegate interface.
virtual bool IsCommandIdChecked(int command_id) const;
virtual bool IsCommandIdEnabled(int command_id) const;
@@ -128,6 +134,9 @@ class BalloonViewImpl : public BalloonView,
// Non-owned pointer to the balloon which owns this object.
Balloon* balloon_;
+ // Non-owned pointer to the balloon collection this is a part of.
+ BalloonCollection* collection_;
+
// The window that contains the frame of the notification.
// Pointer owned by the View subclass.
views::Widget* frame_container_;