hirono | d36c21d | 2016-06-21 01:25:22 | [diff] [blame] | 1 | // Copyright (c) 2016 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 CHROME_BROWSER_NOTIFICATIONS_NOTIFIER_SOURCE_H_ |
| 6 | #define CHROME_BROWSER_NOTIFICATIONS_NOTIFIER_SOURCE_H_ |
| 7 | |
| 8 | #include <memory> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include "base/macros.h" |
| 12 | #include "ui/message_center/notifier_settings.h" |
| 13 | |
| 14 | class Profile; |
| 15 | |
| 16 | namespace message_center { |
| 17 | struct Notifier; |
hirono | d36c21d | 2016-06-21 01:25:22 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | class NotifierSource { |
| 21 | public: |
| 22 | class Observer { |
| 23 | public: |
| 24 | virtual void OnIconImageUpdated(const message_center::NotifierId& id, |
| 25 | const gfx::Image& image) = 0; |
| 26 | virtual void OnNotifierEnabledChanged(const message_center::NotifierId& id, |
| 27 | bool enabled) = 0; |
| 28 | }; |
| 29 | |
| 30 | NotifierSource() = default; |
| 31 | virtual ~NotifierSource() = default; |
| 32 | |
| 33 | // Returns notifiers. |
| 34 | // If the source starts loading for icon images, it needs to call |
| 35 | // Observer::OnIconImageUpdated after the icon is loaded. |
| 36 | virtual std::vector<std::unique_ptr<message_center::Notifier>> |
| 37 | GetNotifierList(Profile* profile) = 0; |
| 38 | |
Evan Stade | 844ad7f | 2017-09-20 18:05:31 | [diff] [blame^] | 39 | // Set notifier enabled. |notifier_id| must have notifier type that can be |
hirono | d36c21d | 2016-06-21 01:25:22 | [diff] [blame] | 40 | // handled by the source. It has responsibility to invoke |
| 41 | // Observer::OnNotifierEnabledChanged. |
| 42 | virtual void SetNotifierEnabled(Profile* profile, |
Evan Stade | 844ad7f | 2017-09-20 18:05:31 | [diff] [blame^] | 43 | const message_center::NotifierId& notifier_id, |
hirono | d36c21d | 2016-06-21 01:25:22 | [diff] [blame] | 44 | bool enabled) = 0; |
| 45 | |
| 46 | // Release temporary resouces tagged with notifier list that is returned last |
| 47 | // time. |
| 48 | virtual void OnNotifierSettingsClosing() {} |
| 49 | |
| 50 | // Notifier type provided by the source. |
| 51 | virtual message_center::NotifierId::NotifierType GetNotifierType() = 0; |
| 52 | |
| 53 | private: |
| 54 | DISALLOW_COPY_AND_ASSIGN(NotifierSource); |
| 55 | }; |
| 56 | |
| 57 | #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFIER_SOURCE_H_ |