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