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