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

Side by Side Diff: ui/message_center/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
« no previous file with comments | « ui/message_center/message_view.cc ('k') | ui/message_center/notification_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 ASH_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_LIST_H_ 5 #ifndef UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_
6 #define ASH_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_LIST_H_ 6 #define UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
11 #include "ash/ash_export.h" 11 #include "base/string16.h"
12 #include "ash/system/web_notification/web_notification.h" 12 #include "ui/gfx/image/image_skia.h"
13 #include "ui/message_center/message_center_export.h"
13 14
14 namespace message_center { 15 namespace message_center {
15 16
16 // A helper class to manage the list of notifications. 17 // A helper class to manage the list of notifications.
17 class ASH_EXPORT WebNotificationList { 18 class MESSAGE_CENTER_EXPORT NotificationList {
18 public: 19 public:
19 typedef std::list<WebNotification> Notifications; 20 struct MESSAGE_CENTER_EXPORT Notification {
21 Notification();
22 virtual ~Notification();
20 23
21 class ASH_EXPORT Delegate { 24 std::string id;
25 string16 title;
26 string16 message;
27 string16 display_source;
28 std::string extension_id;
29 gfx::ImageSkia image;
30 bool is_read; // True if this has been seen in the message center
31 bool shown_as_popup; // True if this has been shown as a popup notification
32 };
33
34 typedef std::list<Notification> Notifications;
35
36 class MESSAGE_CENTER_EXPORT Delegate {
22 public: 37 public:
23 Delegate() {} 38 Delegate() {}
24 virtual ~Delegate() {} 39 virtual ~Delegate() {}
25 40
26 // Removes notifications 41 // Removes notifications
27 virtual void SendRemoveNotification(const std::string& id) = 0; 42 virtual void SendRemoveNotification(const std::string& id) = 0;
28 virtual void SendRemoveAllNotifications() = 0; 43 virtual void SendRemoveAllNotifications() = 0;
29 44
30 // Disables notifications 45 // Disables notifications
31 virtual void DisableNotificationByExtension(const std::string& id) = 0; 46 virtual void DisableNotificationByExtension(const std::string& id) = 0;
32 virtual void DisableNotificationByUrl(const std::string& id) = 0; 47 virtual void DisableNotificationByUrl(const std::string& id) = 0;
33 48
34 // Requests the Delegate to the settings dialog. 49 // Requests the Delegate to the settings dialog.
35 virtual void ShowNotificationSettings(const std::string& id) = 0; 50 virtual void ShowNotificationSettings(const std::string& id) = 0;
36 51
37 // Called when a notification is clicked on. 52 // Called when a notification is clicked on.
38 virtual void OnNotificationClicked(const std::string& id) = 0; 53 virtual void OnNotificationClicked(const std::string& id) = 0;
39 54
40 // Returns the list of notifications to display. 55 // Returns the list of notifications to display.
41 virtual WebNotificationList* GetNotificationList() = 0; 56 virtual NotificationList* GetNotificationList() = 0;
42 }; 57 };
43 58
44 explicit WebNotificationList(Delegate* delegate); 59 explicit NotificationList(Delegate* delegate);
45 virtual ~WebNotificationList(); 60 virtual ~NotificationList();
46 61
47 // Affects whether or not a message has been "read". 62 // Affects whether or not a message has been "read".
48 void SetMessageCenterVisible(bool visible); 63 void SetMessageCenterVisible(bool visible);
49 64
50 void AddNotification(const std::string& id, 65 void AddNotification(const std::string& id,
51 const string16& title, 66 const string16& title,
52 const string16& message, 67 const string16& message,
53 const string16& display_source, 68 const string16& display_source,
54 const std::string& extension_id); 69 const std::string& extension_id);
55 70
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 static const size_t kMaxVisiblePopupNotifications; 105 static const size_t kMaxVisiblePopupNotifications;
91 static const size_t kMaxVisibleMessageCenterNotifications; 106 static const size_t kMaxVisibleMessageCenterNotifications;
92 107
93 private: 108 private:
94 // Iterates through the list and returns the first notification matching |id| 109 // Iterates through the list and returns the first notification matching |id|
95 // (should always be unique). 110 // (should always be unique).
96 Notifications::iterator GetNotification(const std::string& id); 111 Notifications::iterator GetNotification(const std::string& id);
97 112
98 void EraseNotification(Notifications::iterator iter); 113 void EraseNotification(Notifications::iterator iter);
99 114
100 void PushNotification(WebNotification& notification); 115 void PushNotification(Notification& notification);
101 116
102 // Returns the |kMaxVisiblePopupNotifications| least recent notifications 117 // Returns the |kMaxVisiblePopupNotifications| least recent notifications
103 // that have not been shown as a popup. 118 // that have not been shown as a popup.
104 void GetPopupIterators(Notifications::iterator& first, 119 void GetPopupIterators(Notifications::iterator& first,
105 Notifications::iterator& last); 120 Notifications::iterator& last);
106 121
107 Delegate* delegate_; 122 Delegate* delegate_;
108 Notifications notifications_; 123 Notifications notifications_;
109 bool message_center_visible_; 124 bool message_center_visible_;
110 size_t unread_count_; 125 size_t unread_count_;
111 126
112 DISALLOW_COPY_AND_ASSIGN(WebNotificationList); 127 DISALLOW_COPY_AND_ASSIGN(NotificationList);
113 }; 128 };
114 129
115 } // namespace message_center 130 } // namespace message_center
116 131
117 #endif // ASH_SYSTEM_WEB_NOTIFICATION_WEB_NOTIFICATION_LIST_H_ 132 #endif // UI_MESSAGE_CENTER_NOTIFICATION_LIST_H_
OLDNEW
« no previous file with comments | « ui/message_center/message_view.cc ('k') | ui/message_center/notification_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698