Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 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. |
| 4 | |
| 5 | #ifndef UI_MESSAGE_CENTER_NOTIFIER_SETTINGS_H_ |
| 6 | #define UI_MESSAGE_CENTER_NOTIFIER_SETTINGS_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 10 | #include "base/strings/string16.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 11 | #include "ui/gfx/image/image.h" |
| 12 | #include "ui/message_center/message_center_export.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 13 | #include "url/gurl.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 14 | |
| 15 | namespace message_center { |
| 16 | |
| 17 | class NotifierSettingsDelegate; |
| 18 | class NotifierSettingsProvider; |
| 19 | |
| 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); |
| 26 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 27 | // The struct to distinguish the notifiers. |
| 28 | struct MESSAGE_CENTER_EXPORT NotifierId { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 29 | enum NotifierType { |
| 30 | APPLICATION, |
| 31 | WEB_PAGE, |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 32 | SYSTEM_COMPONENT, |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 33 | SYNCED_NOTIFICATION_SERVICE, |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | enum SystemComponentNotifierType { |
| 37 | NONE, |
| 38 | SCREENSHOT, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 39 | }; |
| 40 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 41 | // Constructor for APPLICATION and SYNCED_NOTIFICATION_SERVICE type. |
| 42 | NotifierId(NotifierType type, const std::string& id); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 43 | |
| 44 | // Constructor for WEB_PAGE type. |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 45 | explicit NotifierId(const GURL& url); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 46 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 47 | // Constructor for SYSTEM_COMPONENT type. |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 48 | explicit NotifierId(SystemComponentNotifierType type); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 49 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 50 | bool operator==(const NotifierId& other) const; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 51 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 52 | NotifierType type; |
| 53 | |
| 54 | // The identifier of the app notifier. Empty if it's not APPLICATION or |
| 55 | // SYNCED_NOTIFICATION_SERVICE. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 56 | std::string id; |
| 57 | |
| 58 | // The URL pattern of the notifer. |
| 59 | GURL url; |
| 60 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 61 | // The type of system component notifier. |
| 62 | SystemComponentNotifierType system_component_type; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | // The struct to hold the information of notifiers. The information will be |
| 66 | // used by NotifierSettingsView. |
| 67 | struct MESSAGE_CENTER_EXPORT Notifier { |
| 68 | Notifier(const NotifierId& notifier_id, const string16& name, bool enabled); |
| 69 | ~Notifier(); |
| 70 | |
| 71 | NotifierId notifier_id; |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 72 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 73 | // The human-readable name of the notifier such like the extension name. |
| 74 | // It can be empty. |
| 75 | string16 name; |
| 76 | |
| 77 | // True if the source is allowed to send notifications. True is default. |
| 78 | bool enabled; |
| 79 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 80 | // The icon image of the notifier. The extension icon or favicon. |
| 81 | gfx::Image icon; |
| 82 | |
| 83 | private: |
| 84 | DISALLOW_COPY_AND_ASSIGN(Notifier); |
| 85 | }; |
| 86 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 87 | struct MESSAGE_CENTER_EXPORT NotifierGroup { |
| 88 | NotifierGroup(const gfx::Image& icon, |
| 89 | const string16& name, |
| 90 | const string16& login_info, |
| 91 | size_t index); |
| 92 | ~NotifierGroup(); |
| 93 | |
| 94 | // Icon of a notifier group. |
| 95 | const gfx::Image icon; |
| 96 | |
| 97 | // Display name of a notifier group. |
| 98 | const string16 name; |
| 99 | |
| 100 | // More display information about the notifier group. |
| 101 | string16 login_info; |
| 102 | |
| 103 | // Unique identifier for the notifier group so that they can be selected in |
| 104 | // the UI. |
| 105 | const size_t index; |
| 106 | |
| 107 | private: |
| 108 | DISALLOW_COPY_AND_ASSIGN(NotifierGroup); |
| 109 | }; |
| 110 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 111 | MESSAGE_CENTER_EXPORT std::string ToString( |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 112 | NotifierId::SystemComponentNotifierType type); |
| 113 | MESSAGE_CENTER_EXPORT NotifierId::SystemComponentNotifierType |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 114 | ParseSystemComponentName(const std::string& name); |
| 115 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 116 | // An observer class implemented by the view of the NotifierSettings to get |
| 117 | // notified when the controller has changed data. |
| 118 | class MESSAGE_CENTER_EXPORT NotifierSettingsObserver { |
| 119 | public: |
| 120 | // Called when an icon in the controller has been updated. |
| 121 | virtual void UpdateIconImage(const NotifierId& notifier_id, |
| 122 | const gfx::Image& icon) = 0; |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 123 | |
| 124 | // Called when any change happens to the set of notifier groups. |
| 125 | virtual void NotifierGroupChanged() = 0; |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 126 | }; |
| 127 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 128 | // A class used by NotifierSettingsView to integrate with a setting system |
| 129 | // for the clients of this module. |
| 130 | class MESSAGE_CENTER_EXPORT NotifierSettingsProvider { |
| 131 | public: |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 132 | virtual ~NotifierSettingsProvider() {}; |
| 133 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 134 | // Sets the delegate. |
| 135 | virtual void AddObserver(NotifierSettingsObserver* observer) = 0; |
| 136 | virtual void RemoveObserver(NotifierSettingsObserver* observer) = 0; |
| 137 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 138 | // Returns the number of notifier groups available. |
| 139 | virtual size_t GetNotifierGroupCount() const = 0; |
| 140 | |
| 141 | // Requests the model for a particular notifier group. |
| 142 | virtual const message_center::NotifierGroup& GetNotifierGroupAt( |
| 143 | size_t index) const = 0; |
| 144 | |
| 145 | // Informs the settings provider that further requests to GetNotifierList |
| 146 | // should return notifiers for the specified notifier group. |
| 147 | virtual void SwitchToNotifierGroup(size_t index) = 0; |
| 148 | |
| 149 | // Requests the currently active notifier group. |
| 150 | virtual const message_center::NotifierGroup& GetActiveNotifierGroup() |
| 151 | const = 0; |
| 152 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 153 | // Collects the current notifier list and fills to |notifiers|. Caller takes |
| 154 | // the ownership of the elements of |notifiers|. |
| 155 | virtual void GetNotifierList(std::vector<Notifier*>* notifiers) = 0; |
| 156 | |
| 157 | // Called when the |enabled| for the |notifier| has been changed by user |
| 158 | // operation. |
| 159 | virtual void SetNotifierEnabled(const Notifier& notifier, bool enabled) = 0; |
| 160 | |
| 161 | // Called when the settings window is closed. |
| 162 | virtual void OnNotifierSettingsClosing() = 0; |
| 163 | }; |
| 164 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 165 | } // namespace message_center |
| 166 | |
| 167 | #endif // UI_MESSAGE_CENTER_NOTIFIER_SETTINGS_H_ |