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