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

Unified Diff: chrome/browser/ui/webui/media_router/media_router_ui.cc

Issue 2488403002: [Media Router] Handle multiple Presentation URLs when creating routes. (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/media/router/presentation_service_delegate_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « chrome/browser/media/router/presentation_service_delegate_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698