Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(915)

Side by Side Diff: ui/arc/notification/arc_notification_item_impl.h

Issue 2723143002: Add unittests of ArcCustomNotificationView (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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_IMPL_H_
6 #define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_H_ 6 #define UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "components/signin/core/account_id/account_id.h" 14 #include "components/signin/core/account_id/account_id.h"
15 #include "third_party/skia/include/core/SkBitmap.h" 15 #include "third_party/skia/include/core/SkBitmap.h"
16 #include "ui/arc/notification/arc_notification_item.h"
16 #include "ui/arc/notification/arc_notification_manager.h" 17 #include "ui/arc/notification/arc_notification_manager.h"
17 #include "ui/message_center/message_center.h" 18 #include "ui/message_center/message_center.h"
18 19
19 namespace arc { 20 namespace arc {
20 21
21 // The class represents each ARC notification. One instance of this class 22 // The class represents each ARC notification. One instance of this class
22 // corresponds to one ARC notification. 23 // corresponds to one ARC notification.
23 class ArcNotificationItem { 24 class ArcNotificationItemImpl : public ArcNotificationItem {
24 public: 25 public:
25 ArcNotificationItem(ArcNotificationManager* manager, 26 ArcNotificationItemImpl(ArcNotificationManager* manager,
26 message_center::MessageCenter* message_center, 27 message_center::MessageCenter* message_center,
27 const std::string& notification_key, 28 const std::string& notification_key,
28 const AccountId& profile_id); 29 const AccountId& profile_id);
29 virtual ~ArcNotificationItem(); 30 ~ArcNotificationItemImpl() override;
30 31
31 virtual void UpdateWithArcNotificationData( 32 void UpdateWithArcNotificationData(
32 mojom::ArcNotificationDataPtr data); 33 mojom::ArcNotificationDataPtr data) override;
33 34
34 // Methods called from ArcNotificationManager: 35 void OnClosedFromAndroid() override;
35 void OnClosedFromAndroid(); 36 void Close(bool by_user) override;
37 void CloseFromCloseButton() override;
38 void OpenSettings() override;
36 39
37 // Methods called from ArcNotificationItemDelegate: 40 void AddObserver(Observer* observer) override;
38 void Close(bool by_user); 41 void RemoveObserver(Observer* observer) override;
39 void Click();
40 void ButtonClick(int button_index);
41 void OpenSettings();
42 42
43 const std::string& notification_key() const { return notification_key_; } 43 void IncrementWindowRefCount() override;
44 void DecrementWindowRefCount() override;
45
46 bool pinned() const override;
47 const gfx::ImageSkia& snapshot() const override;
48 const std::string& notification_key() const override;
44 49
45 protected: 50 protected:
46 static int ConvertAndroidPriority(int android_priority); 51 static int ConvertAndroidPriority(int android_priority);
47 52
48 // Checks whether there is on-going |notification_|. 53 // Checks whether there is on-going |notification_|.
49 bool HasPendingNotification(); 54 bool HasPendingNotification();
50 // Cache the |data| in |newer_data_|. 55 // Cache the |data| in |newer_data_|.
51 void CacheArcNotificationData(mojom::ArcNotificationDataPtr data); 56 void CacheArcNotificationData(mojom::ArcNotificationDataPtr data);
52 57
53 // Sets the pending |notification_|. 58 // Sets the pending |notification_|.
(...skipping 15 matching lines...) Expand all
69 return notification_.get(); 74 return notification_.get();
70 } 75 }
71 76
72 private: 77 private:
73 void OnImageDecoded(const SkBitmap& bitmap); 78 void OnImageDecoded(const SkBitmap& bitmap);
74 79
75 ArcNotificationManager* const manager_; 80 ArcNotificationManager* const manager_;
76 message_center::MessageCenter* const message_center_; 81 message_center::MessageCenter* const message_center_;
77 const AccountId profile_id_; 82 const AccountId profile_id_;
78 83
84 bool pinned_ = false;
85 gfx::ImageSkia snapshot_;
86 int window_ref_count_ = 0;
87
88 base::ObserverList<Observer> observers_;
89
79 const std::string notification_key_; 90 const std::string notification_key_;
80 const std::string notification_id_; 91 const std::string notification_id_;
81 92
82 // Stores on-going notification data during the image decoding. 93 // Stores on-going notification data during the image decoding.
83 // This field will be removed after removing async task of image decoding. 94 // This field will be removed after removing async task of image decoding.
84 std::unique_ptr<message_center::Notification> notification_; 95 std::unique_ptr<message_center::Notification> notification_;
85 96
86 // The flag to indicate that the removing is initiated by the manager and we 97 // The flag to indicate that the removing is initiated by the manager and we
87 // don't need to notify a remove event to the manager. 98 // don't need to notify a remove event to the manager.
88 // This is true only when: 99 // This is true only when:
89 // (1) the notification is being removed 100 // (1) the notification is being removed
90 // (2) the removing is initiated by manager 101 // (2) the removing is initiated by manager
91 bool being_removed_by_manager_ = false; 102 bool being_removed_by_manager_ = false;
92 103
93 // Stores the latest notification data which is newer than the on-going data. 104 // Stores the latest notification data which is newer than the on-going data.
94 // If the on-going data is either none or the latest, this is null. 105 // If the on-going data is either none or the latest, this is null.
95 // This field will be removed after removing async task of image decoding. 106 // This field will be removed after removing async task of image decoding.
96 mojom::ArcNotificationDataPtr newer_data_; 107 mojom::ArcNotificationDataPtr newer_data_;
97 108
98 base::ThreadChecker thread_checker_; 109 base::ThreadChecker thread_checker_;
99 base::WeakPtrFactory<ArcNotificationItem> weak_ptr_factory_; 110 base::WeakPtrFactory<ArcNotificationItemImpl> weak_ptr_factory_;
100 111
101 DISALLOW_COPY_AND_ASSIGN(ArcNotificationItem); 112 DISALLOW_COPY_AND_ASSIGN(ArcNotificationItemImpl);
102 }; 113 };
103 114
104 } // namespace arc 115 } // namespace arc
105 116
106 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_ITEM_H_ 117 #endif // UI_ARC_NOTIFICATION_ARC_NOTIFICATION_IMPL_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698