| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_COLLECTION_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_COLLECTION_IMPL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_COLLECTION_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_COLLECTION_IMPL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "chrome/browser/chromeos/notifications/balloon_view_host.h" | 13 #include "chrome/browser/chromeos/notifications/balloon_view_host.h" |
| 14 #include "chrome/browser/notifications/balloon_collection.h" | 14 #include "chrome/browser/notifications/balloon_collection.h" |
| 15 #include "chrome/browser/notifications/balloon_collection_base.h" |
| 15 #include "chrome/common/notification_registrar.h" | 16 #include "chrome/common/notification_registrar.h" |
| 16 #include "gfx/point.h" | 17 #include "gfx/point.h" |
| 17 #include "gfx/rect.h" | 18 #include "gfx/rect.h" |
| 18 | 19 |
| 19 namespace gfx { | 20 namespace gfx { |
| 20 class Size; | 21 class Size; |
| 21 } // namespace gfx | 22 } // namespace gfx |
| 22 | 23 |
| 23 namespace chromeos { | 24 namespace chromeos { |
| 24 | 25 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 53 private: | 54 private: |
| 54 DISALLOW_COPY_AND_ASSIGN(NotificationUI); | 55 DISALLOW_COPY_AND_ASSIGN(NotificationUI); |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 BalloonCollectionImpl(); | 58 BalloonCollectionImpl(); |
| 58 virtual ~BalloonCollectionImpl(); | 59 virtual ~BalloonCollectionImpl(); |
| 59 | 60 |
| 60 // BalloonCollectionInterface overrides | 61 // BalloonCollectionInterface overrides |
| 61 virtual void Add(const Notification& notification, | 62 virtual void Add(const Notification& notification, |
| 62 Profile* profile); | 63 Profile* profile); |
| 63 virtual bool Remove(const Notification& notification); | 64 virtual bool RemoveById(const std::string& id); |
| 65 virtual bool RemoveBySourceOrigin(const GURL& origin); |
| 64 virtual bool HasSpace() const; | 66 virtual bool HasSpace() const; |
| 65 virtual void ResizeBalloon(Balloon* balloon, const gfx::Size& size); | 67 virtual void ResizeBalloon(Balloon* balloon, const gfx::Size& size); |
| 66 virtual void DisplayChanged() {} | 68 virtual void DisplayChanged() {} |
| 67 virtual void OnBalloonClosed(Balloon* source); | 69 virtual void OnBalloonClosed(Balloon* source); |
| 68 virtual const Balloons& GetActiveBalloons() { return balloons_; } | 70 virtual const Balloons& GetActiveBalloons() { return base_.balloons(); } |
| 69 | 71 |
| 70 // NotificationObserver overrides: | 72 // NotificationObserver overrides: |
| 71 virtual void Observe(NotificationType type, | 73 virtual void Observe(NotificationType type, |
| 72 const NotificationSource& source, | 74 const NotificationSource& source, |
| 73 const NotificationDetails& details); | 75 const NotificationDetails& details); |
| 74 | 76 |
| 75 // Adds a callback for DOMUI message. Returns true if the callback | 77 // Adds a callback for DOMUI message. Returns true if the callback |
| 76 // is succssfully registered, or false otherwise. It fails to add if | 78 // is succssfully registered, or false otherwise. It fails to add if |
| 77 // there is no notification that matches NotificationDelegate::id(), | 79 // there is no notification that matches NotificationDelegate::id(), |
| 78 // or a callback for given message already exists. The callback | 80 // or a callback for given message already exists. The callback |
| (...skipping 29 matching lines...) Expand all Loading... |
| 108 NotificationUI* notification_ui() { | 110 NotificationUI* notification_ui() { |
| 109 return notification_ui_.get(); | 111 return notification_ui_.get(); |
| 110 } | 112 } |
| 111 | 113 |
| 112 protected: | 114 protected: |
| 113 // Creates a new balloon. Overridable by unit tests. The caller is | 115 // Creates a new balloon. Overridable by unit tests. The caller is |
| 114 // responsible for freeing the pointer returned. | 116 // responsible for freeing the pointer returned. |
| 115 virtual Balloon* MakeBalloon(const Notification& notification, | 117 virtual Balloon* MakeBalloon(const Notification& notification, |
| 116 Profile* profile); | 118 Profile* profile); |
| 117 | 119 |
| 120 // Base implementation for the collection of active balloons. |
| 121 BalloonCollectionBase base_; |
| 122 |
| 118 private: | 123 private: |
| 119 friend class NotificationPanelTester; | 124 friend class NotificationPanelTester; |
| 120 | 125 |
| 121 // Shutdown the notification ui. | 126 // Shutdown the notification ui. |
| 122 void Shutdown(); | 127 void Shutdown(); |
| 123 | 128 |
| 124 // The number of balloons being displayed. | 129 Balloon* FindBalloon(const Notification& notification) { |
| 125 int count() const { return balloons_.size(); } | 130 return base_.FindBalloon(notification); |
| 126 | 131 } |
| 127 Balloons::iterator FindBalloon(const Notification& notification); | |
| 128 | |
| 129 // Queue of active balloons. | |
| 130 Balloons balloons_; | |
| 131 | 132 |
| 132 scoped_ptr<NotificationUI> notification_ui_; | 133 scoped_ptr<NotificationUI> notification_ui_; |
| 133 | 134 |
| 134 NotificationRegistrar registrar_; | 135 NotificationRegistrar registrar_; |
| 135 | 136 |
| 136 DISALLOW_COPY_AND_ASSIGN(BalloonCollectionImpl); | 137 DISALLOW_COPY_AND_ASSIGN(BalloonCollectionImpl); |
| 137 }; | 138 }; |
| 138 | 139 |
| 139 } // namespace chromeos | 140 } // namespace chromeos |
| 140 | 141 |
| 141 #endif // CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_COLLECTION_IMPL_H_ | 142 #endif // CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_COLLECTION_IMPL_H_ |
| OLD | NEW |