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