OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <string> | 10 #include <string> |
(...skipping 12 matching lines...) Expand all Loading... |
23 class Profile; | 23 class Profile; |
24 class QueuedNotification; | 24 class QueuedNotification; |
25 class SiteInstance; | 25 class SiteInstance; |
26 | 26 |
27 // The notification manager manages use of the desktop for notifications. | 27 // The notification manager manages use of the desktop for notifications. |
28 // It maintains a queue of pending notifications when space becomes constrained. | 28 // It maintains a queue of pending notifications when space becomes constrained. |
29 class NotificationUIManager | 29 class NotificationUIManager |
30 : public BalloonCollection::BalloonSpaceChangeListener, | 30 : public BalloonCollection::BalloonSpaceChangeListener, |
31 public NotificationObserver { | 31 public NotificationObserver { |
32 public: | 32 public: |
33 explicit NotificationUIManager(PrefService* local_state); | |
34 virtual ~NotificationUIManager(); | 33 virtual ~NotificationUIManager(); |
35 | 34 |
36 // Creates an initialized UI manager with a new balloon collection | 35 // Creates an initialized UI manager with a new balloon collection |
37 // and the listener relationship setup. | 36 // and the listener relationship setup. |
38 // Except for unit tests, this is the way to construct the object. | 37 // Except for unit tests, this is the way to construct the object. |
39 static NotificationUIManager* Create(PrefService* local_state); | 38 static NotificationUIManager* Create(PrefService* local_state); |
40 | 39 |
| 40 // Creates an initialized UI manager with the given balloon collection |
| 41 // and the listener relationship setup. |
| 42 // Used primarily by unit tests. |
| 43 static NotificationUIManager* Create(PrefService* local_state, |
| 44 BalloonCollection* balloons); |
| 45 |
41 // Registers preferences. | 46 // Registers preferences. |
42 static void RegisterPrefs(PrefService* prefs); | 47 static void RegisterPrefs(PrefService* prefs); |
43 | 48 |
44 // Initializes the UI manager with a balloon collection; this object | 49 // Initializes the UI manager with a balloon collection; this object |
45 // takes ownership of the balloon collection. | 50 // takes ownership of the balloon collection. |
46 void Initialize(BalloonCollection* balloon_collection); | 51 void Initialize(BalloonCollection* balloon_collection); |
47 | 52 |
48 // Adds a notification to be displayed. Virtual for unit test override. | 53 // Adds a notification to be displayed. Virtual for unit test override. |
49 virtual void Add(const Notification& notification, | 54 virtual void Add(const Notification& notification, |
50 Profile* profile); | 55 Profile* profile); |
(...skipping 17 matching lines...) Expand all Loading... |
68 } | 73 } |
69 | 74 |
70 // Gets the preference indicating where notifications should be placed. | 75 // Gets the preference indicating where notifications should be placed. |
71 BalloonCollection::PositionPreference GetPositionPreference(); | 76 BalloonCollection::PositionPreference GetPositionPreference(); |
72 | 77 |
73 // Sets the preference that indicates where notifications should | 78 // Sets the preference that indicates where notifications should |
74 // be placed on the screen. | 79 // be placed on the screen. |
75 void SetPositionPreference(BalloonCollection::PositionPreference preference); | 80 void SetPositionPreference(BalloonCollection::PositionPreference preference); |
76 | 81 |
77 private: | 82 private: |
| 83 explicit NotificationUIManager(PrefService* local_state); |
| 84 |
78 // NotificationObserver override. | 85 // NotificationObserver override. |
79 virtual void Observe(NotificationType type, | 86 virtual void Observe(NotificationType type, |
80 const NotificationSource& source, | 87 const NotificationSource& source, |
81 const NotificationDetails& details); | 88 const NotificationDetails& details); |
82 | 89 |
83 // Attempts to display notifications from the show_queue if the user | 90 // Attempts to display notifications from the show_queue if the user |
84 // is active. | 91 // is active. |
85 void CheckAndShowNotifications(); | 92 void CheckAndShowNotifications(); |
86 | 93 |
87 // Attempts to display notifications from the show_queue. | 94 // Attempts to display notifications from the show_queue. |
(...skipping 23 matching lines...) Expand all Loading... |
111 IntegerPrefMember position_pref_; | 118 IntegerPrefMember position_pref_; |
112 | 119 |
113 // Used by screen-saver and full-screen handling support. | 120 // Used by screen-saver and full-screen handling support. |
114 bool is_user_active_; | 121 bool is_user_active_; |
115 base::RepeatingTimer<NotificationUIManager> user_state_check_timer_; | 122 base::RepeatingTimer<NotificationUIManager> user_state_check_timer_; |
116 | 123 |
117 DISALLOW_COPY_AND_ASSIGN(NotificationUIManager); | 124 DISALLOW_COPY_AND_ASSIGN(NotificationUIManager); |
118 }; | 125 }; |
119 | 126 |
120 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_ | 127 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_ |
OLD | NEW |