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 MessageCenterTrayBridgeTest
;
19 class WebNotificationTrayTest
;
22 namespace message_center
{
24 class MessagePopupCollectionTest
;
27 class NotifierSettingsDelegate
;
28 class NotifierSettingsProvider
;
30 // Brings up the settings dialog and returns a weak reference to the delegate,
31 // which is typically the view. If the dialog already exists, it is brought to
32 // the front, otherwise it is created.
33 MESSAGE_CENTER_EXPORT NotifierSettingsDelegate
* ShowSettings(
34 NotifierSettingsProvider
* provider
,
35 gfx::NativeView context
);
37 // The struct to distinguish the notifiers.
38 struct MESSAGE_CENTER_EXPORT NotifierId
{
45 // Constructor for non WEB_PAGE type.
46 NotifierId(NotifierType type
, const std::string
& id
);
48 // Constructor for WEB_PAGE type.
49 explicit NotifierId(const GURL
& url
);
51 bool operator==(const NotifierId
& other
) const;
52 // Allows NotifierId to be used as a key in std::map.
53 bool operator<(const NotifierId
& other
) const;
57 // The identifier of the app notifier. Empty if it's WEB_PAGE.
60 // The URL pattern of the notifer.
63 // The identifier of the profile where the notification is created. This is
64 // used for ChromeOS multi-profile support and can be empty.
65 std::string profile_id
;
68 friend class ::MessageCenterTrayBridgeTest
;
69 friend class MessageCenterTrayTest
;
70 friend class test::MessagePopupCollectionTest
;
71 friend class NotificationControllerTest
;
72 friend class PopupCollectionTest
;
73 friend class TrayViewControllerTest
;
74 friend class ash::WebNotificationTrayTest
;
75 FRIEND_TEST_ALL_PREFIXES(PopupControllerTest
, Creation
);
76 FRIEND_TEST_ALL_PREFIXES(NotificationListTest
, UnreadCountNoNegative
);
77 FRIEND_TEST_ALL_PREFIXES(NotificationListTest
, TestHasNotificationOfType
);
79 // The default constructor which doesn't specify the notifier. Used for tests.
83 // The struct to hold the information of notifiers. The information will be
84 // used by NotifierSettingsView.
85 struct MESSAGE_CENTER_EXPORT Notifier
{
86 Notifier(const NotifierId
& notifier_id
,
87 const base::string16
& name
,
91 NotifierId notifier_id
;
93 // The human-readable name of the notifier such like the extension name.
97 // True if the source is allowed to send notifications. True is default.
100 // The icon image of the notifier. The extension icon or favicon.
104 DISALLOW_COPY_AND_ASSIGN(Notifier
);
107 struct MESSAGE_CENTER_EXPORT NotifierGroup
{
108 NotifierGroup(const gfx::Image
& icon
,
109 const base::string16
& name
,
110 const base::string16
& login_info
,
114 // Icon of a notifier group.
115 const gfx::Image icon
;
117 // Display name of a notifier group.
118 const base::string16 name
;
120 // More display information about the notifier group.
121 base::string16 login_info
;
123 // Unique identifier for the notifier group so that they can be selected in
128 DISALLOW_COPY_AND_ASSIGN(NotifierGroup
);
131 // An observer class implemented by the view of the NotifierSettings to get
132 // notified when the controller has changed data.
133 class MESSAGE_CENTER_EXPORT NotifierSettingsObserver
{
135 // Called when an icon in the controller has been updated.
136 virtual void UpdateIconImage(const NotifierId
& notifier_id
,
137 const gfx::Image
& icon
) = 0;
139 // Called when any change happens to the set of notifier groups.
140 virtual void NotifierGroupChanged() = 0;
142 // Called when a notifier is enabled or disabled.
143 virtual void NotifierEnabledChanged(const NotifierId
& notifier_id
,
147 // A class used by NotifierSettingsView to integrate with a setting system
148 // for the clients of this module.
149 class MESSAGE_CENTER_EXPORT NotifierSettingsProvider
{
151 virtual ~NotifierSettingsProvider() {};
153 // Sets the delegate.
154 virtual void AddObserver(NotifierSettingsObserver
* observer
) = 0;
155 virtual void RemoveObserver(NotifierSettingsObserver
* observer
) = 0;
157 // Returns the number of notifier groups available.
158 virtual size_t GetNotifierGroupCount() const = 0;
160 // Requests the model for a particular notifier group.
161 virtual const message_center::NotifierGroup
& GetNotifierGroupAt(
162 size_t index
) const = 0;
164 // Returns true if the notifier group at |index| is active.
165 virtual bool IsNotifierGroupActiveAt(size_t index
) const = 0;
167 // Informs the settings provider that further requests to GetNotifierList
168 // should return notifiers for the specified notifier group.
169 virtual void SwitchToNotifierGroup(size_t index
) = 0;
171 // Requests the currently active notifier group.
172 virtual const message_center::NotifierGroup
& GetActiveNotifierGroup()
175 // Collects the current notifier list and fills to |notifiers|. Caller takes
176 // the ownership of the elements of |notifiers|.
177 virtual void GetNotifierList(std::vector
<Notifier
*>* notifiers
) = 0;
179 // Called when the |enabled| for the |notifier| has been changed by user
181 virtual void SetNotifierEnabled(const Notifier
& notifier
, bool enabled
) = 0;
183 // Called when the settings window is closed.
184 virtual void OnNotifierSettingsClosing() = 0;
186 // Called to determine if a particular notifier can respond to a request for
188 virtual bool NotifierHasAdvancedSettings(const NotifierId
& notifier_id
)
191 // Called upon request for more information about a particular notifier.
192 virtual void OnNotifierAdvancedSettingsRequested(
193 const NotifierId
& notifier_id
,
194 const std::string
* notification_id
) = 0;
197 } // namespace message_center
199 #endif // UI_MESSAGE_CENTER_NOTIFIER_SETTINGS_H_