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 #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/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/media/router/media_router.h" | 9 #include "chrome/browser/media/router/media_router.h" |
| 10 #include "chrome/browser/media/router/media_router_factory.h" | 10 #include "chrome/browser/media/router/media_router_factory.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 // This class caches the values that the observers give us so we can query them | 41 // This class caches the values that the observers give us so we can query them |
| 42 // at any point in time. It also emits a device refresh event when new data is | 42 // at any point in time. It also emits a device refresh event when new data is |
| 43 // available. | 43 // available. |
| 44 class CastDeviceCache : public media_router::MediaRoutesObserver, | 44 class CastDeviceCache : public media_router::MediaRoutesObserver, |
| 45 public media_router::MediaSinksObserver { | 45 public media_router::MediaSinksObserver { |
| 46 public: | 46 public: |
| 47 using MediaSinks = std::vector<media_router::MediaSink>; | 47 using MediaSinks = std::vector<media_router::MediaSink>; |
| 48 using MediaRoutes = std::vector<media_router::MediaRoute>; | 48 using MediaRoutes = std::vector<media_router::MediaRoute>; |
| 49 using MediaRouteIds = std::vector<media_router::MediaRoute::Id>; | |
| 49 | 50 |
| 50 explicit CastDeviceCache(ash::CastConfigDelegate* cast_config_delegate); | 51 explicit CastDeviceCache(ash::CastConfigDelegate* cast_config_delegate); |
| 51 ~CastDeviceCache() override; | 52 ~CastDeviceCache() override; |
| 52 | 53 |
| 53 const MediaSinks& sinks() const { return sinks_; } | 54 const MediaSinks& sinks() const { return sinks_; } |
| 54 const MediaRoutes& routes() const { return routes_; } | 55 const MediaRoutes& routes() const { return routes_; } |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 // media_router::MediaSinksObserver: | 58 // media_router::MediaSinksObserver: |
| 58 void OnSinksReceived(const MediaSinks& sinks) override; | 59 void OnSinksReceived(const MediaSinks& sinks) override; |
| 59 | 60 |
| 60 // media_router::MediaRoutesObserver: | 61 // media_router::MediaRoutesObserver: |
| 61 void OnRoutesUpdated(const MediaRoutes& routes) override; | 62 void OnRoutesUpdated(const MediaRoutes& routes, |
| 63 const MediaRouteIds& joinable_route_ids) override; | |
| 62 | 64 |
| 63 MediaSinks sinks_; | 65 MediaSinks sinks_; |
| 64 MediaRoutes routes_; | 66 MediaRoutes routes_; |
| 65 | 67 |
| 66 // Not owned. | 68 // Not owned. |
| 67 ash::CastConfigDelegate* cast_config_delegate_; | 69 ash::CastConfigDelegate* cast_config_delegate_; |
| 68 | 70 |
| 69 DISALLOW_COPY_AND_ASSIGN(CastDeviceCache); | 71 DISALLOW_COPY_AND_ASSIGN(CastDeviceCache); |
| 70 }; | 72 }; |
| 71 | 73 |
| 72 CastDeviceCache::CastDeviceCache(ash::CastConfigDelegate* cast_config_delegate) | 74 CastDeviceCache::CastDeviceCache(ash::CastConfigDelegate* cast_config_delegate) |
| 73 : MediaRoutesObserver(GetMediaRouter()), | 75 : MediaRoutesObserver(GetMediaRouter()), |
| 74 MediaSinksObserver(GetMediaRouter(), | 76 MediaSinksObserver(GetMediaRouter(), |
| 75 media_router::MediaSourceForDesktop()), | 77 media_router::MediaSourceForDesktop()), |
| 76 cast_config_delegate_(cast_config_delegate) { | 78 cast_config_delegate_(cast_config_delegate) { |
| 77 CHECK(MediaSinksObserver::Init()); | 79 CHECK(MediaSinksObserver::Init()); |
| 78 } | 80 } |
| 79 | 81 |
| 80 CastDeviceCache::~CastDeviceCache() {} | 82 CastDeviceCache::~CastDeviceCache() {} |
| 81 | 83 |
| 82 void CastDeviceCache::OnSinksReceived(const MediaSinks& sinks) { | 84 void CastDeviceCache::OnSinksReceived(const MediaSinks& sinks) { |
| 83 sinks_ = sinks; | 85 sinks_ = sinks; |
| 84 cast_config_delegate_->RequestDeviceRefresh(); | 86 cast_config_delegate_->RequestDeviceRefresh(); |
| 85 } | 87 } |
| 86 | 88 |
| 87 void CastDeviceCache::OnRoutesUpdated(const MediaRoutes& routes) { | 89 void CastDeviceCache::OnRoutesUpdated(const MediaRoutes& routes, |
| 90 const MediaRouteIds& joinable_route_ids) { | |
|
stevenjb
2016/01/05 20:10:23
unused_joinable_route_ids
matt.boetger
2016/01/06 22:49:07
Done.
| |
| 88 routes_ = routes; | 91 routes_ = routes; |
| 89 cast_config_delegate_->RequestDeviceRefresh(); | 92 cast_config_delegate_->RequestDeviceRefresh(); |
| 90 } | 93 } |
| 91 | 94 |
| 92 //////////////////////////////////////////////////////////////////////////////// | 95 //////////////////////////////////////////////////////////////////////////////// |
| 93 // CastConfigDelegateMediaRouter: | 96 // CastConfigDelegateMediaRouter: |
| 94 | 97 |
| 95 // static | 98 // static |
| 96 bool CastConfigDelegateMediaRouter::IsEnabled() { | 99 bool CastConfigDelegateMediaRouter::IsEnabled() { |
| 97 return media_router::MediaRouterEnabled( | 100 return media_router::MediaRouterEnabled( |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 void CastConfigDelegateMediaRouter::StopCasting(const std::string& route_id) { | 194 void CastConfigDelegateMediaRouter::StopCasting(const std::string& route_id) { |
| 192 GetMediaRouter()->CloseRoute(route_id); | 195 GetMediaRouter()->CloseRoute(route_id); |
| 193 } | 196 } |
| 194 | 197 |
| 195 bool CastConfigDelegateMediaRouter::HasOptions() const { | 198 bool CastConfigDelegateMediaRouter::HasOptions() const { |
| 196 // There are no plans to have an options page for the MediaRouter. | 199 // There are no plans to have an options page for the MediaRouter. |
| 197 return false; | 200 return false; |
| 198 } | 201 } |
| 199 | 202 |
| 200 void CastConfigDelegateMediaRouter::LaunchCastOptions() {} | 203 void CastConfigDelegateMediaRouter::LaunchCastOptions() {} |
| OLD | NEW |