Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Side by Side Diff: chrome/browser/ui/ash/cast_config_delegate_media_router.cc

Issue 1567103005: Replace base::CallbackList with base::ObserverList in CastConfigDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Add TODO for proper fix Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/ash/cast_config_delegate_media_router.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
140 CastConfigDelegateMediaRouter::RegisterDeviceUpdateObserver(
141 const ReceiversAndActivitesCallback& callback) {
142 return callback_list_.Add(callback);
143 }
144
145 void CastConfigDelegateMediaRouter::RequestDeviceRefresh() { 139 void CastConfigDelegateMediaRouter::RequestDeviceRefresh() {
146 // The media router component isn't ready yet. 140 // The media router component isn't ready yet.
147 if (!devices()) 141 if (!devices())
148 return; 142 return;
149 143
150 // Build the old-style ReceiverAndActivity set out of the MediaRouter 144 // Build the old-style ReceiverAndActivity set out of the MediaRouter
151 // source/sink/route setup. We first map the existing sinks, and then we 145 // source/sink/route setup. We first map the existing sinks, and then we
152 // update those sinks with activity information. 146 // update those sinks with activity information.
153 147
154 ReceiversAndActivities items; 148 ReceiversAndActivities items;
(...skipping 30 matching lines...) Expand all
185 item.activity.tab_id = 0; 179 item.activity.tab_id = 0;
186 if (media_router::IsDesktopMirroringMediaSource(route.media_source())) 180 if (media_router::IsDesktopMirroringMediaSource(route.media_source()))
187 item.activity.tab_id = Activity::TabId::DESKTOP; 181 item.activity.tab_id = Activity::TabId::DESKTOP;
188 } 182 }
189 183
190 break; 184 break;
191 } 185 }
192 } 186 }
193 } 187 }
194 188
195 callback_list_.Notify(items); 189 FOR_EACH_OBSERVER(ash::CastConfigDelegate::Observer, observer_list_,
190 OnDevicesUpdated(items));
196 } 191 }
197 192
198 void CastConfigDelegateMediaRouter::CastToReceiver( 193 void CastConfigDelegateMediaRouter::CastToReceiver(
199 const std::string& receiver_id) { 194 const std::string& receiver_id) {
200 GetMediaRouter()->CreateRoute( 195 GetMediaRouter()->CreateRoute(
201 media_router::MediaSourceForDesktop().id(), receiver_id, 196 media_router::MediaSourceForDesktop().id(), receiver_id,
202 GURL("http://cros-cast-origin/"), nullptr, 197 GURL("http://cros-cast-origin/"), nullptr,
203 std::vector<media_router::MediaRouteResponseCallback>()); 198 std::vector<media_router::MediaRouteResponseCallback>());
204 } 199 }
205 200
206 void CastConfigDelegateMediaRouter::StopCasting(const std::string& route_id) { 201 void CastConfigDelegateMediaRouter::StopCasting(const std::string& route_id) {
207 GetMediaRouter()->TerminateRoute(route_id); 202 GetMediaRouter()->TerminateRoute(route_id);
208 } 203 }
209 204
210 bool CastConfigDelegateMediaRouter::HasOptions() const { 205 bool CastConfigDelegateMediaRouter::HasOptions() const {
211 // There are no plans to have an options page for the MediaRouter. 206 // There are no plans to have an options page for the MediaRouter.
212 return false; 207 return false;
213 } 208 }
214 209
215 void CastConfigDelegateMediaRouter::LaunchCastOptions() {} 210 void CastConfigDelegateMediaRouter::LaunchCastOptions() {}
211
212 void CastConfigDelegateMediaRouter::AddObserver(
213 ash::CastConfigDelegate::Observer* observer) {
214 observer_list_.AddObserver(observer);
215 }
216
217 void CastConfigDelegateMediaRouter::RemoveObserver(
218 ash::CastConfigDelegate::Observer* observer) {
219 observer_list_.RemoveObserver(observer);
220 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/cast_config_delegate_media_router.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698