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 #ifndef UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_ | 5 #ifndef UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_ |
6 #define UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_ | 6 #define UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 class MESSAGE_CENTER_EXPORT NotificationList { | 49 class MESSAGE_CENTER_EXPORT NotificationList { |
50 public: | 50 public: |
51 // Auto-sorted set. Matches the order in which Notifications are shown in | 51 // Auto-sorted set. Matches the order in which Notifications are shown in |
52 // Notification Center. | 52 // Notification Center. |
53 typedef std::set<Notification*, ComparePriorityTimestampSerial> Notifications; | 53 typedef std::set<Notification*, ComparePriorityTimestampSerial> Notifications; |
54 | 54 |
55 // Auto-sorted set used to return the Notifications to be shown as popup | 55 // Auto-sorted set used to return the Notifications to be shown as popup |
56 // toasts. | 56 // toasts. |
57 typedef std::set<Notification*, CompareTimestampSerial> PopupNotifications; | 57 typedef std::set<Notification*, CompareTimestampSerial> PopupNotifications; |
58 | 58 |
59 explicit NotificationList(); | 59 explicit NotificationList(MessageCenter* message_center); |
60 virtual ~NotificationList(); | 60 virtual ~NotificationList(); |
61 | 61 |
62 // Affects whether or not a message has been "read". Collects the set of | 62 // Makes a message "read". Collects the set of ids whose state have changed |
63 // ids whose state have changed and set to |udpated_ids|. NULL if updated | 63 // and set to |udpated_ids|. NULL if updated ids don't matter. |
64 // ids don't matter. | 64 void SetNotificationsShown(const NotificationBlockers& blockers, |
65 void SetMessageCenterVisible(bool visible, | 65 std::set<std::string>* updated_ids); |
66 std::set<std::string>* updated_ids); | |
67 | 66 |
68 void AddNotification(std::unique_ptr<Notification> notification); | 67 void AddNotification(std::unique_ptr<Notification> notification); |
69 | 68 |
70 void UpdateNotificationMessage( | 69 void UpdateNotificationMessage( |
71 const std::string& old_id, | 70 const std::string& old_id, |
72 std::unique_ptr<Notification> new_notification); | 71 std::unique_ptr<Notification> new_notification); |
73 | 72 |
74 void RemoveNotification(const std::string& id); | 73 void RemoveNotification(const std::string& id); |
75 | 74 |
76 Notifications GetNotificationsByNotifierId(const NotifierId& notifier_id); | 75 Notifications GetNotificationsByNotifierId(const NotifierId& notifier_id); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // NULL. Notification instance is owned by this list. | 129 // NULL. Notification instance is owned by this list. |
131 Notification* GetNotificationById(const std::string& id); | 130 Notification* GetNotificationById(const std::string& id); |
132 | 131 |
133 // Returns all visible notifications, in a (priority-timestamp) order. | 132 // Returns all visible notifications, in a (priority-timestamp) order. |
134 // Suitable for rendering notifications in a MessageCenter. | 133 // Suitable for rendering notifications in a MessageCenter. |
135 Notifications GetVisibleNotifications( | 134 Notifications GetVisibleNotifications( |
136 const NotificationBlockers& blockers) const; | 135 const NotificationBlockers& blockers) const; |
137 size_t NotificationCount(const NotificationBlockers& blockers) const; | 136 size_t NotificationCount(const NotificationBlockers& blockers) const; |
138 size_t UnreadCount(const NotificationBlockers& blockers) const; | 137 size_t UnreadCount(const NotificationBlockers& blockers) const; |
139 | 138 |
140 bool is_message_center_visible() const { return message_center_visible_; } | |
141 | |
142 private: | 139 private: |
143 friend class NotificationListTest; | 140 friend class NotificationListTest; |
144 FRIEND_TEST_ALL_PREFIXES(NotificationListTest, | 141 FRIEND_TEST_ALL_PREFIXES(NotificationListTest, |
145 TestPushingShownNotification); | 142 TestPushingShownNotification); |
146 | 143 |
147 // Iterates through the list and returns the first notification matching |id|. | 144 // Iterates through the list and returns the first notification matching |id|. |
148 Notifications::iterator GetNotification(const std::string& id); | 145 Notifications::iterator GetNotification(const std::string& id); |
149 | 146 |
150 void EraseNotification(Notifications::iterator iter); | 147 void EraseNotification(Notifications::iterator iter); |
151 | 148 |
152 void PushNotification(std::unique_ptr<Notification> notification); | 149 void PushNotification(std::unique_ptr<Notification> notification); |
153 | 150 |
| 151 MessageCenter* message_center_; // owner |
154 Notifications notifications_; | 152 Notifications notifications_; |
155 bool message_center_visible_; | |
156 bool quiet_mode_; | 153 bool quiet_mode_; |
157 | 154 |
158 DISALLOW_COPY_AND_ASSIGN(NotificationList); | 155 DISALLOW_COPY_AND_ASSIGN(NotificationList); |
159 }; | 156 }; |
160 | 157 |
161 } // namespace message_center | 158 } // namespace message_center |
162 | 159 |
163 #endif // UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_ | 160 #endif // UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_ |
OLD | NEW |