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/strings/string16.h"
11 #include "ui/gfx/image/image.h"
12 #include "ui/message_center/message_center_export.h"
15 namespace message_center
{
17 class NotifierSettingsDelegate
;
18 class NotifierSettingsProvider
;
20 // Brings up the settings dialog and returns a weak reference to the delegate,
21 // which is typically the view. If the dialog already exists, it is brought to
22 // the front, otherwise it is created.
23 MESSAGE_CENTER_EXPORT NotifierSettingsDelegate
* ShowSettings(
24 NotifierSettingsProvider
* provider
,
25 gfx::NativeView context
);
27 // The struct to distinguish the notifiers.
28 struct MESSAGE_CENTER_EXPORT NotifierId
{
33 SYNCED_NOTIFICATION_SERVICE
,
36 // Constructor for APPLICATION and SYNCED_NOTIFICATION_SERVICE type.
37 NotifierId(NotifierType type
, const std::string
& id
);
39 // Constructor for WEB_PAGE type.
40 explicit NotifierId(const GURL
& url
);
42 // Constructor for system component types. The type should be positive.
43 explicit NotifierId(int type
);
45 // The default constructor which doesn't specify the notifier. Used for tests.
48 bool operator==(const NotifierId
& other
) const;
52 // The identifier of the app notifier. Empty if it's not APPLICATION or
53 // SYNCED_NOTIFICATION_SERVICE.
56 // The URL pattern of the notifer.
59 // The type of system component notifier, usually used in ash. -1 if it's not
60 // the system component. See also: ash/system/system_notifier.h
61 int system_component_type
;
64 // The struct to hold the information of notifiers. The information will be
65 // used by NotifierSettingsView.
66 struct MESSAGE_CENTER_EXPORT Notifier
{
67 Notifier(const NotifierId
& notifier_id
, const string16
& name
, bool enabled
);
70 NotifierId notifier_id
;
72 // The human-readable name of the notifier such like the extension name.
76 // True if the source is allowed to send notifications. True is default.
79 // The icon image of the notifier. The extension icon or favicon.
83 DISALLOW_COPY_AND_ASSIGN(Notifier
);
86 struct MESSAGE_CENTER_EXPORT NotifierGroup
{
87 NotifierGroup(const gfx::Image
& icon
,
89 const string16
& login_info
,
93 // Icon of a notifier group.
94 const gfx::Image icon
;
96 // Display name of a notifier group.
99 // More display information about the notifier group.
102 // Unique identifier for the notifier group so that they can be selected in
107 DISALLOW_COPY_AND_ASSIGN(NotifierGroup
);
110 // An observer class implemented by the view of the NotifierSettings to get
111 // notified when the controller has changed data.
112 class MESSAGE_CENTER_EXPORT NotifierSettingsObserver
{
114 // Called when an icon in the controller has been updated.
115 virtual void UpdateIconImage(const NotifierId
& notifier_id
,
116 const gfx::Image
& icon
) = 0;
118 // Called when any change happens to the set of notifier groups.
119 virtual void NotifierGroupChanged() = 0;
122 // A class used by NotifierSettingsView to integrate with a setting system
123 // for the clients of this module.
124 class MESSAGE_CENTER_EXPORT NotifierSettingsProvider
{
126 virtual ~NotifierSettingsProvider() {};
128 // Sets the delegate.
129 virtual void AddObserver(NotifierSettingsObserver
* observer
) = 0;
130 virtual void RemoveObserver(NotifierSettingsObserver
* observer
) = 0;
132 // Returns the number of notifier groups available.
133 virtual size_t GetNotifierGroupCount() const = 0;
135 // Requests the model for a particular notifier group.
136 virtual const message_center::NotifierGroup
& GetNotifierGroupAt(
137 size_t index
) const = 0;
139 // Returns true if the notifier group at |index| is active.
140 virtual bool IsNotifierGroupActiveAt(size_t index
) const = 0;
142 // Informs the settings provider that further requests to GetNotifierList
143 // should return notifiers for the specified notifier group.
144 virtual void SwitchToNotifierGroup(size_t index
) = 0;
146 // Requests the currently active notifier group.
147 virtual const message_center::NotifierGroup
& GetActiveNotifierGroup()
150 // Collects the current notifier list and fills to |notifiers|. Caller takes
151 // the ownership of the elements of |notifiers|.
152 virtual void GetNotifierList(std::vector
<Notifier
*>* notifiers
) = 0;
154 // Called when the |enabled| for the |notifier| has been changed by user
156 virtual void SetNotifierEnabled(const Notifier
& notifier
, bool enabled
) = 0;
158 // Called when the settings window is closed.
159 virtual void OnNotifierSettingsClosing() = 0;
161 // Called to determine if a particular notifier can respond to a request for
163 virtual bool NotifierHasAdvancedSettings(const NotifierId
& notifier_id
)
166 // Called upon request for more information about a particular notifier.
167 virtual void OnNotifierAdvancedSettingsRequested(
168 const NotifierId
& notifier_id
,
169 const std::string
* notification_id
) = 0;
172 } // namespace message_center
174 #endif // UI_MESSAGE_CENTER_NOTIFIER_SETTINGS_H_