Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: ash/system/web_notification/web_notification_list.h

Issue 11229022: Move ash/system/web_notification message_center to ui/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ASH_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_LIST_H_
6 #define ASH_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_LIST_H_
7
8 #include <list>
9 #include <string>
10
11 #include "ash/ash_export.h"
12 #include "ash/system/web_notification/web_notification.h"
13
14 namespace message_center {
15
16 // A helper class to manage the list of notifications.
17 class ASH_EXPORT WebNotificationList {
18 public:
19 typedef std::list<WebNotification> Notifications;
20
21 class ASH_EXPORT Delegate {
22 public:
23 Delegate() {}
24 virtual ~Delegate() {}
25
26 // Removes notifications
27 virtual void SendRemoveNotification(const std::string& id) = 0;
28 virtual void SendRemoveAllNotifications() = 0;
29
30 // Disables notifications
31 virtual void DisableNotificationByExtension(const std::string& id) = 0;
32 virtual void DisableNotificationByUrl(const std::string& id) = 0;
33
34 // Requests the Delegate to the settings dialog.
35 virtual void ShowNotificationSettings(const std::string& id) = 0;
36
37 // Called when a notification is clicked on.
38 virtual void OnNotificationClicked(const std::string& id) = 0;
39
40 // Returns the list of notifications to display.
41 virtual WebNotificationList* GetNotificationList() = 0;
42 };
43
44 explicit WebNotificationList(Delegate* delegate);
45 virtual ~WebNotificationList();
46
47 // Affects whether or not a message has been "read".
48 void SetMessageCenterVisible(bool visible);
49
50 void AddNotification(const std::string& id,
51 const string16& title,
52 const string16& message,
53 const string16& display_source,
54 const std::string& extension_id);
55
56 void UpdateNotificationMessage(const std::string& old_id,
57 const std::string& new_id,
58 const string16& title,
59 const string16& message);
60
61 // Returns true if the notification was removed.
62 bool RemoveNotification(const std::string& id);
63
64 void RemoveAllNotifications();
65
66 void SendRemoveNotificationsBySource(const std::string& id);
67
68 void SendRemoveNotificationsByExtension(const std::string& id);
69
70 // Returns true if the notification exists and was updated.
71 bool SetNotificationImage(const std::string& id,
72 const gfx::ImageSkia& image);
73
74 bool HasNotification(const std::string& id);
75
76 // Returns false if the first notification has been shown as a popup (which
77 // means that all notifications have been shown).
78 bool HasPopupNotifications();
79
80 // Modifies |notifications| to contain the |kMaxVisiblePopupNotifications|
81 // least recent notifications that have not been shown as a popup.
82 void GetPopupNotifications(Notifications* notifications);
83
84 // Marks the popups returned by GetPopupNotifications() as shown.
85 void MarkPopupsAsShown();
86
87 const Notifications& notifications() const { return notifications_; }
88 size_t unread_count() const { return unread_count_; }
89
90 static const size_t kMaxVisiblePopupNotifications;
91 static const size_t kMaxVisibleMessageCenterNotifications;
92
93 private:
94 // Iterates through the list and returns the first notification matching |id|
95 // (should always be unique).
96 Notifications::iterator GetNotification(const std::string& id);
97
98 void EraseNotification(Notifications::iterator iter);
99
100 void PushNotification(WebNotification& notification);
101
102 // Returns the |kMaxVisiblePopupNotifications| least recent notifications
103 // that have not been shown as a popup.
104 void GetPopupIterators(Notifications::iterator& first,
105 Notifications::iterator& last);
106
107 Delegate* delegate_;
108 Notifications notifications_;
109 bool message_center_visible_;
110 size_t unread_count_;
111
112 DISALLOW_COPY_AND_ASSIGN(WebNotificationList);
113 };
114
115 } // namespace message_center
116
117 #endif // ASH_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_LIST_H_
OLDNEW
« no previous file with comments | « ash/system/web_notification/web_notification_bubble.cc ('k') | ash/system/web_notification/web_notification_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698