OLD | NEW |
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 CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_IMPL_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_IMPL_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_IMPL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 protected: | 52 protected: |
53 // Attempts to pass a notification from a waiting queue to the subclass for | 53 // Attempts to pass a notification from a waiting queue to the subclass for |
54 // presentation. The subclass can return 'false' if it cannot show the | 54 // presentation. The subclass can return 'false' if it cannot show the |
55 // notification right away. In that case it should invoke | 55 // notification right away. In that case it should invoke |
56 // CheckAndShowNotificaitons() later. | 56 // CheckAndShowNotificaitons() later. |
57 virtual bool ShowNotification(const Notification& notification, | 57 virtual bool ShowNotification(const Notification& notification, |
58 Profile* profile) = 0; | 58 Profile* profile) = 0; |
59 | 59 |
60 // Replace an existing notification of the same id with this one if | 60 // Replace an existing notification of the same id with this one if |
61 // applicable; subclass returns 'true' if the replacement happened. | 61 // applicable. Subclass returns 'true' if the replacement happened. |
62 virtual bool UpdateNotification(const Notification& notification, | 62 virtual bool UpdateNotification(const Notification& notification, |
63 Profile* profile) = 0; | 63 Profile* profile) = 0; |
64 | 64 |
65 // Attempts to display notifications from the show_queue. Invoked by subclass | 65 // Attempts to display notifications from the show_queue. Invoked by |
66 // if it previously returned 'false' from ShowNotifications, which may happen | 66 // subclasses if they previously returned 'false' from ShowNotifications, |
67 // when there is no room to show another notification. When room appears, the | 67 // which may happen when there is no room to show another notification. When |
68 // subclass should call this method to cause an attempt to show more | 68 // room appears, the subclass should call this method to cause an attempt to |
69 // notifications from the waiting queue. | 69 // show more notifications from the waiting queue. |
70 void CheckAndShowNotifications(); | 70 void CheckAndShowNotifications(); |
71 | 71 |
72 private: | |
73 // content::NotificationObserver override. | 72 // content::NotificationObserver override. |
74 virtual void Observe(int type, | 73 virtual void Observe(int type, |
75 const content::NotificationSource& source, | 74 const content::NotificationSource& source, |
76 const content::NotificationDetails& details) OVERRIDE; | 75 const content::NotificationDetails& details) OVERRIDE; |
77 | 76 |
| 77 private: |
78 // Attempts to display notifications from the show_queue. | 78 // Attempts to display notifications from the show_queue. |
79 void ShowNotifications(); | 79 void ShowNotifications(); |
80 | 80 |
81 // Checks the user state to decide if we want to show the notification. | 81 // Checks the user state to decide if we want to show the notification. |
82 void CheckUserState(); | 82 void CheckUserState(); |
83 | 83 |
84 // A queue of notifications which are waiting to be shown. | 84 // A queue of notifications which are waiting to be shown. |
85 typedef std::deque<linked_ptr<QueuedNotification> > NotificationDeque; | 85 typedef std::deque<linked_ptr<QueuedNotification> > NotificationDeque; |
86 NotificationDeque show_queue_; | 86 NotificationDeque show_queue_; |
87 | 87 |
88 // Registrar for the other kind of notifications (event signaling). | 88 // Registrar for the other kind of notifications (event signaling). |
89 content::NotificationRegistrar registrar_; | 89 content::NotificationRegistrar registrar_; |
90 | 90 |
91 // Used by screen-saver and full-screen handling support. | 91 // Used by screen-saver and full-screen handling support. |
92 bool is_user_active_; | 92 bool is_user_active_; |
93 base::RepeatingTimer<NotificationUIManagerImpl> user_state_check_timer_; | 93 base::RepeatingTimer<NotificationUIManagerImpl> user_state_check_timer_; |
94 | 94 |
95 DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerImpl); | 95 DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerImpl); |
96 }; | 96 }; |
97 | 97 |
98 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_IMPL_H_ | 98 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_IMPL_H_ |
OLD | NEW |