OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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_IMPL_H_ |
| 6 #define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_IMPL_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" |
| 14 #include "base/threading/thread_checker.h" |
| 15 #include "components/signin/core/account_id/account_id.h" |
| 16 #include "third_party/skia/include/core/SkBitmap.h" |
| 17 #include "ui/arc/notification/arc_notification_item.h" |
| 18 #include "ui/arc/notification/arc_notification_manager.h" |
| 19 #include "ui/message_center/message_center.h" |
| 20 |
| 21 namespace arc { |
| 22 |
| 23 // The class represents each ARC notification. One instance of this class |
| 24 // corresponds to one ARC notification. |
| 25 class ArcNotificationItemImpl : public ArcNotificationItem { |
| 26 public: |
| 27 ArcNotificationItemImpl(ArcNotificationManager* manager, |
| 28 message_center::MessageCenter* message_center, |
| 29 const std::string& notification_key, |
| 30 const AccountId& profile_id); |
| 31 ~ArcNotificationItemImpl() override; |
| 32 |
| 33 // ArcNotificationItem overrides: |
| 34 void OnClosedFromAndroid() override; |
| 35 void OnUpdatedFromAndroid(mojom::ArcNotificationDataPtr data) override; |
| 36 void Close(bool by_user) override; |
| 37 void Click() override; |
| 38 void OpenSettings() override; |
| 39 bool IsOpeningSettingsSupported() const override; |
| 40 void ToggleExpansion() override; |
| 41 void AddObserver(Observer* observer) override; |
| 42 void RemoveObserver(Observer* observer) override; |
| 43 void IncrementWindowRefCount() override; |
| 44 void DecrementWindowRefCount() override; |
| 45 bool GetPinned() const override; |
| 46 const gfx::ImageSkia& GetSnapshot() const override; |
| 47 mojom::ArcNotificationExpandState GetExpandState() const override; |
| 48 mojom::ArcNotificationShownContents GetShownContents() const override; |
| 49 const std::string& GetNotificationKey() const override; |
| 50 |
| 51 private: |
| 52 // Return true if it's on the thread this instance is created on. |
| 53 bool CalledOnValidThread() const; |
| 54 |
| 55 ArcNotificationManager* const manager_; |
| 56 message_center::MessageCenter* const message_center_; |
| 57 |
| 58 // The pinned state of the latest notification. |
| 59 bool pinned_ = false; |
| 60 // The snapshot of the latest notification. |
| 61 gfx::ImageSkia snapshot_; |
| 62 // The expand state of the latest notification. |
| 63 mojom::ArcNotificationExpandState expand_state_ = |
| 64 mojom::ArcNotificationExpandState::FIXED_SIZE; |
| 65 // The type of shown content of the latest notification. |
| 66 mojom::ArcNotificationShownContents shown_contents_ = |
| 67 mojom::ArcNotificationShownContents::CONTENTS_SHOWN; |
| 68 // The reference counter of the window. |
| 69 int window_ref_count_ = 0; |
| 70 |
| 71 base::ObserverList<Observer> observers_; |
| 72 |
| 73 const AccountId profile_id_; |
| 74 const std::string notification_key_; |
| 75 const std::string notification_id_; |
| 76 |
| 77 // The flag to indicate that the removing is initiated by the manager and we |
| 78 // don't need to notify a remove event to the manager. |
| 79 // This is true only when: |
| 80 // (1) the notification is being removed |
| 81 // (2) the removing is initiated by manager |
| 82 bool being_removed_by_manager_ = false; |
| 83 |
| 84 base::ThreadChecker thread_checker_; |
| 85 base::WeakPtrFactory<ArcNotificationItemImpl> weak_ptr_factory_; |
| 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(ArcNotificationItemImpl); |
| 88 }; |
| 89 |
| 90 } // namespace arc |
| 91 |
| 92 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_IMPL_H_ |
OLD | NEW |