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

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

Issue 2666873006: [Media Router] Convert to use typemaps for media_router.mojom. (Closed)
Patch Set: Remove DCHECK since tests are hitting the code path Created 3 years, 10 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
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_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 "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/optional.h"
13 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/media/router/media_router.h" 17 #include "chrome/browser/media/router/media_router.h"
17 #include "chrome/browser/media/router/media_router_factory.h" 18 #include "chrome/browser/media/router/media_router_factory.h"
18 #include "chrome/browser/media/router/media_router_feature.h" 19 #include "chrome/browser/media/router/media_router_feature.h"
19 #include "chrome/browser/media/router/media_routes_observer.h" 20 #include "chrome/browser/media/router/media_routes_observer.h"
20 #include "chrome/browser/media/router/media_sinks_observer.h" 21 #include "chrome/browser/media/router/media_sinks_observer.h"
21 #include "chrome/browser/media/router/media_source_helper.h" 22 #include "chrome/browser/media/router/media_source_helper.h"
22 #include "chrome/browser/profiles/profile_manager.h" 23 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 for (const media_router::MediaSink& sink : sinks) { 110 for (const media_router::MediaSink& sink : sinks) {
110 // The media router adds a MediaSink instance that doesn't have a name. Make 111 // The media router adds a MediaSink instance that doesn't have a name. Make
111 // sure to filter that sink out from the UI so it is not rendered, as it 112 // sure to filter that sink out from the UI so it is not rendered, as it
112 // will be a line that only has a icon with no apparent meaning. 113 // will be a line that only has a icon with no apparent meaning.
113 if (sink.name().empty()) 114 if (sink.name().empty())
114 continue; 115 continue;
115 116
116 // Hide all sinks which have a domain (ie, castouts) to meet privacy 117 // Hide all sinks which have a domain (ie, castouts) to meet privacy
117 // requirements. This will be enabled once UI can display the domain. See 118 // requirements. This will be enabled once UI can display the domain. See
118 // crbug.com/624016. 119 // crbug.com/624016.
119 if (!sink.domain().empty()) 120 if (sink.domain() && !sink.domain()->empty())
120 continue; 121 continue;
121 122
122 sinks_.push_back(sink); 123 sinks_.push_back(sink);
123 } 124 }
124 125
125 cast_config_client_->RequestDeviceRefresh(); 126 cast_config_client_->RequestDeviceRefresh();
126 } 127 }
127 128
128 void CastDeviceCache::OnRoutesUpdated( 129 void CastDeviceCache::OnRoutesUpdated(
129 const MediaRoutes& routes, 130 const MediaRoutes& routes,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // update those sinks with activity information. 188 // update those sinks with activity information.
188 189
189 std::vector<ash::mojom::SinkAndRoutePtr> items; 190 std::vector<ash::mojom::SinkAndRoutePtr> items;
190 191
191 for (const media_router::MediaSink& sink : devices()->sinks()) { 192 for (const media_router::MediaSink& sink : devices()->sinks()) {
192 ash::mojom::SinkAndRoutePtr sr = ash::mojom::SinkAndRoute::New(); 193 ash::mojom::SinkAndRoutePtr sr = ash::mojom::SinkAndRoute::New();
193 sr->route = ash::mojom::CastRoute::New(); 194 sr->route = ash::mojom::CastRoute::New();
194 sr->sink = ash::mojom::CastSink::New(); 195 sr->sink = ash::mojom::CastSink::New();
195 sr->sink->id = sink.id(); 196 sr->sink->id = sink.id();
196 sr->sink->name = sink.name(); 197 sr->sink->name = sink.name();
197 sr->sink->domain = sink.domain(); 198 sr->sink->domain = sink.domain().value_or(std::string());
198 items.push_back(std::move(sr)); 199 items.push_back(std::move(sr));
199 } 200 }
200 201
201 for (const media_router::MediaRoute& route : devices()->routes()) { 202 for (const media_router::MediaRoute& route : devices()->routes()) {
202 if (!route.for_display()) 203 if (!route.for_display())
203 continue; 204 continue;
204 205
205 for (ash::mojom::SinkAndRoutePtr& item : items) { 206 for (ash::mojom::SinkAndRoutePtr& item : items) {
206 if (item->sink->id == route.media_sink_id()) { 207 if (item->sink->id == route.media_sink_id()) {
207 item->route->id = route.media_route_id(); 208 item->route->id = route.media_route_id();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 switch (type) { 243 switch (type) {
243 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED: 244 case chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED:
244 // 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
245 // 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
246 // object instances. 247 // object instances.
247 devices_.reset(); 248 devices_.reset();
248 RequestDeviceRefresh(); 249 RequestDeviceRefresh();
249 break; 250 break;
250 } 251 }
251 } 252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698