wutao | 16db603c | 2018-07-10 06:43:59 | [diff] [blame] | 1 | // Copyright 2018 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 ASH_ASSISTANT_ASSISTANT_NOTIFICATION_CONTROLLER_H_ |
| 6 | #define ASH_ASSISTANT_ASSISTANT_NOTIFICATION_CONTROLLER_H_ |
| 7 | |
| 8 | #include <map> |
| 9 | |
| 10 | #include "ash/ash_export.h" |
| 11 | #include "base/macros.h" |
wutao | bb4e02f | 2018-07-13 01:47:28 | [diff] [blame] | 12 | #include "base/memory/weak_ptr.h" |
wutao | 16db603c | 2018-07-10 06:43:59 | [diff] [blame] | 13 | #include "chromeos/services/assistant/public/mojom/assistant.mojom.h" |
| 14 | #include "mojo/public/cpp/bindings/binding.h" |
wutao | 5775051 | 2018-07-17 00:55:44 | [diff] [blame] | 15 | #include "ui/message_center/public/cpp/notifier_id.h" |
wutao | 16db603c | 2018-07-10 06:43:59 | [diff] [blame] | 16 | |
| 17 | namespace ash { |
| 18 | |
| 19 | class AssistantController; |
| 20 | |
| 21 | // The class to manage assistant notifications. |
| 22 | class ASH_EXPORT AssistantNotificationController |
| 23 | : public chromeos::assistant::mojom::AssistantNotificationSubscriber { |
| 24 | public: |
| 25 | using AssistantNotificationPtr = |
| 26 | chromeos::assistant::mojom::AssistantNotificationPtr; |
| 27 | |
| 28 | explicit AssistantNotificationController( |
| 29 | AssistantController* assistant_controller); |
| 30 | ~AssistantNotificationController() override; |
| 31 | |
| 32 | // Provides a pointer to the |assistant| owned by AssistantController. |
| 33 | void SetAssistant(chromeos::assistant::mojom::Assistant* assistant); |
| 34 | |
wutao | 2dffee0 | 2018-07-16 04:15:20 | [diff] [blame] | 35 | void RetrieveNotification(AssistantNotificationPtr notification, |
| 36 | int action_index); |
wutao | bb4e02f | 2018-07-13 01:47:28 | [diff] [blame] | 37 | void DismissNotification(AssistantNotificationPtr notification); |
| 38 | |
wutao | 16db603c | 2018-07-10 06:43:59 | [diff] [blame] | 39 | // chromeos::assistant::mojom::AssistantNotificationSubscriber: |
| 40 | void OnShowNotification(AssistantNotificationPtr notification) override; |
wutao | 034b30c | 2018-07-11 17:40:58 | [diff] [blame] | 41 | void OnRemoveNotification(const std::string& grouping_id) override; |
wutao | 16db603c | 2018-07-10 06:43:59 | [diff] [blame] | 42 | |
| 43 | private: |
David Black | c22e435 | 2018-07-11 21:29:48 | [diff] [blame] | 44 | AssistantController* const assistant_controller_; // Owned by Shell. |
wutao | 16db603c | 2018-07-10 06:43:59 | [diff] [blame] | 45 | |
| 46 | mojo::Binding<chromeos::assistant::mojom::AssistantNotificationSubscriber> |
| 47 | assistant_notification_subscriber_binding_; |
| 48 | |
| 49 | // Owned by AssistantController. |
| 50 | chromeos::assistant::mojom::Assistant* assistant_ = nullptr; |
| 51 | |
wutao | 5775051 | 2018-07-17 00:55:44 | [diff] [blame] | 52 | const message_center::NotifierId notifier_id_; |
wutao | 16db603c | 2018-07-10 06:43:59 | [diff] [blame] | 53 | |
wutao | bb4e02f | 2018-07-13 01:47:28 | [diff] [blame] | 54 | base::WeakPtrFactory<AssistantNotificationController> weak_factory_; |
| 55 | |
wutao | 16db603c | 2018-07-10 06:43:59 | [diff] [blame] | 56 | DISALLOW_COPY_AND_ASSIGN(AssistantNotificationController); |
| 57 | }; |
| 58 | |
| 59 | } // namespace ash |
| 60 | |
| 61 | #endif // ASH_ASSISTANT_ASSISTANT_NOTIFICATION_CONTROLLER_H_ |