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"
16 class CastSelectDefaultView
;
17 class CastDetailedView
;
21 class TrayCast
: public SystemTrayItem
, public ShellObserver
{
23 explicit TrayCast(SystemTray
* system_tray
);
27 // Overridden from SystemTrayItem.
28 views::View
* CreateTrayView(user::LoginStatus status
) override
;
29 views::View
* CreateDefaultView(user::LoginStatus status
) override
;
30 views::View
* CreateDetailedView(user::LoginStatus status
) override
;
31 void DestroyTrayView() override
;
32 void DestroyDefaultView() override
;
33 void DestroyDetailedView() override
;
34 void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment
) override
;
36 // Overridden from ShellObserver.
37 void OnCastingSessionStartedOrStopped(bool started
) override
;
39 // Returns true if the cast extension was detected.
40 bool HasCastExtension();
42 // Callback used to enable/disable the begin casting view depending on
43 // if we have any cast receivers.
44 void UpdateCachedReceiverState(
45 const CastConfigDelegate::ReceiversAndActivites
& receivers_activities
);
47 // This makes sure that the current view displayed in the tray is the correct
48 // one, depending on if we are currently casting. If we're casting, then a
49 // view with a stop button is displayed; otherwise, a view that links to a
50 // detail view is displayed instead that allows the user to easily begin a
52 void UpdatePrimaryView();
55 tray::CastTrayView
* tray_
= nullptr;
56 tray::CastDuplexView
* default_
= nullptr;
57 tray::CastDetailedView
* detailed_
= nullptr;
58 CastConfigDelegate
* cast_config_delegate_
;
60 bool has_cast_receivers_
= false;
61 bool is_casting_
= false;
62 base::WeakPtrFactory
<TrayCast
> weak_ptr_factory_
;
64 DISALLOW_COPY_AND_ASSIGN(TrayCast
);
69 #endif // ASH_SYSTEM_CAST_TRAY_CAST_H_