blob: e332918abea06367f54be5d2ac524d3c3d4bd04c [file] [log] [blame]
wutao16db603c2018-07-10 06:43:591// 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"
wutaobb4e02f2018-07-13 01:47:2812#include "base/memory/weak_ptr.h"
wutao16db603c2018-07-10 06:43:5913#include "chromeos/services/assistant/public/mojom/assistant.mojom.h"
14#include "mojo/public/cpp/bindings/binding.h"
wutao57750512018-07-17 00:55:4415#include "ui/message_center/public/cpp/notifier_id.h"
wutao16db603c2018-07-10 06:43:5916
17namespace ash {
18
19class AssistantController;
20
21// The class to manage assistant notifications.
22class 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
wutao2dffee02018-07-16 04:15:2035 void RetrieveNotification(AssistantNotificationPtr notification,
36 int action_index);
wutaobb4e02f2018-07-13 01:47:2837 void DismissNotification(AssistantNotificationPtr notification);
38
wutao16db603c2018-07-10 06:43:5939 // chromeos::assistant::mojom::AssistantNotificationSubscriber:
40 void OnShowNotification(AssistantNotificationPtr notification) override;
wutao034b30c2018-07-11 17:40:5841 void OnRemoveNotification(const std::string& grouping_id) override;
wutao16db603c2018-07-10 06:43:5942
43 private:
David Blackc22e4352018-07-11 21:29:4844 AssistantController* const assistant_controller_; // Owned by Shell.
wutao16db603c2018-07-10 06:43:5945
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
wutao57750512018-07-17 00:55:4452 const message_center::NotifierId notifier_id_;
wutao16db603c2018-07-10 06:43:5953
wutaobb4e02f2018-07-13 01:47:2854 base::WeakPtrFactory<AssistantNotificationController> weak_factory_;
55
wutao16db603c2018-07-10 06:43:5956 DISALLOW_COPY_AND_ASSIGN(AssistantNotificationController);
57};
58
59} // namespace ash
60
61#endif // ASH_ASSISTANT_ASSISTANT_NOTIFICATION_CONTROLLER_H_