OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_ARC_NOTIFICATION_ARC_NOTIFICATION_MANAGER_H_ | 5 #ifndef UI_ARC_NOTIFICATION_ARC_NOTIFICATION_MANAGER_H_ |
6 #define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_MANAGER_H_ | 6 #define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <unordered_map> | 9 #include <unordered_map> |
10 | 10 |
11 #include "components/arc/arc_bridge_service.h" | 11 #include "components/arc/arc_bridge_service.h" |
12 #include "components/arc/arc_service.h" | 12 #include "components/arc/arc_service.h" |
13 #include "components/arc/common/notifications.mojom.h" | 13 #include "components/arc/common/notifications.mojom.h" |
| 14 #include "components/arc/instance_holder.h" |
14 #include "components/signin/core/account_id/account_id.h" | 15 #include "components/signin/core/account_id/account_id.h" |
15 #include "mojo/public/cpp/bindings/binding.h" | 16 #include "mojo/public/cpp/bindings/binding.h" |
16 #include "ui/message_center/message_center.h" | 17 #include "ui/message_center/message_center.h" |
17 | 18 |
18 namespace arc { | 19 namespace arc { |
19 | 20 |
20 class ArcNotificationItem; | 21 class ArcNotificationItem; |
21 | 22 |
22 class ArcNotificationManager : public ArcService, | 23 class ArcNotificationManager |
23 public ArcBridgeService::Observer, | 24 : public ArcService, |
24 public mojom::NotificationsHost { | 25 public InstanceHolder<mojom::NotificationsInstance>::Observer, |
| 26 public mojom::NotificationsHost { |
25 public: | 27 public: |
26 ArcNotificationManager(ArcBridgeService* bridge_service, | 28 ArcNotificationManager(ArcBridgeService* bridge_service, |
27 const AccountId& main_profile_id); | 29 const AccountId& main_profile_id); |
28 | 30 |
29 ArcNotificationManager(ArcBridgeService* bridge_service, | 31 ArcNotificationManager(ArcBridgeService* bridge_service, |
30 const AccountId& main_profile_id, | 32 const AccountId& main_profile_id, |
31 message_center::MessageCenter* message_center); | 33 message_center::MessageCenter* message_center); |
32 | 34 |
33 ~ArcNotificationManager() override; | 35 ~ArcNotificationManager() override; |
34 | 36 |
35 // ArcBridgeService::Observer implementation: | 37 // InstanceHolder<mojom::NotificationsInstance>::Observer implementation: |
36 void OnNotificationsInstanceReady() override; | 38 void OnInstanceReady(mojom::NotificationsInstance* notifications_instance, |
37 void OnNotificationsInstanceClosed() override; | 39 uint32_t version) override; |
| 40 void OnInstanceClosed(mojom::NotificationsInstance*) override; |
38 | 41 |
39 // mojom::NotificationsHost implementation: | 42 // mojom::NotificationsHost implementation: |
40 void OnNotificationPosted(mojom::ArcNotificationDataPtr data) override; | 43 void OnNotificationPosted(mojom::ArcNotificationDataPtr data) override; |
41 void OnNotificationRemoved(const mojo::String& key) override; | 44 void OnNotificationRemoved(const mojo::String& key) override; |
42 void OnToastPosted(mojom::ArcToastDataPtr data) override; | 45 void OnToastPosted(mojom::ArcToastDataPtr data) override; |
43 void OnToastCancelled(mojom::ArcToastDataPtr data) override; | 46 void OnToastCancelled(mojom::ArcToastDataPtr data) override; |
44 | 47 |
45 // Methods called from ArcNotificationItem: | 48 // Methods called from ArcNotificationItem: |
46 void SendNotificationRemovedFromChrome(const std::string& key); | 49 void SendNotificationRemovedFromChrome(const std::string& key); |
47 void SendNotificationClickedOnChrome(const std::string& key); | 50 void SendNotificationClickedOnChrome(const std::string& key); |
48 void SendNotificationButtonClickedOnChrome( | 51 void SendNotificationButtonClickedOnChrome(const std::string& key, |
49 const std::string& key, int button_index); | 52 int button_index); |
50 | 53 |
51 private: | 54 private: |
52 const AccountId main_profile_id_; | 55 const AccountId main_profile_id_; |
53 message_center::MessageCenter* const message_center_; | 56 message_center::MessageCenter* const message_center_; |
54 | 57 |
55 using ItemMap = | 58 using ItemMap = |
56 std::unordered_map<std::string, std::unique_ptr<ArcNotificationItem>>; | 59 std::unordered_map<std::string, std::unique_ptr<ArcNotificationItem>>; |
57 ItemMap items_; | 60 ItemMap items_; |
58 | 61 |
59 bool ready_ = false; | 62 bool ready_ = false; |
60 | 63 |
61 mojo::Binding<arc::mojom::NotificationsHost> binding_; | 64 mojo::Binding<arc::mojom::NotificationsHost> binding_; |
62 | 65 |
63 DISALLOW_COPY_AND_ASSIGN(ArcNotificationManager); | 66 DISALLOW_COPY_AND_ASSIGN(ArcNotificationManager); |
64 }; | 67 }; |
65 | 68 |
66 } // namespace arc | 69 } // namespace arc |
67 | 70 |
68 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_MANAGER_H_ | 71 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_MANAGER_H_ |
OLD | NEW |