Chromium Code Reviews| 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_CAST_CONFIG_DELEGATE_H_ | 5 #ifndef ASH_CAST_CONFIG_DELEGATE_H_ |
| 6 #define ASH_CAST_CONFIG_DELEGATE_H_ | 6 #define ASH_CAST_CONFIG_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/callback_list.h" | |
| 14 #include "base/macros.h" | 13 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 17 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 18 | 17 |
| 19 namespace ash { | 18 namespace ash { |
| 20 | 19 |
| 21 // This delegate allows the UI code in ash, e.g. |TrayCastDetailedView|, | 20 // This delegate allows the UI code in ash, e.g. |TrayCastDetailedView|, |
| 22 // to access the cast extension. | 21 // to access the cast extension. |
| 23 class CastConfigDelegate { | 22 class CastConfigDelegate { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 }; | 63 }; |
| 65 | 64 |
| 66 struct ASH_EXPORT ReceiverAndActivity { | 65 struct ASH_EXPORT ReceiverAndActivity { |
| 67 ReceiverAndActivity(); | 66 ReceiverAndActivity(); |
| 68 ~ReceiverAndActivity(); | 67 ~ReceiverAndActivity(); |
| 69 | 68 |
| 70 Receiver receiver; | 69 Receiver receiver; |
| 71 Activity activity; | 70 Activity activity; |
| 72 }; | 71 }; |
| 73 | 72 |
| 74 // The key is the receiver id. | |
| 75 using ReceiversAndActivities = std::vector<ReceiverAndActivity>; | 73 using ReceiversAndActivities = std::vector<ReceiverAndActivity>; |
| 76 using ReceiversAndActivitesCallback = | 74 |
| 77 base::Callback<void(const ReceiversAndActivities&)>; | 75 class Observer { |
| 78 using DeviceUpdateSubscription = scoped_ptr< | 76 public: |
| 79 base::CallbackList<void(const ReceiversAndActivities&)>::Subscription>; | 77 // Invoked whenever there is new receiver or activity information available. |
| 78 virtual void OnDevicesUpdated(const ReceiversAndActivities& devices); | |
| 79 }; | |
| 80 | 80 |
|
stevenjb
2016/01/12 23:31:49
Typically an observer class with only one or two m
jdufault
2016/01/12 23:59:22
Done.
| |
| 81 virtual ~CastConfigDelegate() {} | 81 virtual ~CastConfigDelegate() {} |
| 82 | 82 |
| 83 // Returns true if cast extension is installed. | 83 // Returns true if cast extension is installed. |
| 84 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is | 84 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is |
| 85 // gone. See crbug.com/551132. | 85 // gone. See crbug.com/551132. |
| 86 virtual bool HasCastExtension() const = 0; | 86 virtual bool HasCastExtension() const = 0; |
| 87 | 87 |
| 88 // Adds a listener that will get invoked whenever the receivers or their | 88 // Add or remove an observer. |
| 89 // associated activites have changed. | 89 virtual void AddObserver(Observer* observer) = 0; |
| 90 virtual DeviceUpdateSubscription RegisterDeviceUpdateObserver( | 90 virtual void RemoveObserver(Observer* observer) = 0; |
| 91 const ReceiversAndActivitesCallback& callback) = 0; | |
| 92 | 91 |
| 93 // Request fresh data from the backend. When the data is available, all | 92 // Request fresh data from the backend. When the data is available, all |
| 94 // registered observers will get called. | 93 // registered observers will get called. |
| 95 virtual void RequestDeviceRefresh() = 0; | 94 virtual void RequestDeviceRefresh() = 0; |
| 96 | 95 |
| 97 // Cast to a receiver specified by |receiver_id|. | 96 // Cast to a receiver specified by |receiver_id|. |
| 98 virtual void CastToReceiver(const std::string& receiver_id) = 0; | 97 virtual void CastToReceiver(const std::string& receiver_id) = 0; |
| 99 | 98 |
| 100 // Stop an ongoing cast (this should be a user initiated stop). |activity_id| | 99 // Stop an ongoing cast (this should be a user initiated stop). |activity_id| |
| 101 // is the identifier of the activity/route that should be stopped. | 100 // is the identifier of the activity/route that should be stopped. |
| 102 virtual void StopCasting(const std::string& activity_id) = 0; | 101 virtual void StopCasting(const std::string& activity_id) = 0; |
| 103 | 102 |
| 104 // Does the device have a settings page? | 103 // Does the device have a settings page? |
| 105 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is | 104 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is |
| 106 // gone. See crbug.com/551132. | 105 // gone. See crbug.com/551132. |
| 107 virtual bool HasOptions() const = 0; | 106 virtual bool HasOptions() const = 0; |
| 108 | 107 |
| 109 // Opens Options page for cast. | 108 // Opens Options page for cast. |
| 110 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is | 109 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is |
| 111 // gone. See crbug.com/551132. | 110 // gone. See crbug.com/551132. |
| 112 virtual void LaunchCastOptions() = 0; | 111 virtual void LaunchCastOptions() = 0; |
| 113 | 112 |
| 114 private: | 113 private: |
| 115 DISALLOW_ASSIGN(CastConfigDelegate); | 114 DISALLOW_ASSIGN(CastConfigDelegate); |
| 116 }; | 115 }; |
| 117 | 116 |
| 118 } // namespace ash | 117 } // namespace ash |
| 119 | 118 |
| 120 #endif // ASH_CAST_CONFIG_DELEGATE_H_ | 119 #endif // ASH_CAST_CONFIG_DELEGATE_H_ |
| OLD | NEW |