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

Side by Side Diff: ash/system/cast/tray_cast.h

Issue 1567103005: Replace base::CallbackList with base::ObserverList in CastConfigDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Replace with ObserverList instead of base::Callback Created 4 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 ASH_SYSTEM_CAST_TRAY_CAST_H_ 5 #ifndef ASH_SYSTEM_CAST_TRAY_CAST_H_
6 #define ASH_SYSTEM_CAST_TRAY_CAST_H_ 6 #define ASH_SYSTEM_CAST_TRAY_CAST_H_
7 7
8 #include "ash/cast_config_delegate.h" 8 #include "ash/cast_config_delegate.h"
9 #include "ash/shell_observer.h" 9 #include "ash/shell_observer.h"
10 #include "ash/system/tray/system_tray_item.h" 10 #include "ash/system/tray/system_tray_item.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13 12
14 namespace ash { 13 namespace ash {
15 namespace tray { 14 namespace tray {
16 class CastTrayView; 15 class CastTrayView;
17 class CastSelectDefaultView; 16 class CastSelectDefaultView;
18 class CastDetailedView; 17 class CastDetailedView;
19 class CastDuplexView; 18 class CastDuplexView;
20 } // namespace tray 19 } // namespace tray
21 20
22 class ASH_EXPORT TrayCast : public SystemTrayItem, public ShellObserver { 21 class ASH_EXPORT TrayCast : public SystemTrayItem,
22 public ShellObserver,
23 public CastConfigDelegate::Observer {
23 public: 24 public:
24 explicit TrayCast(SystemTray* system_tray); 25 explicit TrayCast(SystemTray* system_tray);
25 ~TrayCast() override; 26 ~TrayCast() override;
26 27
27 private: 28 private:
28 // Helper/utility methods for testing. 29 // Helper/utility methods for testing.
29 friend class TrayCastTestAPI; 30 friend class TrayCastTestAPI;
30 void StartCastForTest(const std::string& receiver_id); 31 void StartCastForTest(const std::string& receiver_id);
31 void StopCastForTest(); 32 void StopCastForTest();
32 // Returns the id of the item we are currently displaying in the cast view. 33 // Returns the id of the item we are currently displaying in the cast view.
(...skipping 10 matching lines...) Expand all
43 void DestroyDefaultView() override; 44 void DestroyDefaultView() override;
44 void DestroyDetailedView() override; 45 void DestroyDetailedView() override;
45 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override; 46 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override;
46 47
47 // Overridden from ShellObserver. 48 // Overridden from ShellObserver.
48 void OnCastingSessionStartedOrStopped(bool started) override; 49 void OnCastingSessionStartedOrStopped(bool started) override;
49 50
50 // Returns true if the cast extension was detected. 51 // Returns true if the cast extension was detected.
51 bool HasCastExtension(); 52 bool HasCastExtension();
52 53
53 // Callback used to enable/disable the begin casting view depending on 54 // Overridden from CastConfigDelegate::Observer.
54 // if we have any cast receivers. 55 void OnDevicesUpdated(
55 void OnReceiversUpdated( 56 const CastConfigDelegate::ReceiversAndActivities& devices) override;
56 const CastConfigDelegate::ReceiversAndActivities& receivers_activities);
57 57
58 // This makes sure that the current view displayed in the tray is the correct 58 // This makes sure that the current view displayed in the tray is the correct
59 // one, depending on if we are currently casting. If we're casting, then a 59 // one, depending on if we are currently casting. If we're casting, then a
60 // view with a stop button is displayed; otherwise, a view that links to a 60 // view with a stop button is displayed; otherwise, a view that links to a
61 // detail view is displayed instead that allows the user to easily begin a 61 // detail view is displayed instead that allows the user to easily begin a
62 // casting session. 62 // casting session.
63 void UpdatePrimaryView(); 63 void UpdatePrimaryView();
64 64
65 CastConfigDelegate::ReceiversAndActivities receivers_and_activities_; 65 CastConfigDelegate::ReceiversAndActivities receivers_and_activities_;
66 CastConfigDelegate::DeviceUpdateSubscription device_update_subscription_;
67 bool is_casting_ = false; 66 bool is_casting_ = false;
68 67
68 bool added_observer_ = false;
69
69 // Not owned. 70 // Not owned.
70 tray::CastTrayView* tray_ = nullptr; 71 tray::CastTrayView* tray_ = nullptr;
71 tray::CastDuplexView* default_ = nullptr; 72 tray::CastDuplexView* default_ = nullptr;
72 tray::CastDetailedView* detailed_ = nullptr; 73 tray::CastDetailedView* detailed_ = nullptr;
73 74
74 base::WeakPtrFactory<TrayCast> weak_ptr_factory_;
75
76 DISALLOW_COPY_AND_ASSIGN(TrayCast); 75 DISALLOW_COPY_AND_ASSIGN(TrayCast);
77 }; 76 };
78 77
79 } // namespace ash 78 } // namespace ash
80 79
81 #endif // ASH_SYSTEM_CAST_TRAY_CAST_H_ 80 #endif // ASH_SYSTEM_CAST_TRAY_CAST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698