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" |
|
achuithb
2016/01/13 09:21:25
Do you need this?
jdufault
2016/01/13 19:43:26
Done.
| |
| 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 ASH_EXPORT Observer { |
| 78 using DeviceUpdateSubscription = scoped_ptr< | 76 public: |
| 79 base::CallbackList<void(const ReceiversAndActivities&)>::Subscription>; | 77 virtual ~Observer() {} |
|
achuithb
2016/01/13 09:21:25
I think this can be protected?
jdufault
2016/01/13 19:43:26
Needs to be public so the extension API can call O
stevenjb
2016/01/13 20:02:18
OnDevicesUpdated should be public, but the destruc
achuithb
2016/01/13 21:08:33
Yup, sorry I wasn't clear.
| |
| 78 | |
| 79 // Invoked whenever there is new receiver or activity information available. | |
| 80 virtual void OnDevicesUpdated(const ReceiversAndActivities& devices) = 0; | |
| 81 }; | |
|
achuithb
2016/01/13 09:21:25
DISALLOW_COPY_AND_ASSIGN perhaps?
jdufault
2016/01/13 19:43:26
Doing so also requires defining a default construc
stevenjb
2016/01/13 20:02:18
It shouldn't. This is the preferred pattern:
clas
achuithb
2016/01/13 21:08:33
+1. Thanks for clarifying, Steven
jdufault
2016/01/13 22:02:23
Done.
| |
| 80 | 82 |
| 81 virtual ~CastConfigDelegate() {} | 83 virtual ~CastConfigDelegate() {} |
| 82 | 84 |
| 83 // Returns true if cast extension is installed. | 85 // Returns true if cast extension is installed. |
| 84 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is | 86 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is |
| 85 // gone. See crbug.com/551132. | 87 // gone. See crbug.com/551132. |
| 86 virtual bool HasCastExtension() const = 0; | 88 virtual bool HasCastExtension() const = 0; |
| 87 | 89 |
| 88 // Adds a listener that will get invoked whenever the receivers or their | 90 // Add or remove an observer. |
|
achuithb
2016/01/13 09:21:25
I feel like these administrative functions should
jdufault
2016/01/13 19:43:26
Done.
| |
| 89 // associated activites have changed. | 91 virtual void AddObserver(Observer* observer) = 0; |
| 90 virtual DeviceUpdateSubscription RegisterDeviceUpdateObserver( | 92 virtual void RemoveObserver(Observer* observer) = 0; |
| 91 const ReceiversAndActivitesCallback& callback) = 0; | |
| 92 | 93 |
| 93 // Request fresh data from the backend. When the data is available, all | 94 // Request fresh data from the backend. When the data is available, all |
| 94 // registered observers will get called. | 95 // registered observers will get called. |
| 95 virtual void RequestDeviceRefresh() = 0; | 96 virtual void RequestDeviceRefresh() = 0; |
| 96 | 97 |
| 97 // Cast to a receiver specified by |receiver_id|. | 98 // Cast to a receiver specified by |receiver_id|. |
| 98 virtual void CastToReceiver(const std::string& receiver_id) = 0; | 99 virtual void CastToReceiver(const std::string& receiver_id) = 0; |
| 99 | 100 |
| 100 // Stop an ongoing cast (this should be a user initiated stop). |activity_id| | 101 // 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. | 102 // is the identifier of the activity/route that should be stopped. |
| 102 virtual void StopCasting(const std::string& activity_id) = 0; | 103 virtual void StopCasting(const std::string& activity_id) = 0; |
| 103 | 104 |
| 104 // Does the device have a settings page? | 105 // Does the device have a settings page? |
| 105 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is | 106 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is |
| 106 // gone. See crbug.com/551132. | 107 // gone. See crbug.com/551132. |
| 107 virtual bool HasOptions() const = 0; | 108 virtual bool HasOptions() const = 0; |
| 108 | 109 |
| 109 // Opens Options page for cast. | 110 // Opens Options page for cast. |
| 110 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is | 111 // TODO(jdufault): Remove this function once the CastConfigDelegateChromeos is |
| 111 // gone. See crbug.com/551132. | 112 // gone. See crbug.com/551132. |
| 112 virtual void LaunchCastOptions() = 0; | 113 virtual void LaunchCastOptions() = 0; |
| 113 | 114 |
| 114 private: | 115 private: |
| 115 DISALLOW_ASSIGN(CastConfigDelegate); | 116 DISALLOW_ASSIGN(CastConfigDelegate); |
| 116 }; | 117 }; |
| 117 | 118 |
| 118 } // namespace ash | 119 } // namespace ash |
| 119 | 120 |
| 120 #endif // ASH_CAST_CONFIG_DELEGATE_H_ | 121 #endif // ASH_CAST_CONFIG_DELEGATE_H_ |
| OLD | NEW |