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
{
43 SYNCED_NOTIFICATION_SERVICE
,
46 // Constructor for non WEB_PAGE type.
47 NotifierId(NotifierType type
, const std::string
& id
);
49 // Constructor for WEB_PAGE type.
50 explicit NotifierId(const GURL
& url
);
52 bool operator==(const NotifierId
& other
) const;
53 // Allows NotifierId to be used as a key in std::map.
54 bool operator<(const NotifierId
& other
) const;
58 // The identifier of the app notifier. Empty if it's WEB_PAGE.
61 // The URL pattern of the notifer.
64 // The identifier of the profile where the notification is created. This is
65 // used for ChromeOS multi-profile support and can be empty.
66 std::string profile_id
;
69 friend class ::MessageCenterTrayBridgeTest
;
70 friend class MessageCenterTrayTest
;
71 friend class test::MessagePopupCollectionTest
;
72 friend class NotificationControllerTest
;
73 friend class PopupCollectionTest
;
74 friend class TrayViewControllerTest
;
75 friend class ash::WebNotificationTrayTest
;
76 FRIEND_TEST_ALL_PREFIXES(PopupControllerTest
, Creation
);
77 FRIEND_TEST_ALL_PREFIXES(NotificationListTest
, UnreadCountNoNegative
);
78 FRIEND_TEST_ALL_PREFIXES(NotificationListTest
, TestHasNotificationOfType
);
80 // The default constructor which doesn't specify the notifier. Used for tests.
84 // The struct to hold the information of notifiers. The information will be
85 // used by NotifierSettingsView.
86 struct MESSAGE_CENTER_EXPORT Notifier
{
87 Notifier(const NotifierId
& notifier_id
,
88 const base::string16
& name
,
92 NotifierId notifier_id
;
94 // The human-readable name of the notifier such like the extension name.
98 // True if the source is allowed to send notifications. True is default.
101 // The icon image of the notifier. The extension icon or favicon.
105 DISALLOW_COPY_AND_ASSIGN(Notifier
);
108 struct MESSAGE_CENTER_EXPORT NotifierGroup
{
109 NotifierGroup(const gfx::Image
& icon
,
110 const base::string16
& name
,
111 const base::string16
& login_info
,
115 // Icon of a notifier group.
116 const gfx::Image icon
;
118 // Display name of a notifier group.
119 const base::string16 name
;
121 // More display information about the notifier group.
122 base::string16 login_info
;
124 // Unique identifier for the notifier group so that they can be selected in
129 DISALLOW_COPY_AND_ASSIGN(NotifierGroup
);
132 // An observer class implemented by the view of the NotifierSettings to get
133 // notified when the controller has changed data.
134 class MESSAGE_CENTER_EXPORT NotifierSettingsObserver
{
136 // Called when an icon in the controller has been updated.
137 virtual void UpdateIconImage(const NotifierId
& notifier_id
,
138 const gfx::Image
& icon
) = 0;
140 // Called when any change happens to the set of notifier groups.
141 virtual void NotifierGroupChanged() = 0;
144 // A class used by NotifierSettingsView to integrate with a setting system
145 // for the clients of this module.
146 class MESSAGE_CENTER_EXPORT NotifierSettingsProvider
{
148 virtual ~NotifierSettingsProvider() {};
150 // Sets the delegate.
151 virtual void AddObserver(NotifierSettingsObserver
* observer
) = 0;
152 virtual void RemoveObserver(NotifierSettingsObserver
* observer
) = 0;
154 // Returns the number of notifier groups available.
155 virtual size_t GetNotifierGroupCount() const = 0;
157 // Requests the model for a particular notifier group.
158 virtual const message_center::NotifierGroup
& GetNotifierGroupAt(
159 size_t index
) const = 0;
161 // Returns true if the notifier group at |index| is active.
162 virtual bool IsNotifierGroupActiveAt(size_t index
) const = 0;
164 // Informs the settings provider that further requests to GetNotifierList
165 // should return notifiers for the specified notifier group.
166 virtual void SwitchToNotifierGroup(size_t index
) = 0;
168 // Requests the currently active notifier group.
169 virtual const message_center::NotifierGroup
& GetActiveNotifierGroup()
172 // Collects the current notifier list and fills to |notifiers|. Caller takes
173 // the ownership of the elements of |notifiers|.
174 virtual void GetNotifierList(std::vector
<Notifier
*>* notifiers
) = 0;
176 // Called when the |enabled| for the |notifier| has been changed by user
178 virtual void SetNotifierEnabled(const Notifier
& notifier
, bool enabled
) = 0;
180 // Called when the settings window is closed.
181 virtual void OnNotifierSettingsClosing() = 0;
183 // Called to determine if a particular notifier can respond to a request for
185 virtual bool NotifierHasAdvancedSettings(const NotifierId
& notifier_id
)
188 // Called upon request for more information about a particular notifier.
189 virtual void OnNotifierAdvancedSettingsRequested(
190 const NotifierId
& notifier_id
,
191 const std::string
* notification_id
) = 0;
194 } // namespace message_center
196 #endif // UI_MESSAGE_CENTER_NOTIFIER_SETTINGS_H_