OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_MESSAGE_CENTER_IMPL_H_ | 5 #ifndef UI_MESSAGE_CENTER_MESSAGE_CENTER_IMPL_H_ |
6 #define UI_MESSAGE_CENTER_MESSAGE_CENTER_IMPL_H_ | 6 #define UI_MESSAGE_CENTER_MESSAGE_CENTER_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 }; | 76 }; |
77 | 77 |
78 // A class that manages all the timers running for individual notification popup | 78 // A class that manages all the timers running for individual notification popup |
79 // windows. It supports weak pointers in order to allow safe callbacks when | 79 // windows. It supports weak pointers in order to allow safe callbacks when |
80 // timers expire. | 80 // timers expire. |
81 class MESSAGE_CENTER_EXPORT PopupTimersController | 81 class MESSAGE_CENTER_EXPORT PopupTimersController |
82 : public base::SupportsWeakPtr<PopupTimersController>, | 82 : public base::SupportsWeakPtr<PopupTimersController>, |
83 public MessageCenterObserver { | 83 public MessageCenterObserver { |
84 public: | 84 public: |
85 explicit PopupTimersController(MessageCenter* message_center); | 85 explicit PopupTimersController(MessageCenter* message_center); |
86 virtual ~PopupTimersController(); | 86 ~PopupTimersController() override; |
87 | 87 |
88 // MessageCenterObserver implementation. | 88 // MessageCenterObserver implementation. |
89 virtual void OnNotificationDisplayed( | 89 void OnNotificationDisplayed(const std::string& id, |
90 const std::string& id, | 90 const DisplaySource source) override; |
91 const DisplaySource source) override; | 91 void OnNotificationUpdated(const std::string& id) override; |
92 virtual void OnNotificationUpdated(const std::string& id) override; | 92 void OnNotificationRemoved(const std::string& id, bool by_user) override; |
93 virtual void OnNotificationRemoved(const std::string& id, bool by_user) | |
94 override; | |
95 | 93 |
96 // Callback for each timer when its time is up. | 94 // Callback for each timer when its time is up. |
97 virtual void TimerFinished(const std::string& id); | 95 virtual void TimerFinished(const std::string& id); |
98 | 96 |
99 // Pauses all running timers. | 97 // Pauses all running timers. |
100 void PauseAll(); | 98 void PauseAll(); |
101 | 99 |
102 // Continues all managed timers. | 100 // Continues all managed timers. |
103 void StartAll(); | 101 void StartAll(); |
104 | 102 |
(...skipping 30 matching lines...) Expand all Loading... |
135 }; | 133 }; |
136 | 134 |
137 } // namespace internal | 135 } // namespace internal |
138 | 136 |
139 // The default implementation of MessageCenter. | 137 // The default implementation of MessageCenter. |
140 class MessageCenterImpl : public MessageCenter, | 138 class MessageCenterImpl : public MessageCenter, |
141 public NotificationBlocker::Observer, | 139 public NotificationBlocker::Observer, |
142 public message_center::NotifierSettingsObserver { | 140 public message_center::NotifierSettingsObserver { |
143 public: | 141 public: |
144 MessageCenterImpl(); | 142 MessageCenterImpl(); |
145 virtual ~MessageCenterImpl(); | 143 ~MessageCenterImpl() override; |
146 | 144 |
147 // MessageCenter overrides: | 145 // MessageCenter overrides: |
148 virtual void AddObserver(MessageCenterObserver* observer) override; | 146 void AddObserver(MessageCenterObserver* observer) override; |
149 virtual void RemoveObserver(MessageCenterObserver* observer) override; | 147 void RemoveObserver(MessageCenterObserver* observer) override; |
150 virtual void AddNotificationBlocker(NotificationBlocker* blocker) override; | 148 void AddNotificationBlocker(NotificationBlocker* blocker) override; |
151 virtual void RemoveNotificationBlocker(NotificationBlocker* blocker) override; | 149 void RemoveNotificationBlocker(NotificationBlocker* blocker) override; |
152 virtual void SetVisibility(Visibility visible) override; | 150 void SetVisibility(Visibility visible) override; |
153 virtual bool IsMessageCenterVisible() const override; | 151 bool IsMessageCenterVisible() const override; |
154 virtual size_t NotificationCount() const override; | 152 size_t NotificationCount() const override; |
155 virtual size_t UnreadNotificationCount() const override; | 153 size_t UnreadNotificationCount() const override; |
156 virtual bool HasPopupNotifications() const override; | 154 bool HasPopupNotifications() const override; |
157 virtual bool IsQuietMode() const override; | 155 bool IsQuietMode() const override; |
158 virtual bool HasClickedListener(const std::string& id) override; | 156 bool HasClickedListener(const std::string& id) override; |
159 virtual message_center::Notification* FindVisibleNotificationById( | 157 message_center::Notification* FindVisibleNotificationById( |
160 const std::string& id) override; | 158 const std::string& id) override; |
161 virtual const NotificationList::Notifications& GetVisibleNotifications() | 159 const NotificationList::Notifications& GetVisibleNotifications() override; |
162 override; | 160 NotificationList::PopupNotifications GetPopupNotifications() override; |
163 virtual NotificationList::PopupNotifications GetPopupNotifications() override; | 161 void AddNotification(scoped_ptr<Notification> notification) override; |
164 virtual void AddNotification(scoped_ptr<Notification> notification) override; | 162 void UpdateNotification(const std::string& old_id, |
165 virtual void UpdateNotification(const std::string& old_id, | 163 scoped_ptr<Notification> new_notification) override; |
166 scoped_ptr<Notification> new_notification) | 164 void RemoveNotification(const std::string& id, bool by_user) override; |
167 override; | 165 void RemoveAllNotifications(bool by_user) override; |
168 virtual void RemoveNotification(const std::string& id, bool by_user) override; | 166 void RemoveAllVisibleNotifications(bool by_user) override; |
169 virtual void RemoveAllNotifications(bool by_user) override; | 167 void SetNotificationIcon(const std::string& notification_id, |
170 virtual void RemoveAllVisibleNotifications(bool by_user) override; | 168 const gfx::Image& image) override; |
171 virtual void SetNotificationIcon(const std::string& notification_id, | 169 void SetNotificationImage(const std::string& notification_id, |
172 const gfx::Image& image) override; | 170 const gfx::Image& image) override; |
173 virtual void SetNotificationImage(const std::string& notification_id, | 171 void SetNotificationButtonIcon(const std::string& notification_id, |
174 const gfx::Image& image) override; | 172 int button_index, |
175 virtual void SetNotificationButtonIcon(const std::string& notification_id, | 173 const gfx::Image& image) override; |
176 int button_index, | 174 void DisableNotificationsByNotifier(const NotifierId& notifier_id) override; |
177 const gfx::Image& image) override; | 175 void ClickOnNotification(const std::string& id) override; |
178 virtual void DisableNotificationsByNotifier( | 176 void ClickOnNotificationButton(const std::string& id, |
179 const NotifierId& notifier_id) override; | 177 int button_index) override; |
180 virtual void ClickOnNotification(const std::string& id) override; | 178 void MarkSinglePopupAsShown(const std::string& id, |
181 virtual void ClickOnNotificationButton(const std::string& id, | 179 bool mark_notification_as_read) override; |
182 int button_index) override; | 180 void DisplayedNotification(const std::string& id, |
183 virtual void MarkSinglePopupAsShown(const std::string& id, | 181 const DisplaySource source) override; |
184 bool mark_notification_as_read) override; | 182 void SetNotifierSettingsProvider(NotifierSettingsProvider* provider) override; |
185 virtual void DisplayedNotification( | 183 NotifierSettingsProvider* GetNotifierSettingsProvider() override; |
186 const std::string& id, | 184 void SetQuietMode(bool in_quiet_mode) override; |
187 const DisplaySource source) override; | 185 void EnterQuietModeWithExpire(const base::TimeDelta& expires_in) override; |
188 virtual void SetNotifierSettingsProvider( | 186 void RestartPopupTimers() override; |
189 NotifierSettingsProvider* provider) override; | 187 void PausePopupTimers() override; |
190 virtual NotifierSettingsProvider* GetNotifierSettingsProvider() override; | |
191 virtual void SetQuietMode(bool in_quiet_mode) override; | |
192 virtual void EnterQuietModeWithExpire( | |
193 const base::TimeDelta& expires_in) override; | |
194 virtual void RestartPopupTimers() override; | |
195 virtual void PausePopupTimers() override; | |
196 | 188 |
197 // NotificationBlocker::Observer overrides: | 189 // NotificationBlocker::Observer overrides: |
198 virtual void OnBlockingStateChanged(NotificationBlocker* blocker) override; | 190 void OnBlockingStateChanged(NotificationBlocker* blocker) override; |
199 | 191 |
200 // message_center::NotifierSettingsObserver overrides: | 192 // message_center::NotifierSettingsObserver overrides: |
201 virtual void UpdateIconImage(const NotifierId& notifier_id, | 193 void UpdateIconImage(const NotifierId& notifier_id, |
202 const gfx::Image& icon) override; | 194 const gfx::Image& icon) override; |
203 virtual void NotifierGroupChanged() override; | 195 void NotifierGroupChanged() override; |
204 virtual void NotifierEnabledChanged(const NotifierId& notifier_id, | 196 void NotifierEnabledChanged(const NotifierId& notifier_id, |
205 bool enabled) override; | 197 bool enabled) override; |
206 | 198 |
207 protected: | 199 protected: |
208 virtual void DisableTimersForTest() override; | 200 void DisableTimersForTest() override; |
209 | 201 |
210 private: | 202 private: |
211 struct NotificationCache { | 203 struct NotificationCache { |
212 NotificationCache(); | 204 NotificationCache(); |
213 ~NotificationCache(); | 205 ~NotificationCache(); |
214 void Rebuild(const NotificationList::Notifications& notifications); | 206 void Rebuild(const NotificationList::Notifications& notifications); |
215 void RecountUnread(); | 207 void RecountUnread(); |
216 | 208 |
217 NotificationList::Notifications visible_notifications; | 209 NotificationList::Notifications visible_notifications; |
218 size_t unread_count; | 210 size_t unread_count; |
(...skipping 13 matching lines...) Expand all Loading... |
232 // Queue for the notifications to delay the addition/updates when the message | 224 // Queue for the notifications to delay the addition/updates when the message |
233 // center is visible. | 225 // center is visible. |
234 scoped_ptr<internal::ChangeQueue> notification_queue_; | 226 scoped_ptr<internal::ChangeQueue> notification_queue_; |
235 | 227 |
236 DISALLOW_COPY_AND_ASSIGN(MessageCenterImpl); | 228 DISALLOW_COPY_AND_ASSIGN(MessageCenterImpl); |
237 }; | 229 }; |
238 | 230 |
239 } // namespace message_center | 231 } // namespace message_center |
240 | 232 |
241 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ | 233 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ |
OLD | NEW |