OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BASE_H_ | 7 #ifndef CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_BASE_H_ |
8 #define CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_BASE_H_ | 8 #define CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_BASE_H_ |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 | 14 |
15 class Balloon; | 15 class Balloon; |
16 class GURL; | 16 class GURL; |
17 class Notification; | 17 class Notification; |
| 18 class Profile; |
18 | 19 |
19 // This class provides support for implementing a BalloonCollection | 20 // This class provides support for implementing a BalloonCollection |
20 // including the parts common between Chrome UI and ChromeOS UI. | 21 // including the parts common between Chrome UI and ChromeOS UI. |
21 class BalloonCollectionBase { | 22 class BalloonCollectionBase { |
22 public: | 23 public: |
23 BalloonCollectionBase(); | 24 BalloonCollectionBase(); |
24 virtual ~BalloonCollectionBase(); | 25 virtual ~BalloonCollectionBase(); |
25 | 26 |
26 typedef std::deque<Balloon*> Balloons; | 27 typedef std::deque<Balloon*> Balloons; |
27 | 28 |
28 // Adds a balloon to the collection. Takes ownership of pointer. | 29 // Adds a balloon to the collection. Takes ownership of pointer. |
29 virtual void Add(Balloon* balloon, bool add_to_front); | 30 virtual void Add(Balloon* balloon, bool add_to_front); |
30 | 31 |
31 // Removes a balloon from the collection (if present). Frees | 32 // Removes a balloon from the collection (if present). Frees |
32 // the pointer after removal. | 33 // the pointer after removal. |
33 virtual void Remove(Balloon* balloon); | 34 virtual void Remove(Balloon* balloon); |
34 | 35 |
35 // Finds any balloon matching the given notification id, and | 36 // Finds any balloon matching the given notification id, and |
36 // calls CloseByScript on it. Returns true if anything was | 37 // calls CloseByScript on it. Returns true if anything was |
37 // found. | 38 // found. |
38 virtual bool CloseById(const std::string& id); | 39 virtual bool CloseById(const std::string& id); |
39 | 40 |
40 // Finds all balloons matching the given notification source, | 41 // Finds all balloons matching the given notification source, |
41 // and calls CloseByScript on them. Returns true if anything | 42 // and calls CloseByScript on them. Returns true if anything |
42 // was found. | 43 // was found. |
43 virtual bool CloseAllBySourceOrigin(const GURL& source_origin); | 44 virtual bool CloseAllBySourceOrigin(const GURL& source_origin); |
44 | 45 |
| 46 // Finds all balloons matching the given profile and calls CloseByScript |
| 47 // on them. Returns true if anything was found. |
| 48 virtual bool CloseAllByProfile(Profile* profile); |
| 49 |
45 // Calls CloseByScript on all balloons. | 50 // Calls CloseByScript on all balloons. |
46 virtual void CloseAll(); | 51 virtual void CloseAll(); |
47 | 52 |
48 const Balloons& balloons() const { return balloons_; } | 53 const Balloons& balloons() const { return balloons_; } |
49 | 54 |
50 // Returns the balloon matching the given notification id, or | 55 // Returns the balloon matching the given notification id, or |
51 // NULL if there is no matching balloon. | 56 // NULL if there is no matching balloon. |
52 Balloon* FindBalloonById(const std::string& notification_id); | 57 Balloon* FindBalloonById(const std::string& notification_id); |
53 | 58 |
54 // Returns the balloon matching the given notification, or | 59 // Returns the balloon matching the given notification, or |
55 // NULL if there is no matching balloon. | 60 // NULL if there is no matching balloon. |
56 Balloon* FindBalloon(const Notification& notification); | 61 Balloon* FindBalloon(const Notification& notification); |
57 | 62 |
58 // The number of balloons being displayed. | 63 // The number of balloons being displayed. |
59 int count() const { return static_cast<int>(balloons_.size()); } | 64 int count() const { return static_cast<int>(balloons_.size()); } |
60 | 65 |
61 private: | 66 private: |
62 // Queue of active balloons. Pointers are owned by this class. | 67 // Queue of active balloons. Pointers are owned by this class. |
63 Balloons balloons_; | 68 Balloons balloons_; |
64 | 69 |
65 DISALLOW_COPY_AND_ASSIGN(BalloonCollectionBase); | 70 DISALLOW_COPY_AND_ASSIGN(BalloonCollectionBase); |
66 }; | 71 }; |
67 | 72 |
68 #endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_BASE_H_ | 73 #endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_BASE_H_ |
OLD | NEW |