| 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..5ea8ed9d732cd325113cd111bcb7ae0aea361d82 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,17 @@ 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(),
 | 
| +                                [](const auto& source) {
 | 
| +                                  return CanConnectToMediaSource(source);
 | 
| +                                });
 | 
| +  return source_it != sources.end() ? *source_it : MediaSource();
 | 
| +}
 | 
| +
 | 
|  }  // namespace
 | 
|  
 | 
|  // static
 | 
| @@ -323,10 +334,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.
 | 
| +  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();
 | 
| 
 |