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_ITEM_H_ | 5 #ifndef UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_H_ |
6 #define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_H_ | 6 #define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
13 #include "components/signin/core/account_id/account_id.h" | 13 #include "components/signin/core/account_id/account_id.h" |
14 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
15 #include "ui/arc/notification/arc_notification_manager.h" | 15 #include "ui/arc/notification/arc_notification_manager.h" |
16 #include "ui/arc/notification/arc_notification_surface_collection.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 // The class represents each ARC notification. One instance of this class | 21 // The class represents each ARC notification. One instance of this class |
21 // corresponds to one ARC notification. | 22 // corresponds to one ARC notification. |
22 class ArcNotificationItem { | 23 class ArcNotificationItem : public ArcNotificationSurfaceCollection::Observer { |
yoshiki
2016/06/15 11:47:20
Most of ArcNotificationItem code is not shared wit
xiyuan
2016/06/15 19:32:44
Done.
| |
23 public: | 24 public: |
24 ArcNotificationItem(ArcNotificationManager* manager, | 25 ArcNotificationItem(ArcNotificationManager* manager, |
25 message_center::MessageCenter* message_center, | 26 message_center::MessageCenter* message_center, |
26 const std::string& notification_key, | 27 const std::string& notification_key, |
27 const AccountId& profile_id); | 28 const AccountId& profile_id); |
28 ~ArcNotificationItem(); | 29 ~ArcNotificationItem() override; |
29 | 30 |
30 void UpdateWithArcNotificationData(const mojom::ArcNotificationData& data); | 31 void UpdateWithArcNotificationData(const mojom::ArcNotificationData& data); |
31 | 32 |
32 // Methods called from ArcNotificationManager: | 33 // Methods called from ArcNotificationManager: |
33 void OnClosedFromAndroid(bool by_user); | 34 void OnClosedFromAndroid(bool by_user); |
34 | 35 |
35 // Methods called from ArcNotificationItemDelegate: | 36 // Methods called from ArcNotificationItemDelegate: |
36 void Close(bool by_user); | 37 void Close(bool by_user); |
37 void Click(); | 38 void Click(); |
38 void ButtonClick(int button_index); | 39 void ButtonClick(int button_index); |
39 | 40 |
40 private: | 41 private: |
42 // ArcNotificationSurfaceCollection::Observer | |
43 void OnNotificationSurfaceAdded(exo::NotificationSurface* surface) override; | |
44 | |
41 void OnImageDecoded(const SkBitmap& bitmap); | 45 void OnImageDecoded(const SkBitmap& bitmap); |
42 | 46 |
47 // Add |notification_| to message center and update again if there is | |
48 // |newer_data_|. | |
49 void AddToMessageCenter(); | |
50 | |
43 ArcNotificationManager* const manager_; | 51 ArcNotificationManager* const manager_; |
44 message_center::MessageCenter* const message_center_; | 52 message_center::MessageCenter* const message_center_; |
45 const AccountId profile_id_; | 53 const AccountId profile_id_; |
46 | 54 |
47 const std::string notification_key_; | 55 const std::string notification_key_; |
48 const std::string notification_id_; | 56 const std::string notification_id_; |
49 | 57 |
50 // Stores on-going notification data during the image decoding. | 58 // Stores on-going notification data during the image decoding. |
51 // This field will be removed after removing async task of image decoding. | 59 // This field will be removed after removing async task of image decoding. |
52 std::unique_ptr<message_center::Notification> notification_; | 60 std::unique_ptr<message_center::Notification> notification_; |
(...skipping 12 matching lines...) Expand all Loading... | |
65 | 73 |
66 base::ThreadChecker thread_checker_; | 74 base::ThreadChecker thread_checker_; |
67 base::WeakPtrFactory<ArcNotificationItem> weak_ptr_factory_; | 75 base::WeakPtrFactory<ArcNotificationItem> weak_ptr_factory_; |
68 | 76 |
69 DISALLOW_COPY_AND_ASSIGN(ArcNotificationItem); | 77 DISALLOW_COPY_AND_ASSIGN(ArcNotificationItem); |
70 }; | 78 }; |
71 | 79 |
72 } // namespace arc | 80 } // namespace arc |
73 | 81 |
74 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_H_ | 82 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_H_ |
OLD | NEW |