Chromium Code Reviews| Index: chrome/browser/ui/webui/media_router/media_router_ui.cc | 
| diff --git a/chrome/browser/ui/webui/media_router/media_router_ui.cc b/chrome/browser/ui/webui/media_router/media_router_ui.cc | 
| index 3374fc27a4c5285c2972b246aa0fd5e50e5f571d..3a7e8badba8e7b7be4e1ae11b18ec68b46ebb652 100644 | 
| --- a/chrome/browser/ui/webui/media_router/media_router_ui.cc | 
| +++ b/chrome/browser/ui/webui/media_router/media_router_ui.cc | 
| @@ -88,6 +88,15 @@ base::TimeDelta GetRouteRequestTimeout(MediaCastMode cast_mode) { | 
| } | 
| } | 
| +// Returns the first source in |sources| that can be connected to by using the | 
| +// "Cast" button in the dialog, or an empty source if there is none. This is | 
| +// used by the Media Router to find such a matching route if it exists. | 
| +MediaSource GetSourceForRouteObserver(const std::vector<MediaSource>& sources) { | 
| + auto source_it = | 
| + std::find_if(sources.begin(), sources.end(), CanConnectToMediaSource); | 
| + return source_it != sources.end() ? *source_it : MediaSource(""); | 
| +} | 
| + | 
| } // namespace | 
| // static | 
| @@ -323,10 +332,15 @@ void MediaRouterUI::OnDefaultPresentationChanged( | 
| query_result_manager_->SetSourcesForCastMode( | 
| MediaCastMode::DEFAULT, sources, | 
| presentation_request_->frame_url().GetOrigin()); | 
| - // Register for MediaRoute updates. | 
| - // TODO(crbug.com/627655): Use multiple URLs. | 
| + // Register for MediaRoute updates. NOTE(mfoltz): If there are multiple | 
| + // sources that can be connected to via the dialog, this will break. We will | 
| + // need to observe multiple sources (keyed by sinks) in that case. As this is | 
| + // Cast-specific for the forseeable future, it may be simpler to plumb a new | 
| + // observer API for this case. | 
| 
 
imcheng
2016/12/05 21:58:39
+1, A specific API to query routes joinable with a
 
zhaobin
2016/12/06 20:06:37
Acknowledged.
 
 | 
| + const MediaSource source_for_route_observer = | 
| + GetSourceForRouteObserver(sources); | 
| routes_observer_.reset(new UIMediaRoutesObserver( | 
| - router_, sources[0].id(), | 
| + router_, source_for_route_observer.id(), | 
| base::Bind(&MediaRouterUI::OnRoutesUpdated, base::Unretained(this)))); | 
| UpdateCastModes(); |