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 #include "chrome/browser/ui/ash/cast_config_delegate_media_router.h" | 5 #include "chrome/browser/ui/ash/cast_config_delegate_media_router.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/media/router/media_router.h" | 10 #include "chrome/browser/media/router/media_router.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 devices_->Init(); | 129 devices_->Init(); |
130 } | 130 } |
131 | 131 |
132 return devices_.get(); | 132 return devices_.get(); |
133 } | 133 } |
134 | 134 |
135 bool CastConfigDelegateMediaRouter::HasCastExtension() const { | 135 bool CastConfigDelegateMediaRouter::HasCastExtension() const { |
136 return true; | 136 return true; |
137 } | 137 } |
138 | 138 |
139 CastConfigDelegateMediaRouter::DeviceUpdateSubscription | |
140 CastConfigDelegateMediaRouter::RegisterDeviceUpdateObserver( | |
141 const ReceiversAndActivitesCallback& callback) { | |
142 return callback_list_.Add(callback); | |
143 } | |
144 | |
145 void CastConfigDelegateMediaRouter::RequestDeviceRefresh() { | 139 void CastConfigDelegateMediaRouter::RequestDeviceRefresh() { |
146 // The media router component isn't ready yet. | 140 // The media router component isn't ready yet. |
147 if (!devices()) | 141 if (!devices()) |
148 return; | 142 return; |
149 | 143 |
150 // Build the old-style ReceiverAndActivity set out of the MediaRouter | 144 // Build the old-style ReceiverAndActivity set out of the MediaRouter |
151 // source/sink/route setup. We first map the existing sinks, and then we | 145 // source/sink/route setup. We first map the existing sinks, and then we |
152 // update those sinks with activity information. | 146 // update those sinks with activity information. |
153 | 147 |
154 ReceiversAndActivities items; | 148 ReceiversAndActivities items; |
(...skipping 30 matching lines...) Expand all Loading... |
185 item.activity.tab_id = 0; | 179 item.activity.tab_id = 0; |
186 if (media_router::IsDesktopMirroringMediaSource(route.media_source())) | 180 if (media_router::IsDesktopMirroringMediaSource(route.media_source())) |
187 item.activity.tab_id = Activity::TabId::DESKTOP; | 181 item.activity.tab_id = Activity::TabId::DESKTOP; |
188 } | 182 } |
189 | 183 |
190 break; | 184 break; |
191 } | 185 } |
192 } | 186 } |
193 } | 187 } |
194 | 188 |
195 callback_list_.Notify(items); | 189 FOR_EACH_OBSERVER(ash::CastConfigDelegate::Observer, observer_list_, |
| 190 OnDevicesUpdated(items)); |
196 } | 191 } |
197 | 192 |
198 void CastConfigDelegateMediaRouter::CastToReceiver( | 193 void CastConfigDelegateMediaRouter::CastToReceiver( |
199 const std::string& receiver_id) { | 194 const std::string& receiver_id) { |
200 GetMediaRouter()->CreateRoute( | 195 GetMediaRouter()->CreateRoute( |
201 media_router::MediaSourceForDesktop().id(), receiver_id, | 196 media_router::MediaSourceForDesktop().id(), receiver_id, |
202 GURL("http://cros-cast-origin/"), nullptr, | 197 GURL("http://cros-cast-origin/"), nullptr, |
203 std::vector<media_router::MediaRouteResponseCallback>()); | 198 std::vector<media_router::MediaRouteResponseCallback>()); |
204 } | 199 } |
205 | 200 |
206 void CastConfigDelegateMediaRouter::StopCasting(const std::string& route_id) { | 201 void CastConfigDelegateMediaRouter::StopCasting(const std::string& route_id) { |
207 GetMediaRouter()->TerminateRoute(route_id); | 202 GetMediaRouter()->TerminateRoute(route_id); |
208 } | 203 } |
209 | 204 |
210 bool CastConfigDelegateMediaRouter::HasOptions() const { | 205 bool CastConfigDelegateMediaRouter::HasOptions() const { |
211 // There are no plans to have an options page for the MediaRouter. | 206 // There are no plans to have an options page for the MediaRouter. |
212 return false; | 207 return false; |
213 } | 208 } |
214 | 209 |
215 void CastConfigDelegateMediaRouter::LaunchCastOptions() {} | 210 void CastConfigDelegateMediaRouter::LaunchCastOptions() {} |
| 211 |
| 212 void CastConfigDelegateMediaRouter::AddObserver( |
| 213 ash::CastConfigDelegate::Observer* observer) { |
| 214 observer_list_.AddObserver(observer); |
| 215 } |
| 216 |
| 217 void CastConfigDelegateMediaRouter::RemoveObserver( |
| 218 ash::CastConfigDelegate::Observer* observer) { |
| 219 observer_list_.RemoveObserver(observer); |
| 220 } |
OLD | NEW |