1 // Copyright (c) 2013 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_NOTIFIER_SETTINGS_H_
6 #define UI_MESSAGE_CENTER_NOTIFIER_SETTINGS_H_
10 #include "base/gtest_prod_util.h"
11 #include "base/strings/string16.h"
12 #include "ui/gfx/image/image.h"
13 #include "ui/message_center/message_center_export.h"
16 class MessageCenterNotificationsTest
;
17 class MessageCenterTrayBridgeTest
;
18 class StubNotificationUIManager
;
21 class WebNotificationTrayTest
;
24 namespace message_center
{
26 class MessagePopupCollectionTest
;
29 class MessageCenterNotificationManagerTest
;
30 class NotifierSettingsDelegate
;
31 class NotifierSettingsProvider
;
33 // Brings up the settings dialog and returns a weak reference to the delegate,
34 // which is typically the view. If the dialog already exists, it is brought to
35 // the front, otherwise it is created.
36 MESSAGE_CENTER_EXPORT NotifierSettingsDelegate
* ShowSettings(
37 NotifierSettingsProvider
* provider
,
38 gfx::NativeView context
);
40 // The struct to distinguish the notifiers.
41 struct MESSAGE_CENTER_EXPORT NotifierId
{
48 // Constructor for non WEB_PAGE type.
49 NotifierId(NotifierType type
, const std::string
& id
);
51 // Constructor for WEB_PAGE type.
52 explicit NotifierId(const GURL
& url
);
54 bool operator==(const NotifierId
& other
) const;
55 // Allows NotifierId to be used as a key in std::map.
56 bool operator<(const NotifierId
& other
) const;
60 // The identifier of the app notifier. Empty if it's WEB_PAGE.
63 // The URL pattern of the notifer.
66 // The identifier of the profile where the notification is created. This is
67 // used for ChromeOS multi-profile support and can be empty.
68 std::string profile_id
;
71 friend class MessageCenterNotificationManagerTest
;
72 friend class MessageCenterTrayTest
;
73 friend class NotificationControllerTest
;
74 friend class PopupCollectionTest
;
75 friend class TrayViewControllerTest
;
76 friend class ::MessageCenterNotificationsTest
;
77 friend class ::MessageCenterTrayBridgeTest
;
78 friend class ::StubNotificationUIManager
;
79 friend class ash::WebNotificationTrayTest
;
80 friend class test::MessagePopupCollectionTest
;
81 FRIEND_TEST_ALL_PREFIXES(PopupControllerTest
, Creation
);
82 FRIEND_TEST_ALL_PREFIXES(NotificationListTest
, UnreadCountNoNegative
);
83 FRIEND_TEST_ALL_PREFIXES(NotificationListTest
, TestHasNotificationOfType
);
85 // The default constructor which doesn't specify the notifier. Used for tests.
89 // The struct to hold the information of notifiers. The information will be
90 // used by NotifierSettingsView.
91 struct MESSAGE_CENTER_EXPORT Notifier
{
92 Notifier(const NotifierId
& notifier_id
,
93 const base::string16
& name
,
97 NotifierId notifier_id
;
99 // The human-readable name of the notifier such like the extension name.
103 // True if the source is allowed to send notifications. True is default.
106 // The icon image of the notifier. The extension icon or favicon.
110 DISALLOW_COPY_AND_ASSIGN(Notifier
);
113 struct MESSAGE_CENTER_EXPORT NotifierGroup
{
114 NotifierGroup(const gfx::Image
& icon
,
115 const base::string16
& name
,
116 const base::string16
& login_info
,
120 // Icon of a notifier group.
121 const gfx::Image icon
;
123 // Display name of a notifier group.
124 const base::string16 name
;
126 // More display information about the notifier group.
127 base::string16 login_info
;
129 // Unique identifier for the notifier group so that they can be selected in
134 DISALLOW_COPY_AND_ASSIGN(NotifierGroup
);
137 // An observer class implemented by the view of the NotifierSettings to get
138 // notified when the controller has changed data.
139 class MESSAGE_CENTER_EXPORT NotifierSettingsObserver
{
141 // Called when an icon in the controller has been updated.
142 virtual void UpdateIconImage(const NotifierId
& notifier_id
,
143 const gfx::Image
& icon
) = 0;
145 // Called when any change happens to the set of notifier groups.
146 virtual void NotifierGroupChanged() = 0;
148 // Called when a notifier is enabled or disabled.
149 virtual void NotifierEnabledChanged(const NotifierId
& notifier_id
,
153 // A class used by NotifierSettingsView to integrate with a setting system
154 // for the clients of this module.
155 class MESSAGE_CENTER_EXPORT NotifierSettingsProvider
{
157 virtual ~NotifierSettingsProvider() {};
159 // Sets the delegate.
160 virtual void AddObserver(NotifierSettingsObserver
* observer
) = 0;
161 virtual void RemoveObserver(NotifierSettingsObserver
* observer
) = 0;
163 // Returns the number of notifier groups available.
164 virtual size_t GetNotifierGroupCount() const = 0;
166 // Requests the model for a particular notifier group.
167 virtual const message_center::NotifierGroup
& GetNotifierGroupAt(
168 size_t index
) const = 0;
170 // Returns true if the notifier group at |index| is active.
171 virtual bool IsNotifierGroupActiveAt(size_t index
) const = 0;
173 // Informs the settings provider that further requests to GetNotifierList
174 // should return notifiers for the specified notifier group.
175 virtual void SwitchToNotifierGroup(size_t index
) = 0;
177 // Requests the currently active notifier group.
178 virtual const message_center::NotifierGroup
& GetActiveNotifierGroup()
181 // Collects the current notifier list and fills to |notifiers|. Caller takes
182 // the ownership of the elements of |notifiers|.
183 virtual void GetNotifierList(std::vector
<Notifier
*>* notifiers
) = 0;
185 // Called when the |enabled| for the |notifier| has been changed by user
187 virtual void SetNotifierEnabled(const Notifier
& notifier
, bool enabled
) = 0;
189 // Called when the settings window is closed.
190 virtual void OnNotifierSettingsClosing() = 0;
192 // Called to determine if a particular notifier can respond to a request for
194 virtual bool NotifierHasAdvancedSettings(const NotifierId
& notifier_id
)
197 // Called upon request for more information about a particular notifier.
198 virtual void OnNotifierAdvancedSettingsRequested(
199 const NotifierId
& notifier_id
,
200 const std::string
* notification_id
) = 0;
203 } // namespace message_center
205 #endif // UI_MESSAGE_CENTER_NOTIFIER_SETTINGS_H_