Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ash / system / cast / tray_cast.h
blob96bb903d84a913c118aae071c0c8be8518411721
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
3 // found in the LICENSE file.
5 #ifndef ASH_SYSTEM_CAST_TRAY_CAST_H_
6 #define ASH_SYSTEM_CAST_TRAY_CAST_H_
8 #include "ash/cast_config_delegate.h"
9 #include "ash/shell_observer.h"
10 #include "ash/system/tray/system_tray_item.h"
11 #include "base/memory/weak_ptr.h"
13 namespace ash {
14 namespace tray {
15 class CastTrayView;
16 class CastSelectDefaultView;
17 class CastDetailedView;
18 class CastDuplexView;
19 } // namespace tray
21 class ASH_EXPORT TrayCast : public SystemTrayItem, public ShellObserver {
22 public:
23 explicit TrayCast(SystemTray* system_tray);
24 ~TrayCast() override;
26 private:
27 // Helper/utility methods for testing.
28 friend class TrayCastTestAPI;
29 void StartCastForTest(const std::string& receiver_id);
30 void StopCastForTest();
31 const views::View* GetDefaultView() const;
32 enum ChildViewId { TRAY_VIEW = 1, SELECT_VIEW, CAST_VIEW };
34 // Overridden from SystemTrayItem.
35 views::View* CreateTrayView(user::LoginStatus status) override;
36 views::View* CreateDefaultView(user::LoginStatus status) override;
37 views::View* CreateDetailedView(user::LoginStatus status) override;
38 void DestroyTrayView() override;
39 void DestroyDefaultView() override;
40 void DestroyDetailedView() override;
41 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override;
43 // Overridden from ShellObserver.
44 void OnCastingSessionStartedOrStopped(bool started) override;
46 // Returns true if the cast extension was detected.
47 bool HasCastExtension();
49 // Callback used to enable/disable the begin casting view depending on
50 // if we have any cast receivers.
51 void OnReceiversUpdated(
52 const CastConfigDelegate::ReceiversAndActivites& receivers_activities);
54 // This makes sure that the current view displayed in the tray is the correct
55 // one, depending on if we are currently casting. If we're casting, then a
56 // view with a stop button is displayed; otherwise, a view that links to a
57 // detail view is displayed instead that allows the user to easily begin a
58 // casting session.
59 void UpdatePrimaryView();
61 CastConfigDelegate::ReceiversAndActivites receivers_and_activities_;
62 CastConfigDelegate::DeviceUpdateSubscription device_update_subscription_;
63 bool is_casting_ = false;
65 // Not owned.
66 tray::CastTrayView* tray_ = nullptr;
67 tray::CastDuplexView* default_ = nullptr;
68 tray::CastDetailedView* detailed_ = nullptr;
70 base::WeakPtrFactory<TrayCast> weak_ptr_factory_;
72 DISALLOW_COPY_AND_ASSIGN(TrayCast);
75 } // namespace ash
77 #endif // ASH_SYSTEM_CAST_TRAY_CAST_H_