Views Omnibox: tolerate minor click-to-select-all dragging.
[chromium-blink-merge.git] / ui / message_center / notifier_settings.h
blobf1ab7f0708f23545c82b5e556635622706bbeef8
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 MessageCenterTrayBridgeTest;
18 namespace ash {
19 class WebNotificationTrayTest;
22 namespace message_center {
23 namespace test {
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 {
39 enum NotifierType {
40 APPLICATION,
41 WEB_PAGE,
42 SYSTEM_COMPONENT,
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;
56 NotifierType type;
58 // The identifier of the app notifier. Empty if it's WEB_PAGE.
59 std::string id;
61 // The URL pattern of the notifer.
62 GURL url;
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;
68 private:
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.
81 NotifierId();
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,
89 bool enabled);
90 ~Notifier();
92 NotifierId notifier_id;
94 // The human-readable name of the notifier such like the extension name.
95 // It can be empty.
96 base::string16 name;
98 // True if the source is allowed to send notifications. True is default.
99 bool enabled;
101 // The icon image of the notifier. The extension icon or favicon.
102 gfx::Image icon;
104 private:
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,
112 size_t index);
113 ~NotifierGroup();
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
125 // the UI.
126 const size_t index;
128 private:
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 {
135 public:
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 {
147 public:
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()
170 const = 0;
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
177 // operation.
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
184 // more information.
185 virtual bool NotifierHasAdvancedSettings(const NotifierId& notifier_id)
186 const = 0;
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_