| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_COMMON_CAST_CONFIG_DELEGATE_H_ | 5 #ifndef ASH_COMMON_CAST_CONFIG_DELEGATE_H_ |
| 6 #define ASH_COMMON_CAST_CONFIG_DELEGATE_H_ | 6 #define ASH_COMMON_CAST_CONFIG_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "ash/ash_export.h" | 12 #include "ash/ash_export.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 namespace ash { | 17 namespace ash { |
| 18 | 18 |
| 19 // This delegate allows the UI code in ash, e.g. |TrayCastDetailedView|, | 19 // This delegate allows the UI code in ash, e.g. |TrayCastDetailedView|, |
| 20 // to access the cast extension. | 20 // to access the cast extension. |
| 21 class CastConfigDelegate { | 21 class CastConfigDelegate { |
| 22 public: | 22 public: |
| 23 struct ASH_EXPORT Sink { | 23 struct ASH_EXPORT Sink { |
| 24 Sink(); | 24 Sink(); |
| 25 ~Sink(); | 25 ~Sink(); |
| 26 | 26 |
| 27 std::string id; | 27 std::string id; |
| 28 base::string16 name; | 28 base::string16 name; |
| 29 base::string16 domain; |
| 29 }; | 30 }; |
| 30 | 31 |
| 31 struct ASH_EXPORT Route { | 32 struct ASH_EXPORT Route { |
| 32 // The tab identifier that we are casting. These are the special tab values | 33 enum class ContentSource { UNKNOWN, TAB, DESKTOP }; |
| 33 // taken from the chromecast extension itself. If an actual tab is being | |
| 34 // casted, then the TabId will be >= 0. | |
| 35 enum TabId { | |
| 36 EXTENSION = -1, | |
| 37 DESKTOP = -2, | |
| 38 DISCOVERED_ACTIVITY = -3, | |
| 39 EXTERNAL_EXTENSION_CLIENT = -4, | |
| 40 | |
| 41 // Not in the extension. Used when the extension does not give us a tabId | |
| 42 // (ie, the cast is running from another device). | |
| 43 UNKNOWN = -5 | |
| 44 }; | |
| 45 | 34 |
| 46 Route(); | 35 Route(); |
| 47 ~Route(); | 36 ~Route(); |
| 48 | 37 |
| 49 std::string id; | 38 std::string id; |
| 50 base::string16 title; | 39 base::string16 title; |
| 51 | 40 |
| 52 // Is the route source this computer? ie, are we mirroring the display? | 41 // Is the activity originating from this computer? |
| 53 bool is_local_source = false; | 42 bool is_local_source = false; |
| 54 | 43 |
| 55 // The id for the tab we are casting. Could be one of the TabId values, | 44 // What is source of the content? For example, we could be DIAL casting a |
| 56 // or a value >= 0 that represents that tab index of the tab we are | 45 // tab or mirroring the entire desktop. |
| 57 // casting. We default to casting the desktop, as a tab may not | 46 ContentSource content_source = ContentSource::UNKNOWN; |
| 58 // necessarily exist. | |
| 59 // TODO(jdufault): Remove tab_id once the CastConfigDelegateChromeos is | |
| 60 // gone. See crbug.com/551132. | |
| 61 int tab_id = TabId::DESKTOP; | |
| 62 }; | 47 }; |
| 63 | 48 |
| 64 struct ASH_EXPORT SinkAndRoute { | 49 struct ASH_EXPORT SinkAndRoute { |
| 65 SinkAndRoute(); | 50 SinkAndRoute(); |
| 66 ~SinkAndRoute(); | 51 ~SinkAndRoute(); |
| 67 | 52 |
| 68 Sink sink; | 53 Sink sink; |
| 69 Route route; | 54 Route route; |
| 70 }; | 55 }; |
| 71 | 56 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 82 private: | 67 private: |
| 83 DISALLOW_ASSIGN(Observer); | 68 DISALLOW_ASSIGN(Observer); |
| 84 }; | 69 }; |
| 85 | 70 |
| 86 virtual ~CastConfigDelegate() {} | 71 virtual ~CastConfigDelegate() {} |
| 87 | 72 |
| 88 // Request fresh data from the backend. When the data is available, all | 73 // Request fresh data from the backend. When the data is available, all |
| 89 // registered observers will get called. | 74 // registered observers will get called. |
| 90 virtual void RequestDeviceRefresh() = 0; | 75 virtual void RequestDeviceRefresh() = 0; |
| 91 | 76 |
| 92 // Cast to a sink specified by |sink_id|. | 77 // Initiate a casting session to |sink|. |
| 93 virtual void CastToSink(const std::string& sink_id) = 0; | 78 virtual void CastToSink(const Sink& sink) = 0; |
| 94 | 79 |
| 95 // Stop an ongoing cast (this should be a user initiated stop). |route_id| | 80 // A user-initiated request to stop the given cast session. |
| 96 // is the identifier of the sink/route that should be stopped. | 81 virtual void StopCasting(const Route& route) = 0; |
| 97 virtual void StopCasting(const std::string& route_id) = 0; | |
| 98 | 82 |
| 99 // Add or remove an observer. | 83 // Add or remove an observer. |
| 100 virtual void AddObserver(Observer* observer) = 0; | 84 virtual void AddObserver(Observer* observer) = 0; |
| 101 virtual void RemoveObserver(Observer* observer) = 0; | 85 virtual void RemoveObserver(Observer* observer) = 0; |
| 102 | 86 |
| 103 private: | 87 private: |
| 104 DISALLOW_ASSIGN(CastConfigDelegate); | 88 DISALLOW_ASSIGN(CastConfigDelegate); |
| 105 }; | 89 }; |
| 106 | 90 |
| 107 } // namespace ash | 91 } // namespace ash |
| 108 | 92 |
| 109 #endif // ASH_COMMON_CAST_CONFIG_DELEGATE_H_ | 93 #endif // ASH_COMMON_CAST_CONFIG_DELEGATE_H_ |
| OLD | NEW |