| 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_client_media_router.h" | 5 #include "chrome/browser/ui/ash/cast_config_client_media_router.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 ash::mojom::CastConfigClient* cast_config_client_; | 88 ash::mojom::CastConfigClient* cast_config_client_; |
| 89 | 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(CastDeviceCache); | 90 DISALLOW_COPY_AND_ASSIGN(CastDeviceCache); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 CastDeviceCache::CastDeviceCache( | 93 CastDeviceCache::CastDeviceCache( |
| 94 ash::mojom::CastConfigClient* cast_config_client) | 94 ash::mojom::CastConfigClient* cast_config_client) |
| 95 : MediaRoutesObserver(GetMediaRouter()), | 95 : MediaRoutesObserver(GetMediaRouter()), |
| 96 MediaSinksObserver(GetMediaRouter(), | 96 MediaSinksObserver(GetMediaRouter(), |
| 97 media_router::MediaSourceForDesktop(), | 97 media_router::MediaSourceForDesktop(), |
| 98 GURL(chrome::kChromeUIMediaRouterURL)), | 98 url::Origin(GURL(chrome::kChromeUIMediaRouterURL))), |
| 99 cast_config_client_(cast_config_client) {} | 99 cast_config_client_(cast_config_client) {} |
| 100 | 100 |
| 101 CastDeviceCache::~CastDeviceCache() {} | 101 CastDeviceCache::~CastDeviceCache() {} |
| 102 | 102 |
| 103 void CastDeviceCache::Init() { | 103 void CastDeviceCache::Init() { |
| 104 CHECK(MediaSinksObserver::Init()); | 104 CHECK(MediaSinksObserver::Init()); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void CastDeviceCache::OnSinksReceived(const MediaSinks& sinks) { | 107 void CastDeviceCache::OnSinksReceived(const MediaSinks& sinks) { |
| 108 sinks_.clear(); | 108 sinks_.clear(); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 | 221 |
| 222 cast_config_->OnDevicesUpdated(std::move(items)); | 222 cast_config_->OnDevicesUpdated(std::move(items)); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void CastConfigClientMediaRouter::CastToSink(ash::mojom::CastSinkPtr sink) { | 225 void CastConfigClientMediaRouter::CastToSink(ash::mojom::CastSinkPtr sink) { |
| 226 // TODO(imcheng): Pass in tab casting timeout. | 226 // TODO(imcheng): Pass in tab casting timeout. |
| 227 GetMediaRouter()->CreateRoute( | 227 GetMediaRouter()->CreateRoute( |
| 228 media_router::MediaSourceForDesktop().id(), sink->id, | 228 media_router::MediaSourceForDesktop().id(), sink->id, |
| 229 GURL("http://cros-cast-origin/"), nullptr, | 229 url::Origin(GURL("http://cros-cast-origin/")), nullptr, |
| 230 std::vector<media_router::MediaRouteResponseCallback>(), | 230 std::vector<media_router::MediaRouteResponseCallback>(), |
| 231 base::TimeDelta(), false); | 231 base::TimeDelta(), false); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void CastConfigClientMediaRouter::StopCasting(ash::mojom::CastRoutePtr route) { | 234 void CastConfigClientMediaRouter::StopCasting(ash::mojom::CastRoutePtr route) { |
| 235 GetMediaRouter()->TerminateRoute(route->id); | 235 GetMediaRouter()->TerminateRoute(route->id); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void CastConfigClientMediaRouter::Observe( | 238 void CastConfigClientMediaRouter::Observe( |
| 239 int type, | 239 int type, |
| 240 const content::NotificationSource& source, | 240 const content::NotificationSource& source, |
| 241 const content::NotificationDetails& details) { | 241 const content::NotificationDetails& details) { |
| 242 switch (type) { | 242 switch (type) { |
| 243 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: | 243 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: |
| 244 // The active profile has changed, which means that the media router has | 244 // The active profile has changed, which means that the media router has |
| 245 // as well. Reset the device cache to ensure we are using up-to-date | 245 // as well. Reset the device cache to ensure we are using up-to-date |
| 246 // object instances. | 246 // object instances. |
| 247 devices_.reset(); | 247 devices_.reset(); |
| 248 RequestDeviceRefresh(); | 248 RequestDeviceRefresh(); |
| 249 break; | 249 break; |
| 250 } | 250 } |
| 251 } | 251 } |
| OLD | NEW |