Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / ui / message_center / notifier_settings.h
blob68ec9fd72580a29ae35328eedabed2a843191b1b
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_
8 #include <string>
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"
14 #include "url/gurl.h"
16 class MessageCenterNotificationsTest;
17 class MessageCenterTrayBridgeTest;
18 class StubNotificationUIManager;
20 namespace ash {
21 class WebNotificationTrayTest;
24 namespace message_center {
25 namespace test {
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 {
42 enum NotifierType {
43 APPLICATION,
44 WEB_PAGE,
45 SYSTEM_COMPONENT,
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;
58 NotifierType type;
60 // The identifier of the app notifier. Empty if it's WEB_PAGE.
61 std::string id;
63 // The URL pattern of the notifer.
64 GURL url;
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;
70 private:
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.
86 NotifierId();
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,
94 bool enabled);
95 ~Notifier();
97 NotifierId notifier_id;
99 // The human-readable name of the notifier such like the extension name.
100 // It can be empty.
101 base::string16 name;
103 // True if the source is allowed to send notifications. True is default.
104 bool enabled;
106 // The icon image of the notifier. The extension icon or favicon.
107 gfx::Image icon;
109 private:
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,
117 size_t index);
118 ~NotifierGroup();
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
130 // the UI.
131 const size_t index;
133 private:
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 {
140 public:
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,
150 bool enabled) = 0;
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 {
156 public:
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()
179 const = 0;
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
186 // operation.
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
193 // more information.
194 virtual bool NotifierHasAdvancedSettings(const NotifierId& notifier_id)
195 const = 0;
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_