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_CAST_CONFIG_DELEGATE_H_
6 #define ASH_CAST_CONFIG_DELEGATE_H_
11 #include "ash/ash_export.h"
12 #include "base/callback.h"
13 #include "base/callback_list.h"
14 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/strings/string16.h"
21 // This delegate allows the UI code in ash, e.g. |TrayCastDetailedView|,
22 // to access the cast extension.
23 class CastConfigDelegate
{
25 struct ASH_EXPORT Receiver
{
33 struct ASH_EXPORT Activity
{
34 // The tab identifier that we are casting. These are the special tab values
35 // taken from the chromecast extension itself. If an actual tab is being
36 // casted, then the TabId will be >= 0.
40 DISCOVERED_ACTIVITY
= -3,
41 EXTERNAL_EXTENSION_CLIENT
= -4,
43 // Not in the extension. Used when the extension does not give us a tabId
44 // (ie, the cast is running from another device).
54 // The id for the tab we are casting. Could be one of the TabId values,
55 // or a value >= 0 that represents that tab index of the tab we are
56 // casting. We default to casting the desktop, as a tab may not
58 int tab_id
= TabId::DESKTOP
;
61 struct ASH_EXPORT ReceiverAndActivity
{
62 ReceiverAndActivity();
63 ~ReceiverAndActivity();
69 // The key is the receiver id.
70 using ReceiversAndActivites
= std::vector
<ReceiverAndActivity
>;
71 using ReceiversAndActivitesCallback
=
72 base::Callback
<void(const ReceiversAndActivites
&)>;
73 using DeviceUpdateSubscription
= scoped_ptr
<
74 base::CallbackList
<void(const ReceiversAndActivites
&)>::Subscription
>;
76 virtual ~CastConfigDelegate() {}
78 // Returns true if cast extension is installed.
79 virtual bool HasCastExtension() const = 0;
81 // Adds a listener that will get invoked whenever the receivers or their
82 // associated activites have changed.
83 virtual DeviceUpdateSubscription
RegisterDeviceUpdateObserver(
84 const ReceiversAndActivitesCallback
& callback
) = 0;
86 // Request fresh data from the backend. When the data is available, all
87 // registered observers will get called.
88 virtual void RequestDeviceRefresh() = 0;
90 // Cast to a receiver specified by |receiver_id|.
91 virtual void CastToReceiver(const std::string
& receiver_id
) = 0;
93 // Stop an ongoing cast (this should be a user initiated stop).
94 virtual void StopCasting() = 0;
96 // Opens Options page for cast.
97 virtual void LaunchCastOptions() = 0;
100 DISALLOW_ASSIGN(CastConfigDelegate
);
105 #endif // ASH_CAST_CONFIG_DELEGATE_H_