summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/resources
diff options
context:
space:
mode:
authorimcheng <imcheng@chromium.org>2015-09-04 12:57:22 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-04 19:58:36 +0000
commit95b035acbd5de817212c595b13d9eef06c42ded0 (patch)
tree58833b3b4874f50159ff1aa72bb589b10213d52c /extensions/renderer/resources
parent42faaab81b7fc1484058e9bb9d8f3fb10567ba40 (diff)
downloadchromium_src-95b035acbd5de817212c595b13d9eef06c42ded0.zip
chromium_src-95b035acbd5de817212c595b13d9eef06c42ded0.tar.gz
chromium_src-95b035acbd5de817212c595b13d9eef06c42ded0.tar.bz2
[Media Router] Downgrade MediaSink / add for_display in MediaRoute.
We don't need to have the full MediaSink in the MediaRoute; only the sink ID is needed for UI purposes. This simplifies the MediaRoute conversion logic in media_router_bindings.js since it no longer has to rely on logic to look up sink name or other hacks. Also add bool for_display to MediaRoute for purpose of selecting proper route to be displayed in UI. This field is to be populated by the provider. Also removed unused mojo converters. There will be a corresponding change to provider manager code to remove the sinks input argument for onRoutesUpdated, and add for_display field to Route. After the providers are updated to populate for_display, the UI logic can be changed to only pass in routes with for_display = true to the WebUI. BUG=510300 Review URL: https://codereview.chromium.org/1325753003 Cr-Commit-Position: refs/heads/master@{#347475}
Diffstat (limited to 'extensions/renderer/resources')
-rw-r--r--extensions/renderer/resources/media_router_bindings.js33
1 files changed, 8 insertions, 25 deletions
diff --git a/extensions/renderer/resources/media_router_bindings.js b/extensions/renderer/resources/media_router_bindings.js
index 7063856..dc54f42 100644
--- a/extensions/renderer/resources/media_router_bindings.js
+++ b/extensions/renderer/resources/media_router_bindings.js
@@ -61,21 +61,19 @@ define('media_router_bindings', [
* Returns a Mojo MediaRoute object given a MediaRoute and a
* media sink name.
* @param {!MediaRoute} route
- * @param {!string} sinkName
* @return {!mojo.MediaRoute}
*/
- function routeToMojo_(route, sinkName) {
+ function routeToMojo_(route) {
return new mediaRouterMojom.MediaRoute({
'media_route_id': route.id,
'media_source': route.mediaSource,
- 'media_sink': new mediaRouterMojom.MediaSink({
- 'sink_id': route.sinkId,
- 'name': sinkName,
- }),
+ 'media_sink_id': route.sinkId,
'description': route.description,
'icon_url': route.iconUrl,
'is_local': route.isLocal,
'custom_controller_path': route.customControllerPath,
+ // TODO(imcheng): Remove logic when extension always sets the field.
+ 'for_display': route.forDisplay == undefined ? true : route.forDisplay
});
}
@@ -259,22 +257,9 @@ define('media_router_bindings', [
* Called by the provider manager when the set of active routes
* has been updated.
* @param {!Array<MediaRoute>} routes The active set of media routes.
- * @param {!Array<MediaSink>} sinks The active set of media sinks.
*/
- MediaRouter.prototype.onRoutesUpdated = function(routes, sinks) {
- // Create an inverted index relating sink IDs to their names.
- var sinkNameMap = {};
- for (var i = 0; i < sinks.length; i++) {
- sinkNameMap[sinks[i].id] = sinks[i].friendlyName;
- }
-
- // Convert MediaRoutes to Mojo objects and add their sink names
- // via sinkNameMap.
- var mojoRoutes = routes.map(function(nextRoute) {
- return routeToMojo_(nextRoute, sinkNameMap[nextRoute.sinkId]);
- });
-
- this.service_.onRoutesUpdated(mojoRoutes, sinks.map(sinkToMojo_));
+ MediaRouter.prototype.onRoutesUpdated = function(routes) {
+ this.service_.onRoutesUpdated(routes.map(routeToMojo_));
};
/**
@@ -463,8 +448,7 @@ define('media_router_bindings', [
return this.handlers_.createRoute(
sourceUrn, sinkId, presentationId, origin, tabId)
.then(function(route) {
- // Sink name is not used, so it is omitted here.
- return {route: routeToMojo_(route, "")};
+ return {route: routeToMojo_(route)};
}.bind(this))
.catch(function(err) {
return {error_text: 'Error creating route: ' + err.message};
@@ -487,8 +471,7 @@ define('media_router_bindings', [
function(sourceUrn, presentationId, origin, tabId) {
return this.handlers_.joinRoute(sourceUrn, presentationId, origin, tabId)
.then(function(newRoute) {
- // Sink name is not used, so it is omitted here.
- return {route: routeToMojo_(newRoute, "")};
+ return {route: routeToMojo_(newRoute)};
},
function(err) {
return {error_text: 'Error joining route: ' + err.message};