gpu: Tweak Android WebGL test expectations
[chromium-blink-merge.git] / ui / message_center / message_center.h
blobc0556647148dba7430ec9c88ef8bfdd289018145
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
3 // found in the LICENSE file.
5 #ifndef UI_MESSAGE_CENTER_MESSAGE_CENTER_H_
6 #define UI_MESSAGE_CENTER_MESSAGE_CENTER_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/observer_list.h"
12 #include "ui/gfx/native_widget_types.h"
13 #include "ui/message_center/message_center_export.h"
14 #include "ui/message_center/notification_list.h"
15 #include "ui/message_center/notification_types.h"
17 class TrayViewControllerTest;
19 namespace base {
20 class DictionaryValue;
23 // Interface to manage the NotificationList. The client (e.g. Chrome) calls
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
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.
30 namespace message_center {
32 class MessageCenterObserver;
33 class NotificationList;
34 class NotifierSettingsDelegate;
35 class NotifierSettingsProvider;
37 class MESSAGE_CENTER_EXPORT MessageCenter {
38 public:
39 // Creates the global message center object.
40 static void Initialize();
42 // Returns the global message center object. Initialize must be called first.
43 static MessageCenter* Get();
45 // Destroys the global message_center object.
46 static void Shutdown();
48 class MESSAGE_CENTER_EXPORT Delegate {
49 public:
50 virtual ~Delegate();
52 // Request to disable the extension associated with |notification_id|.
53 virtual void DisableExtension(const std::string& notification_id) = 0;
55 // Request to disable notifications from the source of |notification_id|.
56 virtual void DisableNotificationsFromSource(
57 const std::string& notification_id) = 0;
59 // Request to show the notification settings (|notification_id| is used
60 // to identify the requesting browser context).
61 virtual void ShowSettings(const std::string& notification_id) = 0;
64 // Called to set the delegate. Generally called only once, except in tests.
65 // Changing the delegate does not affect notifications in its
66 // NotificationList.
67 virtual void SetDelegate(Delegate* delegate) = 0;
69 // Management of the observer list.
70 virtual void AddObserver(MessageCenterObserver* observer) = 0;
71 virtual void RemoveObserver(MessageCenterObserver* observer) = 0;
73 // Queries of current notification list status.
74 virtual size_t NotificationCount() const = 0;
75 virtual size_t UnreadNotificationCount() const = 0;
76 virtual bool HasPopupNotifications() const = 0;
77 virtual bool HasNotification(const std::string& id) = 0;
78 virtual bool IsQuietMode() const = 0;
79 virtual bool HasClickedListener(const std::string& id) = 0;
81 // Getters of the current notifications.
82 virtual const NotificationList::Notifications& GetNotifications() = 0;
83 // Gets all notifications being shown as popups.
84 virtual NotificationList::PopupNotifications GetPopupNotifications() = 0;
86 // Basic operations of notification: add/remove/update.
88 // Adds a new notification.
89 virtual void AddNotification(scoped_ptr<Notification> notification) = 0;
91 // Updates an existing notification with id = old_id and set its id to new_id.
92 virtual void UpdateNotification(
93 const std::string& old_id,
94 scoped_ptr<Notification> new_notification) = 0;
96 // Removes an existing notification.
97 virtual void RemoveNotification(const std::string& id, bool by_user) = 0;
98 virtual void RemoveAllNotifications(bool by_user) = 0;
100 // Sets the icon image. Icon appears at the top-left of the notification.
101 virtual void SetNotificationIcon(const std::string& notification_id,
102 const gfx::Image& image) = 0;
104 // Sets the large image for the notifications of type == TYPE_IMAGE. Specified
105 // image will appear below of the notification.
106 virtual void SetNotificationImage(const std::string& notification_id,
107 const gfx::Image& image) = 0;
109 // Sets the image for the icon of the specific action button.
110 virtual void SetNotificationButtonIcon(const std::string& notification_id,
111 int button_index,
112 const gfx::Image& image) = 0;
114 // Operations happening especially from GUIs: click, expand, disable,
115 // and settings.
116 // Searches through the notifications and disables any that match the
117 // extension id given.
118 virtual void DisableNotificationsByExtension(const std::string& id) = 0;
120 // Disables all notifications that match the given url by querying the
121 // delegate and also by matching display_source.
122 // TODO(dewittj): Is display_source matching necessary?
123 virtual void DisableNotificationsByUrl(const std::string& url) = 0;
125 // TODO(mukai): settings can be in another class?
126 // Shows the settings for a web notification (profile is identified by the
127 // given notification id).
128 virtual void ShowNotificationSettings(const std::string& id) = 0;
130 // Reformat a notification to show its entire text content.
131 virtual void ExpandNotification(const std::string& id) = 0;
133 // This should be called by UI classes when a notification is clicked to
134 // trigger the notification's delegate callback and also update the message
135 // center observers.
136 virtual void ClickOnNotification(const std::string& id) = 0;
138 // This should be called by UI classes when a notification button is clicked
139 // to trigger the notification's delegate callback and also update the message
140 // center observers.
141 virtual void ClickOnNotificationButton(const std::string& id,
142 int button_index) = 0;
144 // This should be called by UI classes after a visible notification popup
145 // closes, indicating that the notification has been shown to the user.
146 // |mark_notification_as_read|, if false, will unset the read bit on a
147 // notification, increasing the unread count of the center.
148 virtual void MarkSinglePopupAsShown(const std::string& id,
149 bool mark_notification_as_read) = 0;
151 // This should be called by UI classes when a notification is first displayed
152 // to the user, in order to decrement the unread_count for the tray, and to
153 // notify observers that the notification is visible.
154 virtual void DisplayedNotification(const std::string& id) = 0;
156 // Setter/getter of notifier settings provider. This will be a weak reference.
157 // This should be set at the initialization process. The getter may return
158 // NULL for tests.
159 virtual void SetNotifierSettingsProvider(
160 NotifierSettingsProvider* provider) = 0;
161 virtual NotifierSettingsProvider* GetNotifierSettingsProvider() = 0;
163 // This can be called to change the quiet mode state (without a timeout).
164 virtual void SetQuietMode(bool in_quiet_mode) = 0;
166 // Temporarily enables quiet mode for |expires_in| time.
167 virtual void EnterQuietModeWithExpire(const base::TimeDelta& expires_in) = 0;
169 // Informs the notification list whether the message center is visible.
170 // This affects whether or not a message has been "read".
171 virtual void SetMessageCenterVisible(bool visible) = 0;
173 // Allows querying the visibility of the center.
174 virtual bool IsMessageCenterVisible() = 0;
176 // UI classes should call this when there is cause to leave popups visible for
177 // longer than the default (for example, when the mouse hovers over a popup).
178 virtual void PausePopupTimers() = 0;
180 // UI classes should call this when the popup timers should restart (for
181 // example, after the mouse leaves the popup.)
182 virtual void RestartPopupTimers() = 0;
184 protected:
185 friend class ::TrayViewControllerTest;
186 virtual void DisableTimersForTest() = 0;
188 MessageCenter();
189 virtual ~MessageCenter();
191 private:
192 DISALLOW_COPY_AND_ASSIGN(MessageCenter);
195 } // namespace message_center
197 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_H_