| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/media/router/media_router.h" | 13 #include "chrome/browser/media/router/media_router.h" |
| 14 #include "chrome/browser/media/router/media_router_factory.h" | 14 #include "chrome/browser/media/router/media_router_factory.h" |
| 15 #include "chrome/browser/media/router/media_router_feature.h" | 15 #include "chrome/browser/media/router/media_router_feature.h" |
| 16 #include "chrome/browser/media/router/media_routes_observer.h" | 16 #include "chrome/browser/media/router/media_routes_observer.h" |
| 17 #include "chrome/browser/media/router/media_sinks_observer.h" | 17 #include "chrome/browser/media/router/media_sinks_observer.h" |
| 18 #include "chrome/browser/media/router/media_source_helper.h" | 18 #include "chrome/browser/media/router/media_source_helper.h" |
| 19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/common/url_constants.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 media_router::MediaRouter* media_router_for_test_ = nullptr; | 24 media_router::MediaRouter* media_router_for_test_ = nullptr; |
| 24 | 25 |
| 25 media_router::MediaRouter* GetMediaRouter() { | 26 media_router::MediaRouter* GetMediaRouter() { |
| 26 if (media_router_for_test_) | 27 if (media_router_for_test_) |
| 27 return media_router_for_test_; | 28 return media_router_for_test_; |
| 28 | 29 |
| 29 auto* router = media_router::MediaRouterFactory::GetApiForBrowserContext( | 30 auto* router = media_router::MediaRouterFactory::GetApiForBrowserContext( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 77 |
| 77 // Not owned. | 78 // Not owned. |
| 78 ash::CastConfigDelegate* cast_config_delegate_; | 79 ash::CastConfigDelegate* cast_config_delegate_; |
| 79 | 80 |
| 80 DISALLOW_COPY_AND_ASSIGN(CastDeviceCache); | 81 DISALLOW_COPY_AND_ASSIGN(CastDeviceCache); |
| 81 }; | 82 }; |
| 82 | 83 |
| 83 CastDeviceCache::CastDeviceCache(ash::CastConfigDelegate* cast_config_delegate) | 84 CastDeviceCache::CastDeviceCache(ash::CastConfigDelegate* cast_config_delegate) |
| 84 : MediaRoutesObserver(GetMediaRouter()), | 85 : MediaRoutesObserver(GetMediaRouter()), |
| 85 MediaSinksObserver(GetMediaRouter(), | 86 MediaSinksObserver(GetMediaRouter(), |
| 86 media_router::MediaSourceForDesktop()), | 87 media_router::MediaSourceForDesktop(), |
| 87 cast_config_delegate_(cast_config_delegate) { | 88 GURL(chrome::kChromeUIMediaRouterURL)), |
| 88 } | 89 cast_config_delegate_(cast_config_delegate) {} |
| 89 | 90 |
| 90 CastDeviceCache::~CastDeviceCache() {} | 91 CastDeviceCache::~CastDeviceCache() {} |
| 91 | 92 |
| 92 void CastDeviceCache::Init() { | 93 void CastDeviceCache::Init() { |
| 93 CHECK(MediaSinksObserver::Init()); | 94 CHECK(MediaSinksObserver::Init()); |
| 94 } | 95 } |
| 95 | 96 |
| 96 void CastDeviceCache::OnSinksReceived(const MediaSinks& sinks) { | 97 void CastDeviceCache::OnSinksReceived(const MediaSinks& sinks) { |
| 97 sinks_ = sinks; | 98 sinks_ = sinks; |
| 98 cast_config_delegate_->RequestDeviceRefresh(); | 99 cast_config_delegate_->RequestDeviceRefresh(); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 217 |
| 217 void CastConfigDelegateMediaRouter::AddObserver( | 218 void CastConfigDelegateMediaRouter::AddObserver( |
| 218 ash::CastConfigDelegate::Observer* observer) { | 219 ash::CastConfigDelegate::Observer* observer) { |
| 219 observer_list_.AddObserver(observer); | 220 observer_list_.AddObserver(observer); |
| 220 } | 221 } |
| 221 | 222 |
| 222 void CastConfigDelegateMediaRouter::RemoveObserver( | 223 void CastConfigDelegateMediaRouter::RemoveObserver( |
| 223 ash::CastConfigDelegate::Observer* observer) { | 224 ash::CastConfigDelegate::Observer* observer) { |
| 224 observer_list_.RemoveObserver(observer); | 225 observer_list_.RemoveObserver(observer); |
| 225 } | 226 } |
| OLD | NEW |