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/message_center_types.h" |
14 #include "ui/message_center/notification_list.h" | 15 #include "ui/message_center/notification_list.h" |
15 #include "ui/message_center/notification_types.h" | 16 #include "ui/message_center/notification_types.h" |
16 | 17 |
17 class TrayViewControllerTest; | 18 class TrayViewControllerTest; |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class DictionaryValue; | 21 class DictionaryValue; |
21 } | 22 } |
22 | 23 |
23 // Interface to manage the NotificationList. The client (e.g. Chrome) calls | 24 // Interface to manage the NotificationList. The client (e.g. Chrome) calls |
24 // [Add|Remove|Update]Notification to create and update notifications in the | 25 // [Add|Remove|Update]Notification to create and update notifications in the |
25 // list. It also sends those changes to its observers when a notification | 26 // list. It also sends those changes to its observers when a notification |
26 // is shown, closed, or clicked on. | 27 // 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 | 28 |
30 namespace message_center { | 29 namespace message_center { |
31 | 30 |
32 class MessageCenterObserver; | 31 class MessageCenterObserver; |
33 class NotificationList; | 32 class NotificationList; |
34 class NotifierSettingsDelegate; | 33 class NotifierSettingsDelegate; |
35 class NotifierSettingsProvider; | 34 class NotifierSettingsProvider; |
36 | 35 |
37 class MESSAGE_CENTER_EXPORT MessageCenter { | 36 class MESSAGE_CENTER_EXPORT MessageCenter { |
38 public: | 37 public: |
39 // Creates the global message center object. | 38 // Creates the global message center object. |
40 static void Initialize(); | 39 static void Initialize(); |
41 | 40 |
42 // Returns the global message center object. Initialize must be called first. | 41 // Returns the global message center object. Initialize must be called first. |
43 static MessageCenter* Get(); | 42 static MessageCenter* Get(); |
44 | 43 |
45 // Destroys the global message_center object. | 44 // Destroys the global message_center object. |
46 static void Shutdown(); | 45 static void Shutdown(); |
47 | 46 |
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. | 47 // Management of the observer list. |
63 virtual void AddObserver(MessageCenterObserver* observer) = 0; | 48 virtual void AddObserver(MessageCenterObserver* observer) = 0; |
64 virtual void RemoveObserver(MessageCenterObserver* observer) = 0; | 49 virtual void RemoveObserver(MessageCenterObserver* observer) = 0; |
65 | 50 |
66 // Queries of current notification list status. | 51 // Queries of current notification list status. |
67 virtual size_t NotificationCount() const = 0; | 52 virtual size_t NotificationCount() const = 0; |
68 virtual size_t UnreadNotificationCount() const = 0; | 53 virtual size_t UnreadNotificationCount() const = 0; |
69 virtual bool HasPopupNotifications() const = 0; | 54 virtual bool HasPopupNotifications() const = 0; |
70 virtual bool HasNotification(const std::string& id) = 0; | 55 virtual bool HasNotification(const std::string& id) = 0; |
71 virtual bool IsQuietMode() const = 0; | 56 virtual bool IsQuietMode() const = 0; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 int button_index, | 89 int button_index, |
105 const gfx::Image& image) = 0; | 90 const gfx::Image& image) = 0; |
106 | 91 |
107 // Operations happening especially from GUIs: click, expand, disable, | 92 // Operations happening especially from GUIs: click, expand, disable, |
108 // and settings. | 93 // and settings. |
109 // Searches through the notifications and disables any that match the | 94 // Searches through the notifications and disables any that match the |
110 // extension id given. | 95 // extension id given. |
111 virtual void DisableNotificationsByNotifier( | 96 virtual void DisableNotificationsByNotifier( |
112 const NotifierId& notifier_id) = 0; | 97 const NotifierId& notifier_id) = 0; |
113 | 98 |
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. | 99 // Reformat a notification to show its entire text content. |
120 virtual void ExpandNotification(const std::string& id) = 0; | 100 virtual void ExpandNotification(const std::string& id) = 0; |
121 | 101 |
122 // This should be called by UI classes when a notification is clicked to | 102 // 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 | 103 // trigger the notification's delegate callback and also update the message |
124 // center observers. | 104 // center observers. |
125 virtual void ClickOnNotification(const std::string& id) = 0; | 105 virtual void ClickOnNotification(const std::string& id) = 0; |
126 | 106 |
127 // This should be called by UI classes when a notification button is clicked | 107 // 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 | 108 // to trigger the notification's delegate callback and also update the message |
(...skipping 21 matching lines...) Expand all Loading... |
150 virtual NotifierSettingsProvider* GetNotifierSettingsProvider() = 0; | 130 virtual NotifierSettingsProvider* GetNotifierSettingsProvider() = 0; |
151 | 131 |
152 // This can be called to change the quiet mode state (without a timeout). | 132 // This can be called to change the quiet mode state (without a timeout). |
153 virtual void SetQuietMode(bool in_quiet_mode) = 0; | 133 virtual void SetQuietMode(bool in_quiet_mode) = 0; |
154 | 134 |
155 // Temporarily enables quiet mode for |expires_in| time. | 135 // Temporarily enables quiet mode for |expires_in| time. |
156 virtual void EnterQuietModeWithExpire(const base::TimeDelta& expires_in) = 0; | 136 virtual void EnterQuietModeWithExpire(const base::TimeDelta& expires_in) = 0; |
157 | 137 |
158 // Informs the notification list whether the message center is visible. | 138 // Informs the notification list whether the message center is visible. |
159 // This affects whether or not a message has been "read". | 139 // This affects whether or not a message has been "read". |
160 virtual void SetMessageCenterVisible(bool visible) = 0; | 140 virtual void SetVisibility(Visibility visible) = 0; |
161 | 141 |
162 // Allows querying the visibility of the center. | 142 // Allows querying the visibility of the center. |
163 virtual bool IsMessageCenterVisible() = 0; | 143 virtual bool IsMessageCenterVisible() = 0; |
164 | 144 |
165 // UI classes should call this when there is cause to leave popups visible for | 145 // 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). | 146 // longer than the default (for example, when the mouse hovers over a popup). |
167 virtual void PausePopupTimers() = 0; | 147 virtual void PausePopupTimers() = 0; |
168 | 148 |
169 // UI classes should call this when the popup timers should restart (for | 149 // UI classes should call this when the popup timers should restart (for |
170 // example, after the mouse leaves the popup.) | 150 // example, after the mouse leaves the popup.) |
171 virtual void RestartPopupTimers() = 0; | 151 virtual void RestartPopupTimers() = 0; |
172 | 152 |
173 protected: | 153 protected: |
174 friend class ::TrayViewControllerTest; | 154 friend class ::TrayViewControllerTest; |
175 virtual void DisableTimersForTest() = 0; | 155 virtual void DisableTimersForTest() = 0; |
176 | 156 |
177 MessageCenter(); | 157 MessageCenter(); |
178 virtual ~MessageCenter(); | 158 virtual ~MessageCenter(); |
179 | 159 |
180 private: | 160 private: |
181 DISALLOW_COPY_AND_ASSIGN(MessageCenter); | 161 DISALLOW_COPY_AND_ASSIGN(MessageCenter); |
182 }; | 162 }; |
183 | 163 |
184 } // namespace message_center | 164 } // namespace message_center |
185 | 165 |
186 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ | 166 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ |
OLD | NEW |