OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_H_ |
| 6 #define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/threading/thread_checker.h" |
| 13 #include "components/signin/core/account_id/account_id.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 #include "ui/arc/notification/arc_notification_manager.h" |
| 16 #include "ui/message_center/message_center.h" |
| 17 |
| 18 namespace arc { |
| 19 |
| 20 // The class represents each ARC notification. One instance of this class |
| 21 // corresponds to one ARC notification. |
| 22 class ArcNotificationItem { |
| 23 public: |
| 24 ArcNotificationItem(ArcNotificationManager* manager, |
| 25 message_center::MessageCenter* message_center, |
| 26 const std::string& notification_key, |
| 27 const AccountId& profile_id); |
| 28 ~ArcNotificationItem(); |
| 29 |
| 30 void UpdateWithArcNotificationData(const ArcNotificationData& data); |
| 31 |
| 32 // Methods called from ArcNotificationManager: |
| 33 void OnClosedFromAndroid(); |
| 34 |
| 35 // Methods called from ArcNotificationItemDelegate: |
| 36 void Close(bool by_user); |
| 37 void Click(); |
| 38 |
| 39 private: |
| 40 void OnImageDecoded(const SkBitmap& bitmap); |
| 41 |
| 42 ArcNotificationManager* const manager_; |
| 43 message_center::MessageCenter* const message_center_; |
| 44 const AccountId profile_id_; |
| 45 |
| 46 const std::string notification_key_; |
| 47 const std::string notification_id_; |
| 48 |
| 49 // Stores on-going notification data during the image decoding. |
| 50 // This field will be removed after removing async task of image decoding. |
| 51 scoped_ptr<message_center::Notification> notification_; |
| 52 |
| 53 // The flag to indicate that the removing is initiated by the manager and we |
| 54 // don't need to notify a remove event to the manager. |
| 55 // This is true only when: |
| 56 // (1) the notification is being removed |
| 57 // (2) the removing is initiated by manager |
| 58 bool being_removed_by_manager_ = false; |
| 59 |
| 60 // Stores the latest notification data which is newer than the on-going data. |
| 61 // If the on-going data is either none or the latest, this is null. |
| 62 // This field will be removed after removing async task of image decoding. |
| 63 ArcNotificationDataPtr newer_data_; |
| 64 |
| 65 base::ThreadChecker thread_checker_; |
| 66 base::WeakPtrFactory<ArcNotificationItem> weak_ptr_factory_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(ArcNotificationItem); |
| 69 }; |
| 70 |
| 71 } // namespace arc |
| 72 |
| 73 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_H_ |
OLD | NEW |