| 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 |
| 11 #include "ash/public/interfaces/constants.mojom.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 13 #include "base/optional.h" | 14 #include "base/optional.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/media/router/media_router.h" | 18 #include "chrome/browser/media/router/media_router.h" |
| 18 #include "chrome/browser/media/router/media_router_factory.h" | 19 #include "chrome/browser/media/router/media_router_factory.h" |
| 19 #include "chrome/browser/media/router/media_router_feature.h" | 20 #include "chrome/browser/media/router/media_router_feature.h" |
| 20 #include "chrome/browser/media/router/media_routes_observer.h" | 21 #include "chrome/browser/media/router/media_routes_observer.h" |
| 21 #include "chrome/browser/media/router/media_sinks_observer.h" | 22 #include "chrome/browser/media/router/media_sinks_observer.h" |
| 22 #include "chrome/browser/media/router/media_source_helper.h" | 23 #include "chrome/browser/media/router/media_source_helper.h" |
| 23 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
| 24 #include "chrome/browser/ui/ash/ash_util.h" | |
| 25 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
| 26 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 27 #include "content/public/browser/notification_source.h" | 27 #include "content/public/browser/notification_source.h" |
| 28 #include "content/public/common/service_manager_connection.h" | 28 #include "content/public/common/service_manager_connection.h" |
| 29 #include "services/service_manager/public/cpp/connector.h" | 29 #include "services/service_manager/public/cpp/connector.h" |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 media_router::MediaRouter* media_router_for_test_ = nullptr; | 33 media_router::MediaRouter* media_router_for_test_ = nullptr; |
| 34 | 34 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 CastConfigClientMediaRouter::CastConfigClientMediaRouter() : binding_(this) { | 144 CastConfigClientMediaRouter::CastConfigClientMediaRouter() : binding_(this) { |
| 145 // TODO(jdufault): This should use a callback interface once there is an | 145 // TODO(jdufault): This should use a callback interface once there is an |
| 146 // equivalent. See crbug.com/666005. | 146 // equivalent. See crbug.com/666005. |
| 147 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 147 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 148 content::NotificationService::AllSources()); | 148 content::NotificationService::AllSources()); |
| 149 | 149 |
| 150 // When starting up, we need to connect to ash and set ourselves as the | 150 // When starting up, we need to connect to ash and set ourselves as the |
| 151 // client. | 151 // client. |
| 152 content::ServiceManagerConnection::GetForProcess() | 152 content::ServiceManagerConnection::GetForProcess() |
| 153 ->GetConnector() | 153 ->GetConnector() |
| 154 ->BindInterface(ash_util::GetAshServiceName(), &cast_config_); | 154 ->BindInterface(ash::mojom::kServiceName, &cast_config_); |
| 155 | 155 |
| 156 // Register this object as the client interface implementation. | 156 // Register this object as the client interface implementation. |
| 157 ash::mojom::CastConfigClientAssociatedPtrInfo ptr_info; | 157 ash::mojom::CastConfigClientAssociatedPtrInfo ptr_info; |
| 158 binding_.Bind(&ptr_info); | 158 binding_.Bind(&ptr_info); |
| 159 cast_config_->SetClient(std::move(ptr_info)); | 159 cast_config_->SetClient(std::move(ptr_info)); |
| 160 } | 160 } |
| 161 | 161 |
| 162 CastConfigClientMediaRouter::~CastConfigClientMediaRouter() {} | 162 CastConfigClientMediaRouter::~CastConfigClientMediaRouter() {} |
| 163 | 163 |
| 164 CastDeviceCache* CastConfigClientMediaRouter::devices() { | 164 CastDeviceCache* CastConfigClientMediaRouter::devices() { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 switch (type) { | 243 switch (type) { |
| 244 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: | 244 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: |
| 245 // The active profile has changed, which means that the media router has | 245 // The active profile has changed, which means that the media router has |
| 246 // as well. Reset the device cache to ensure we are using up-to-date | 246 // as well. Reset the device cache to ensure we are using up-to-date |
| 247 // object instances. | 247 // object instances. |
| 248 devices_.reset(); | 248 devices_.reset(); |
| 249 RequestDeviceRefresh(); | 249 RequestDeviceRefresh(); |
| 250 break; | 250 break; |
| 251 } | 251 } |
| 252 } | 252 } |
| OLD | NEW |