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

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

Issue 2319893002: Merge "arc: Defer notification surface creation" (Closed)
Patch Set: Created 4 years, 3 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 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_CUSTOM_NOTIFICATION_ITEM_H_ 5 #ifndef UI_ARC_NOTIFICATION_ARC_CUSTOM_NOTIFICATION_ITEM_H_
6 #define UI_ARC_NOTIFICATION_ARC_CUSTOM_NOTIFICATION_ITEM_H_ 6 #define UI_ARC_NOTIFICATION_ARC_CUSTOM_NOTIFICATION_ITEM_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/observer_list.h" 9 #include "base/observer_list.h"
10 #include "ui/arc/notification/arc_notification_item.h" 10 #include "ui/arc/notification/arc_notification_item.h"
11 #include "ui/arc/notification/arc_notification_surface_manager.h" 11 #include "ui/gfx/image/image_skia.h"
12 12
13 namespace arc { 13 namespace arc {
14 14
15 class ArcCustomNotificationItem 15 class ArcCustomNotificationItem : public ArcNotificationItem {
16 : public ArcNotificationItem,
17 public ArcNotificationSurfaceManager::Observer {
18 public: 16 public:
19 class Observer { 17 class Observer {
20 public: 18 public:
21 // Invoked when the notification data for this item has changed. 19 // Invoked when the notification data for this item has changed.
22 virtual void OnItemDestroying() = 0; 20 virtual void OnItemDestroying() = 0;
23 21
24 // Invoked when the pinned stated is changed. 22 // Invoked when the notification data for the item is updated.
25 virtual void OnItemPinnedChanged() = 0; 23 virtual void OnItemUpdated() = 0;
26
27 // Invoked when the notification surface for this item is gone.
28 virtual void OnItemNotificationSurfaceRemoved() = 0;
29 24
30 protected: 25 protected:
31 virtual ~Observer() = default; 26 virtual ~Observer() = default;
32 }; 27 };
33 28
34 ArcCustomNotificationItem(ArcNotificationManager* manager, 29 ArcCustomNotificationItem(ArcNotificationManager* manager,
35 message_center::MessageCenter* message_center, 30 message_center::MessageCenter* message_center,
36 const std::string& notification_key, 31 const std::string& notification_key,
37 const AccountId& profile_id); 32 const AccountId& profile_id);
38 ~ArcCustomNotificationItem() override; 33 ~ArcCustomNotificationItem() override;
39 34
40 void UpdateWithArcNotificationData( 35 void UpdateWithArcNotificationData(
41 const mojom::ArcNotificationData& data) override; 36 const mojom::ArcNotificationData& data) override;
42 37
43 void CloseFromCloseButton(); 38 void CloseFromCloseButton();
44 39
45 void AddObserver(Observer* observer); 40 void AddObserver(Observer* observer);
46 void RemoveObserver(Observer* observer); 41 void RemoveObserver(Observer* observer);
47 42
43 // Increment |window_ref_count_| and a CreateNotificationWindow request
44 // is sent when |window_ref_count_| goes from zero to one.
45 void IncrementWindowRefCount();
46
47 // Decrement |window_ref_count_| and a CloseNotificationWindow request
48 // is sent when |window_ref_count_| goes from one to zero.
49 void DecrementWindowRefCount();
50
48 bool pinned() const { return pinned_; } 51 bool pinned() const { return pinned_; }
52 const gfx::ImageSkia& snapshot() const { return snapshot_; }
49 53
50 private: 54 private:
51 // ArcNotificationSurfaceManager::Observer: 55 bool pinned_ = false;
52 void OnNotificationSurfaceAdded(exo::NotificationSurface* surface) override; 56 gfx::ImageSkia snapshot_;
53 void OnNotificationSurfaceRemoved(exo::NotificationSurface* surface) override; 57 int window_ref_count_ = 0;
54 58
55 bool pinned_ = false;
56 base::ObserverList<Observer> observers_; 59 base::ObserverList<Observer> observers_;
57 60
58 DISALLOW_COPY_AND_ASSIGN(ArcCustomNotificationItem); 61 DISALLOW_COPY_AND_ASSIGN(ArcCustomNotificationItem);
59 }; 62 };
60 63
61 } // namespace arc 64 } // namespace arc
62 65
63 #endif // UI_ARC_NOTIFICATION_ARC_CUSTOM_NOTIFICATION_ITEM_H_ 66 #endif // UI_ARC_NOTIFICATION_ARC_CUSTOM_NOTIFICATION_ITEM_H_
OLDNEW
« no previous file with comments | « components/arc/test/fake_notifications_instance.cc ('k') | ui/arc/notification/arc_custom_notification_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698