| Index: ui/message_center/notification_list.h
|
| diff --git a/ui/message_center/notification_list.h b/ui/message_center/notification_list.h
|
| index ec8b4db65d362f5facbefb4482c0efcd778490a6..3d3771317d350fb80c41f6579027f151c1361006 100644
|
| --- a/ui/message_center/notification_list.h
|
| +++ b/ui/message_center/notification_list.h
|
| @@ -5,8 +5,7 @@
|
| #ifndef UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_
|
| #define UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_
|
|
|
| -#include <list>
|
| -#include <map>
|
| +#include <set>
|
| #include <string>
|
|
|
| #include "base/string16.h"
|
| @@ -16,7 +15,7 @@
|
| #include "ui/gfx/native_widget_types.h"
|
| #include "ui/message_center/message_center_export.h"
|
| #include "ui/message_center/notification.h"
|
| -#include "ui/notifications/notification_types.h"
|
| +#include "ui/message_center/notification_types.h"
|
|
|
| namespace base {
|
| class DictionaryValue;
|
| @@ -24,10 +23,25 @@ class DictionaryValue;
|
|
|
| namespace message_center {
|
|
|
| +// Comparers used to auto-sort the lists of Notifications.
|
| +struct ComparePriorityTimestampSerial {
|
| + bool operator()(Notification* n1, Notification* n2);
|
| +};
|
| +
|
| +struct CompareTimestampSerial {
|
| + bool operator()(Notification* n1, Notification* n2);
|
| +};
|
| +
|
| // A helper class to manage the list of notifications.
|
| class MESSAGE_CENTER_EXPORT NotificationList {
|
| public:
|
| - typedef std::list<Notification> Notifications;
|
| + // Auto-sorted set. Matches the order in which Notifications are shown in
|
| + // Notification Center.
|
| + typedef std::set<Notification*, ComparePriorityTimestampSerial> Notifications;
|
| +
|
| + // Auto-sorted set used to return the Notifications to be shown as popup
|
| + // toasts.
|
| + typedef std::set<Notification*, CompareTimestampSerial> PopupNotifications;
|
|
|
| class MESSAGE_CENTER_EXPORT Delegate {
|
| public:
|
| @@ -69,7 +83,7 @@ class MESSAGE_CENTER_EXPORT NotificationList {
|
| // Affects whether or not a message has been "read".
|
| void SetMessageCenterVisible(bool visible);
|
|
|
| - void AddNotification(ui::notifications::NotificationType type,
|
| + void AddNotification(NotificationType type,
|
| const std::string& id,
|
| const string16& title,
|
| const string16& message,
|
| @@ -83,8 +97,7 @@ class MESSAGE_CENTER_EXPORT NotificationList {
|
| const string16& message,
|
| const base::DictionaryValue* optional_fields);
|
|
|
| - // Returns true if the notification was removed.
|
| - bool RemoveNotification(const std::string& id);
|
| + void RemoveNotification(const std::string& id);
|
|
|
| void RemoveAllNotifications();
|
|
|
| @@ -111,9 +124,11 @@ class MESSAGE_CENTER_EXPORT NotificationList {
|
| // means that all notifications have been shown).
|
| bool HasPopupNotifications();
|
|
|
| - // Modifies |notifications| to contain the |kMaxVisiblePopupNotifications|
|
| - // least recent notifications that have not been shown as a popup.
|
| - void GetPopupNotifications(Notifications* notifications);
|
| + // Returns the recent notifications of the priority higher then LOW,
|
| + // that have not been shown as a popup. kMaxVisiblePopupNotifications are
|
| + // used to limit the number of notifications for the DEFAULT priority.
|
| + // The returned list is sorted by timestamp, newer first.
|
| + PopupNotifications GetPopupNotifications();
|
|
|
| // Marks the popups for the |priority| as shown.
|
| void MarkPopupsAsShown(int priority);
|
| @@ -133,7 +148,9 @@ class MESSAGE_CENTER_EXPORT NotificationList {
|
| // specified time-delta from now.
|
| void EnterQuietModeWithExpire(const base::TimeDelta& expires_in);
|
|
|
| - void GetNotifications(Notifications* notifications) const;
|
| + // Returns all notifications, in a (priority-timestamp) order. Suitable for
|
| + // rendering notifications in a NotificationCenter.
|
| + const Notifications& GetNotifications();
|
| size_t NotificationCount() const;
|
| size_t unread_count() const { return unread_count_; }
|
|
|
| @@ -141,35 +158,18 @@ class MESSAGE_CENTER_EXPORT NotificationList {
|
| static const size_t kMaxVisibleMessageCenterNotifications;
|
|
|
| private:
|
| - typedef std::map<int, Notifications> NotificationMap;
|
| -
|
| - // Iterates through the list and stores the first notification matching |id|
|
| - // (should always be unique) to |iter|. Returns true if it's found.
|
| - bool GetNotification(const std::string& id, Notifications::iterator* iter);
|
| + // Iterates through the list and returns the first notification matching |id|.
|
| + Notifications::iterator GetNotification(const std::string& id);
|
|
|
| void EraseNotification(Notifications::iterator iter);
|
|
|
| - void PushNotification(Notification& notification);
|
| -
|
| - // Returns the recent notifications of the |priority| that have not been shown
|
| - // as a popup. kMaxVisiblePopupNotifications are used to limit the number of
|
| - // notifications for the default priority.
|
| - void GetPopupIterators(int priority,
|
| - Notifications::iterator* first,
|
| - Notifications::iterator* last);
|
| -
|
| - // Given a dictionary of optional notification fields (or NULL), unpacks all
|
| - // recognized values into the given Notification struct. We assume prior
|
| - // proper initialization of |notification| fields that correspond to
|
| - // |optional_fields|.
|
| - void UnpackOptionalFields(const base::DictionaryValue* optional_fields,
|
| - Notification* notification);
|
| + void PushNotification(scoped_ptr<Notification> notification);
|
|
|
| // Sets the current quiet mode status to |quiet_mode|.
|
| void SetQuietModeInternal(bool quiet_mode);
|
|
|
| Delegate* delegate_;
|
| - NotificationMap notifications_;
|
| + Notifications notifications_;
|
| bool message_center_visible_;
|
| size_t unread_count_;
|
| bool quiet_mode_;
|
|
|