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 | |
Evan Stade | d6d837f | 2017-09-29 02:51:02 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFIER_CONTROLLER_H_ |
| 6 | #define CHROME_BROWSER_NOTIFICATIONS_NOTIFIER_CONTROLLER_H_ |
hirono | d36c21d | 2016-06-21 01:25:22 | [diff] [blame] | 7 | |
| 8 | #include <memory> |
| 9 | #include <vector> |
| 10 | |
Evan Stade | 55575d8 | 2017-11-02 00:52:36 | [diff] [blame] | 11 | #include "ash/public/interfaces/ash_message_center_controller.mojom.h" |
hirono | d36c21d | 2016-06-21 01:25:22 | [diff] [blame] | 12 | #include "base/macros.h" |
Evan Stade | 889ce471 | 2018-01-28 15:26:26 | [diff] [blame^] | 13 | #include "ui/message_center/public/cpp/notifier_id.h" |
hirono | d36c21d | 2016-06-21 01:25:22 | [diff] [blame] | 14 | |
| 15 | class Profile; |
| 16 | |
Evan Stade | d6d837f | 2017-09-29 02:51:02 | [diff] [blame] | 17 | // An interface to control Notifiers, grouped by NotifierType. Controllers are |
| 18 | // responsible for both collating display data and toggling settings in response |
| 19 | // to user inputs. |
| 20 | class NotifierController { |
hirono | d36c21d | 2016-06-21 01:25:22 | [diff] [blame] | 21 | public: |
| 22 | class Observer { |
| 23 | public: |
| 24 | virtual void OnIconImageUpdated(const message_center::NotifierId& id, |
Evan Stade | 55575d8 | 2017-11-02 00:52:36 | [diff] [blame] | 25 | const gfx::ImageSkia& image) = 0; |
hirono | d36c21d | 2016-06-21 01:25:22 | [diff] [blame] | 26 | virtual void OnNotifierEnabledChanged(const message_center::NotifierId& id, |
| 27 | bool enabled) = 0; |
| 28 | }; |
| 29 | |
Evan Stade | d6d837f | 2017-09-29 02:51:02 | [diff] [blame] | 30 | NotifierController() = default; |
| 31 | virtual ~NotifierController() = default; |
hirono | d36c21d | 2016-06-21 01:25:22 | [diff] [blame] | 32 | |
Evan Stade | d6d837f | 2017-09-29 02:51:02 | [diff] [blame] | 33 | // Returns notifiers to display in the settings UI. Not all notifiers appear |
| 34 | // in settings. If the source starts loading for icon images, it needs to call |
hirono | d36c21d | 2016-06-21 01:25:22 | [diff] [blame] | 35 | // Observer::OnIconImageUpdated after the icon is loaded. |
Evan Stade | 55575d8 | 2017-11-02 00:52:36 | [diff] [blame] | 36 | virtual std::vector<ash::mojom::NotifierUiDataPtr> GetNotifierList( |
| 37 | Profile* profile) = 0; |
hirono | d36c21d | 2016-06-21 01:25:22 | [diff] [blame] | 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 | |
hirono | d36c21d | 2016-06-21 01:25:22 | [diff] [blame] | 46 | private: |
Evan Stade | d6d837f | 2017-09-29 02:51:02 | [diff] [blame] | 47 | DISALLOW_COPY_AND_ASSIGN(NotifierController); |
hirono | d36c21d | 2016-06-21 01:25:22 | [diff] [blame] | 48 | }; |
| 49 | |
Evan Stade | d6d837f | 2017-09-29 02:51:02 | [diff] [blame] | 50 | #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFIER_CONTROLLER_H_ |