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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <string> | 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
18 #include "ui/message_center/message_center.h" | 18 #include "ui/message_center/message_center.h" |
19 #include "ui/message_center/message_center_observer.h" | 19 #include "ui/message_center/message_center_observer.h" |
20 #include "ui/message_center/message_center_types.h" | 20 #include "ui/message_center/message_center_types.h" |
21 #include "ui/message_center/notification_blocker.h" | 21 #include "ui/message_center/notification_blocker.h" |
22 #include "ui/message_center/notifier_settings.h" | 22 #include "ui/message_center/notifier_settings.h" |
23 #include "ui/message_center/popup_timers_controller.h" | 23 #include "ui/message_center/popup_timers_controller.h" |
24 | 24 |
(...skipping 22 matching lines...) Expand all Loading... |
47 bool IsMessageCenterVisible() const override; | 47 bool IsMessageCenterVisible() const override; |
48 size_t NotificationCount() const override; | 48 size_t NotificationCount() const override; |
49 size_t UnreadNotificationCount() const override; | 49 size_t UnreadNotificationCount() const override; |
50 bool HasPopupNotifications() const override; | 50 bool HasPopupNotifications() const override; |
51 bool IsQuietMode() const override; | 51 bool IsQuietMode() const override; |
52 bool HasClickedListener(const std::string& id) override; | 52 bool HasClickedListener(const std::string& id) override; |
53 message_center::Notification* FindVisibleNotificationById( | 53 message_center::Notification* FindVisibleNotificationById( |
54 const std::string& id) override; | 54 const std::string& id) override; |
55 const NotificationList::Notifications& GetVisibleNotifications() override; | 55 const NotificationList::Notifications& GetVisibleNotifications() override; |
56 NotificationList::PopupNotifications GetPopupNotifications() override; | 56 NotificationList::PopupNotifications GetPopupNotifications() override; |
57 void AddNotification(scoped_ptr<Notification> notification) override; | 57 void AddNotification(std::unique_ptr<Notification> notification) override; |
58 void UpdateNotification(const std::string& old_id, | 58 void UpdateNotification( |
59 scoped_ptr<Notification> new_notification) override; | 59 const std::string& old_id, |
| 60 std::unique_ptr<Notification> new_notification) override; |
60 void RemoveNotification(const std::string& id, bool by_user) override; | 61 void RemoveNotification(const std::string& id, bool by_user) override; |
61 void RemoveAllNotifications(bool by_user, RemoveType type) override; | 62 void RemoveAllNotifications(bool by_user, RemoveType type) override; |
62 void SetNotificationIcon(const std::string& notification_id, | 63 void SetNotificationIcon(const std::string& notification_id, |
63 const gfx::Image& image) override; | 64 const gfx::Image& image) override; |
64 void SetNotificationImage(const std::string& notification_id, | 65 void SetNotificationImage(const std::string& notification_id, |
65 const gfx::Image& image) override; | 66 const gfx::Image& image) override; |
66 void SetNotificationButtonIcon(const std::string& notification_id, | 67 void SetNotificationButtonIcon(const std::string& notification_id, |
67 int button_index, | 68 int button_index, |
68 const gfx::Image& image) override; | 69 const gfx::Image& image) override; |
69 void DisableNotificationsByNotifier(const NotifierId& notifier_id) override; | 70 void DisableNotificationsByNotifier(const NotifierId& notifier_id) override; |
(...skipping 17 matching lines...) Expand all Loading... |
87 void OnBlockingStateChanged(NotificationBlocker* blocker) override; | 88 void OnBlockingStateChanged(NotificationBlocker* blocker) override; |
88 | 89 |
89 // message_center::NotifierSettingsObserver overrides: | 90 // message_center::NotifierSettingsObserver overrides: |
90 void UpdateIconImage(const NotifierId& notifier_id, | 91 void UpdateIconImage(const NotifierId& notifier_id, |
91 const gfx::Image& icon) override; | 92 const gfx::Image& icon) override; |
92 void NotifierGroupChanged() override; | 93 void NotifierGroupChanged() override; |
93 void NotifierEnabledChanged(const NotifierId& notifier_id, | 94 void NotifierEnabledChanged(const NotifierId& notifier_id, |
94 bool enabled) override; | 95 bool enabled) override; |
95 | 96 |
96 // Unexposed methods: | 97 // Unexposed methods: |
97 void AddNotificationImmediately(scoped_ptr<Notification> notification); | 98 void AddNotificationImmediately(std::unique_ptr<Notification> notification); |
98 void UpdateNotificationImmediately( | 99 void UpdateNotificationImmediately( |
99 const std::string& old_id, | 100 const std::string& old_id, |
100 scoped_ptr<Notification> new_notification); | 101 std::unique_ptr<Notification> new_notification); |
101 void RemoveNotificationImmediately(const std::string& id, bool by_user); | 102 void RemoveNotificationImmediately(const std::string& id, bool by_user); |
102 | 103 |
103 protected: | 104 protected: |
104 void DisableTimersForTest() override; | 105 void DisableTimersForTest() override; |
105 void EnableChangeQueueForTest(bool enable) override; | 106 void EnableChangeQueueForTest(bool enable) override; |
106 | 107 |
107 private: | 108 private: |
108 struct NotificationCache { | 109 struct NotificationCache { |
109 NotificationCache(); | 110 NotificationCache(); |
110 ~NotificationCache(); | 111 ~NotificationCache(); |
111 void Rebuild(const NotificationList::Notifications& notifications); | 112 void Rebuild(const NotificationList::Notifications& notifications); |
112 void RecountUnread(); | 113 void RecountUnread(); |
113 | 114 |
114 NotificationList::Notifications visible_notifications; | 115 NotificationList::Notifications visible_notifications; |
115 size_t unread_count; | 116 size_t unread_count; |
116 }; | 117 }; |
117 | 118 |
118 void RemoveNotificationsForNotifierId(const NotifierId& notifier_id); | 119 void RemoveNotificationsForNotifierId(const NotifierId& notifier_id); |
119 | 120 |
120 scoped_ptr<NotificationList> notification_list_; | 121 std::unique_ptr<NotificationList> notification_list_; |
121 NotificationCache notification_cache_; | 122 NotificationCache notification_cache_; |
122 base::ObserverList<MessageCenterObserver> observer_list_; | 123 base::ObserverList<MessageCenterObserver> observer_list_; |
123 scoped_ptr<PopupTimersController> popup_timers_controller_; | 124 std::unique_ptr<PopupTimersController> popup_timers_controller_; |
124 scoped_ptr<base::OneShotTimer> quiet_mode_timer_; | 125 std::unique_ptr<base::OneShotTimer> quiet_mode_timer_; |
125 NotifierSettingsProvider* settings_provider_; | 126 NotifierSettingsProvider* settings_provider_; |
126 std::vector<NotificationBlocker*> blockers_; | 127 std::vector<NotificationBlocker*> blockers_; |
127 | 128 |
128 // Queue for the notifications to delay the addition/updates when the message | 129 // Queue for the notifications to delay the addition/updates when the message |
129 // center is visible. | 130 // center is visible. |
130 scoped_ptr<internal::ChangeQueue> notification_queue_; | 131 std::unique_ptr<internal::ChangeQueue> notification_queue_; |
131 | 132 |
132 DISALLOW_COPY_AND_ASSIGN(MessageCenterImpl); | 133 DISALLOW_COPY_AND_ASSIGN(MessageCenterImpl); |
133 }; | 134 }; |
134 | 135 |
135 } // namespace message_center | 136 } // namespace message_center |
136 | 137 |
137 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ | 138 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ |
OLD | NEW |