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 UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ | 5 #ifndef UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ |
6 #define UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ | 6 #define UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
13 #include "ui/message_center/message_center_export.h" | 13 #include "ui/message_center/message_center_export.h" |
14 #include "ui/message_center/notification_list.h" | 14 #include "ui/message_center/notification_list.h" |
15 #include "ui/message_center/notification_types.h" | 15 #include "ui/message_center/notification_types.h" |
16 | 16 |
17 class TrayViewControllerTest; | 17 class TrayViewControllerTest; |
18 | 18 |
19 namespace base { | 19 namespace base { |
20 class DictionaryValue; | 20 class DictionaryValue; |
21 } | 21 } |
22 | 22 |
23 // Interface to manage the NotificationList. The client (e.g. Chrome) calls | 23 // Interface to manage the NotificationList. The client (e.g. Chrome) calls |
24 // [Add|Remove|Update]Notification to create and update notifications in the | 24 // [Add|Remove|Update]Notification to create and update notifications in the |
25 // list. It also sends those changes to its observers when a notification | 25 // list. It also sends those changes to its observers when a notification |
26 // is shown, closed, or clicked on. | 26 // is shown, closed, or clicked on. |
27 // It can also implement Delegate to ask platform-dependent features like | |
28 // disabling extensions or opening settings. | |
29 | 27 |
30 namespace message_center { | 28 namespace message_center { |
31 | 29 |
32 class MessageCenterObserver; | 30 class MessageCenterObserver; |
33 class NotificationList; | 31 class NotificationList; |
34 class NotifierSettingsDelegate; | 32 class NotifierSettingsDelegate; |
35 class NotifierSettingsProvider; | 33 class NotifierSettingsProvider; |
36 | 34 |
35 enum Visibility { | |
Jun Mukai
2013/09/09 17:12:35
It would be better to declare this enum in another
dewittj
2013/09/10 21:23:24
Done.
| |
36 // When nothing or just toast popups are being displayed. | |
37 VISIBILITY_TRANSIENT = 0, | |
38 // When the message center view is being displayed. | |
39 VISIBILITY_MESSAGE_CENTER, | |
40 // When the settings view is being displayed. | |
41 VISIBILITY_SETTINGS | |
42 }; | |
43 | |
37 class MESSAGE_CENTER_EXPORT MessageCenter { | 44 class MESSAGE_CENTER_EXPORT MessageCenter { |
38 public: | 45 public: |
39 // Creates the global message center object. | 46 // Creates the global message center object. |
40 static void Initialize(); | 47 static void Initialize(); |
41 | 48 |
42 // Returns the global message center object. Initialize must be called first. | 49 // Returns the global message center object. Initialize must be called first. |
43 static MessageCenter* Get(); | 50 static MessageCenter* Get(); |
44 | 51 |
45 // Destroys the global message_center object. | 52 // Destroys the global message_center object. |
46 static void Shutdown(); | 53 static void Shutdown(); |
47 | 54 |
48 class MESSAGE_CENTER_EXPORT Delegate { | |
49 public: | |
50 virtual ~Delegate(); | |
51 | |
52 // Request to show the notification settings (|notification_id| is used | |
53 // to identify the requesting browser context). | |
54 virtual void ShowSettings(const std::string& notification_id) = 0; | |
55 }; | |
56 | |
57 // Called to set the delegate. Generally called only once, except in tests. | |
58 // Changing the delegate does not affect notifications in its | |
59 // NotificationList. | |
60 virtual void SetDelegate(Delegate* delegate) = 0; | |
61 | |
62 // Management of the observer list. | 55 // Management of the observer list. |
63 virtual void AddObserver(MessageCenterObserver* observer) = 0; | 56 virtual void AddObserver(MessageCenterObserver* observer) = 0; |
64 virtual void RemoveObserver(MessageCenterObserver* observer) = 0; | 57 virtual void RemoveObserver(MessageCenterObserver* observer) = 0; |
65 | 58 |
66 // Queries of current notification list status. | 59 // Queries of current notification list status. |
67 virtual size_t NotificationCount() const = 0; | 60 virtual size_t NotificationCount() const = 0; |
68 virtual size_t UnreadNotificationCount() const = 0; | 61 virtual size_t UnreadNotificationCount() const = 0; |
69 virtual bool HasPopupNotifications() const = 0; | 62 virtual bool HasPopupNotifications() const = 0; |
70 virtual bool HasNotification(const std::string& id) = 0; | 63 virtual bool HasNotification(const std::string& id) = 0; |
71 virtual bool IsQuietMode() const = 0; | 64 virtual bool IsQuietMode() const = 0; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 int button_index, | 97 int button_index, |
105 const gfx::Image& image) = 0; | 98 const gfx::Image& image) = 0; |
106 | 99 |
107 // Operations happening especially from GUIs: click, expand, disable, | 100 // Operations happening especially from GUIs: click, expand, disable, |
108 // and settings. | 101 // and settings. |
109 // Searches through the notifications and disables any that match the | 102 // Searches through the notifications and disables any that match the |
110 // extension id given. | 103 // extension id given. |
111 virtual void DisableNotificationsByNotifier( | 104 virtual void DisableNotificationsByNotifier( |
112 const NotifierId& notifier_id) = 0; | 105 const NotifierId& notifier_id) = 0; |
113 | 106 |
114 // TODO(mukai): settings can be in another class? | |
115 // Shows the settings for a web notification (profile is identified by the | |
116 // given notification id). | |
117 virtual void ShowNotificationSettings(const std::string& id) = 0; | |
118 | |
119 // Reformat a notification to show its entire text content. | 107 // Reformat a notification to show its entire text content. |
120 virtual void ExpandNotification(const std::string& id) = 0; | 108 virtual void ExpandNotification(const std::string& id) = 0; |
121 | 109 |
122 // This should be called by UI classes when a notification is clicked to | 110 // This should be called by UI classes when a notification is clicked to |
123 // trigger the notification's delegate callback and also update the message | 111 // trigger the notification's delegate callback and also update the message |
124 // center observers. | 112 // center observers. |
125 virtual void ClickOnNotification(const std::string& id) = 0; | 113 virtual void ClickOnNotification(const std::string& id) = 0; |
126 | 114 |
127 // This should be called by UI classes when a notification button is clicked | 115 // This should be called by UI classes when a notification button is clicked |
128 // to trigger the notification's delegate callback and also update the message | 116 // to trigger the notification's delegate callback and also update the message |
(...skipping 21 matching lines...) Expand all Loading... | |
150 virtual NotifierSettingsProvider* GetNotifierSettingsProvider() = 0; | 138 virtual NotifierSettingsProvider* GetNotifierSettingsProvider() = 0; |
151 | 139 |
152 // This can be called to change the quiet mode state (without a timeout). | 140 // This can be called to change the quiet mode state (without a timeout). |
153 virtual void SetQuietMode(bool in_quiet_mode) = 0; | 141 virtual void SetQuietMode(bool in_quiet_mode) = 0; |
154 | 142 |
155 // Temporarily enables quiet mode for |expires_in| time. | 143 // Temporarily enables quiet mode for |expires_in| time. |
156 virtual void EnterQuietModeWithExpire(const base::TimeDelta& expires_in) = 0; | 144 virtual void EnterQuietModeWithExpire(const base::TimeDelta& expires_in) = 0; |
157 | 145 |
158 // Informs the notification list whether the message center is visible. | 146 // Informs the notification list whether the message center is visible. |
159 // This affects whether or not a message has been "read". | 147 // This affects whether or not a message has been "read". |
160 virtual void SetMessageCenterVisible(bool visible) = 0; | 148 virtual void SetVisibility(Visibility visible) = 0; |
161 | 149 |
162 // Allows querying the visibility of the center. | 150 // Allows querying the visibility of the center. |
163 virtual bool IsMessageCenterVisible() = 0; | 151 virtual bool IsMessageCenterVisible() = 0; |
164 | 152 |
165 // UI classes should call this when there is cause to leave popups visible for | 153 // UI classes should call this when there is cause to leave popups visible for |
166 // longer than the default (for example, when the mouse hovers over a popup). | 154 // longer than the default (for example, when the mouse hovers over a popup). |
167 virtual void PausePopupTimers() = 0; | 155 virtual void PausePopupTimers() = 0; |
168 | 156 |
169 // UI classes should call this when the popup timers should restart (for | 157 // UI classes should call this when the popup timers should restart (for |
170 // example, after the mouse leaves the popup.) | 158 // example, after the mouse leaves the popup.) |
171 virtual void RestartPopupTimers() = 0; | 159 virtual void RestartPopupTimers() = 0; |
172 | 160 |
173 protected: | 161 protected: |
174 friend class ::TrayViewControllerTest; | 162 friend class ::TrayViewControllerTest; |
175 virtual void DisableTimersForTest() = 0; | 163 virtual void DisableTimersForTest() = 0; |
176 | 164 |
177 MessageCenter(); | 165 MessageCenter(); |
178 virtual ~MessageCenter(); | 166 virtual ~MessageCenter(); |
179 | 167 |
180 private: | 168 private: |
181 DISALLOW_COPY_AND_ASSIGN(MessageCenter); | 169 DISALLOW_COPY_AND_ASSIGN(MessageCenter); |
182 }; | 170 }; |
183 | 171 |
184 } // namespace message_center | 172 } // namespace message_center |
185 | 173 |
186 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ | 174 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ |
OLD | NEW |