OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // Handles the visible notification (or balloons). | 5 // Handles the visible notification (or balloons). |
6 | 6 |
7 #ifndef CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_H_ | 7 #ifndef CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_H_ |
8 #define CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_H_ | 8 #define CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_H_ |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
11 | 11 |
12 #include "base/gfx/point.h" | 12 #include "base/gfx/point.h" |
13 #include "base/gfx/rect.h" | 13 #include "base/gfx/rect.h" |
14 #include "base/gfx/size.h" | 14 #include "base/gfx/size.h" |
15 #include "chrome/browser/notifications/balloon.h" | 15 #include "chrome/browser/notifications/balloon.h" |
16 #include "chrome/browser/notifications/notification.h" | 16 #include "chrome/browser/notifications/notification.h" |
17 | 17 |
18 class Balloon; | 18 class Balloon; |
19 class Profile; | 19 class Profile; |
20 | 20 |
21 class BalloonCollection { | 21 class BalloonCollection { |
22 public: | 22 public: |
23 virtual ~BalloonCollection() {} | 23 virtual ~BalloonCollection() {} |
24 | 24 |
25 // Adds a new balloon for the specified notification. | 25 // Adds a new balloon for the specified notification. |
26 virtual void Add(const Notification& notification, | 26 virtual void Add(const Notification& notification, |
27 Profile* profile) = 0; | 27 Profile* profile) = 0; |
28 | 28 |
| 29 // Removes a balloon from the collection if present. Returns |
| 30 // true if anything was removed. |
| 31 virtual bool Remove(const Notification& notification) = 0; |
| 32 |
29 // Is there room to add another notification? | 33 // Is there room to add another notification? |
30 virtual bool HasSpace() const = 0; | 34 virtual bool HasSpace() const = 0; |
31 }; | 35 }; |
32 | 36 |
33 // A balloon collection represents a set of notification balloons being | 37 // A balloon collection represents a set of notification balloons being |
34 // shown on the screen. It positions new notifications according to | 38 // shown on the screen. It positions new notifications according to |
35 // a layout, and monitors for balloons being closed, which it reports | 39 // a layout, and monitors for balloons being closed, which it reports |
36 // up to its parent, the notification UI manager. | 40 // up to its parent, the notification UI manager. |
37 class BalloonCollectionImpl : public BalloonCollection, | 41 class BalloonCollectionImpl : public BalloonCollection, |
38 public Balloon::BalloonCloseListener { | 42 public Balloon::BalloonCloseListener { |
(...skipping 13 matching lines...) Expand all Loading... |
52 BalloonSpaceChangeListener* space_change_listener() { | 56 BalloonSpaceChangeListener* space_change_listener() { |
53 return space_change_listener_; | 57 return space_change_listener_; |
54 } | 58 } |
55 void set_space_change_listener(BalloonSpaceChangeListener* listener) { | 59 void set_space_change_listener(BalloonSpaceChangeListener* listener) { |
56 space_change_listener_ = listener; | 60 space_change_listener_ = listener; |
57 } | 61 } |
58 | 62 |
59 // BalloonCollectionInterface overrides | 63 // BalloonCollectionInterface overrides |
60 virtual void Add(const Notification& notification, | 64 virtual void Add(const Notification& notification, |
61 Profile* profile); | 65 Profile* profile); |
| 66 virtual bool Remove(const Notification& notification); |
62 virtual bool HasSpace() const; | 67 virtual bool HasSpace() const; |
63 | 68 |
64 // Balloon::BalloonCloseListener interface | 69 // Balloon::BalloonCloseListener interface |
65 virtual void OnBalloonClosed(Balloon* source); | 70 virtual void OnBalloonClosed(Balloon* source); |
66 | 71 |
67 protected: | 72 protected: |
68 // Creates a new balloon. Overridable by unit tests. The caller is | 73 // Creates a new balloon. Overridable by unit tests. The caller is |
69 // responsible for freeing the pointer returned. | 74 // responsible for freeing the pointer returned. |
70 virtual Balloon* MakeBalloon(const Notification& notification, | 75 virtual Balloon* MakeBalloon(const Notification& notification, |
71 Profile* profile); | 76 Profile* profile); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 typedef std::deque<Balloon*> Balloons; | 147 typedef std::deque<Balloon*> Balloons; |
143 Balloons balloons_; | 148 Balloons balloons_; |
144 | 149 |
145 // The layout parameters for balloons in this collection. | 150 // The layout parameters for balloons in this collection. |
146 Layout layout_; | 151 Layout layout_; |
147 | 152 |
148 DISALLOW_COPY_AND_ASSIGN(BalloonCollectionImpl); | 153 DISALLOW_COPY_AND_ASSIGN(BalloonCollectionImpl); |
149 }; | 154 }; |
150 | 155 |
151 #endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_H_ | 156 #endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_H_ |
OLD | NEW |