forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtray_cast.h
81 lines (65 loc) · 2.77 KB
/
tray_cast.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_CAST_TRAY_CAST_H_
#define ASH_SYSTEM_CAST_TRAY_CAST_H_
#include "ash/cast_config_delegate.h"
#include "ash/shell_observer.h"
#include "ash/system/tray/system_tray_item.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
namespace ash {
namespace tray {
class CastTrayView;
class CastSelectDefaultView;
class CastDetailedView;
class CastDuplexView;
} // namespace tray
class ASH_EXPORT TrayCast : public SystemTrayItem, public ShellObserver {
public:
explicit TrayCast(SystemTray* system_tray);
~TrayCast() override;
private:
// Helper/utility methods for testing.
friend class TrayCastTestAPI;
void StartCastForTest(const std::string& receiver_id);
void StopCastForTest();
// Returns the id of the item we are currently displaying in the cast view.
// This assumes that the cast view is active.
const std::string& GetDisplayedCastId();
const views::View* GetDefaultView() const;
enum ChildViewId { TRAY_VIEW = 1, SELECT_VIEW, CAST_VIEW };
// Overridden from SystemTrayItem.
views::View* CreateTrayView(user::LoginStatus status) override;
views::View* CreateDefaultView(user::LoginStatus status) override;
views::View* CreateDetailedView(user::LoginStatus status) override;
void DestroyTrayView() override;
void DestroyDefaultView() override;
void DestroyDetailedView() override;
void UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) override;
// Overridden from ShellObserver.
void OnCastingSessionStartedOrStopped(bool started) override;
// Returns true if the cast extension was detected.
bool HasCastExtension();
// Callback used to enable/disable the begin casting view depending on
// if we have any cast receivers.
void OnReceiversUpdated(
const CastConfigDelegate::ReceiversAndActivities& receivers_activities);
// This makes sure that the current view displayed in the tray is the correct
// one, depending on if we are currently casting. If we're casting, then a
// view with a stop button is displayed; otherwise, a view that links to a
// detail view is displayed instead that allows the user to easily begin a
// casting session.
void UpdatePrimaryView();
CastConfigDelegate::ReceiversAndActivities receivers_and_activities_;
CastConfigDelegate::DeviceUpdateSubscription device_update_subscription_;
bool is_casting_ = false;
// Not owned.
tray::CastTrayView* tray_ = nullptr;
tray::CastDuplexView* default_ = nullptr;
tray::CastDetailedView* detailed_ = nullptr;
base::WeakPtrFactory<TrayCast> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(TrayCast);
};
} // namespace ash
#endif // ASH_SYSTEM_CAST_TRAY_CAST_H_