blob: f38a05c5f3f6322ad00a77f7b24d61a6916f6fbb (
plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
// 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_CAST_CONFIG_DELEGATE_H_
#define ASH_CAST_CONFIG_DELEGATE_H_
#include <map>
#include <string>
#include "ash/ash_export.h"
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "url/gurl.h"
namespace ash {
// This delegate allows the UI code in ash, e.g. |TrayCastDetailedView|,
// to access the cast extension.
class CastConfigDelegate {
public:
struct ASH_EXPORT Receiver {
Receiver();
~Receiver();
std::string id;
base::string16 name;
};
struct ASH_EXPORT Activity {
// The tab identifier that we are casting. These are the special tab values
// taken from the chromecast extension itself. If an actual tab is being
// casted, then the TabId will be >= 0.
enum TabId {
EXTENSION = -1,
DESKTOP = -2,
DISCOVERED_ACTIVITY = -3,
EXTERNAL_EXTENSION_CLIENT = -4
};
Activity();
~Activity();
std::string id;
base::string16 title;
std::string activity_type;
bool allow_stop = false;
// The id for the tab we are casting. Could be one of the TabId values,
// or a value >= 0 that represents that tab index of the tab we are
// casting. We default to casting the desktop, as a tab may not
// necessarily exist.
int tab_id = TabId::DESKTOP;
};
struct ASH_EXPORT ReceiverAndActivity {
ReceiverAndActivity();
~ReceiverAndActivity();
Receiver receiver;
Activity activity;
};
// The key is the receiver id.
using ReceiversAndActivites = std::map<std::string, ReceiverAndActivity>;
using ReceiversAndActivitesCallback =
base::Callback<void(const ReceiversAndActivites&)>;
virtual ~CastConfigDelegate() {}
// Returns true if cast extension is installed.
virtual bool HasCastExtension() const = 0;
// Fetches the current set of receivers and their possible activities. This
// method will lookup the current chromecast extension and query its current
// state. The |callback| will be invoked when the receiver/activity data is
// available.
virtual void GetReceiversAndActivities(
const ReceiversAndActivitesCallback& callback) = 0;
// Cast to a receiver specified by |receiver_id|.
virtual void CastToReceiver(const std::string& receiver_id) = 0;
// Stop an ongoing cast.
virtual void StopCasting() = 0;
// Opens Options page for cast.
virtual void LaunchCastOptions() = 0;
private:
DISALLOW_ASSIGN(CastConfigDelegate);
};
} // namespace ash
#endif // ASH_CAST_CONFIG_DELEGATE_H_
|