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

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

Issue 2547703002: [Media Router] Handle multiple Presentation URLs when creating routes (Closed)
Patch Set: fix unittests Created 4 years 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
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..1a749addd6b99d8e958d7bb8fb9a9e6bf0fe055e 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 MediaSource& source) {
mark a. foltz 2016/12/02 20:59:09 Is the lambda function necessary, or can you pass
zhaobin 2016/12/02 22:50:57 Done.
+ 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();

Powered by Google App Engine
This is Rietveld 408576698