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

Unified Diff: chrome/browser/resources/media_router/elements/route_details/route_details.js

Issue 2062913002: [Media Router] Allow casting new media to sink with existing route. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 months 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/resources/media_router/elements/route_details/route_details.js
diff --git a/chrome/browser/resources/media_router/elements/route_details/route_details.js b/chrome/browser/resources/media_router/elements/route_details/route_details.js
index e92779eee7949053436953d8fa989f07541b8738..148f04361a2c6fad712773218c40f76643f57fe7 100644
--- a/chrome/browser/resources/media_router/elements/route_details/route_details.js
+++ b/chrome/browser/resources/media_router/elements/route_details/route_details.js
@@ -17,6 +17,25 @@ Polymer({
},
/**
+ * Bitmask of available cast modes compatible with the sink of the current
+ * route.
+ * @type {number}
+ */
+ availableCastModes: {
+ type: Number,
+ value: 0,
+ },
+
+ /**
+ * Whether the external container will accept replace-route-click events.
+ * @type {boolean}
+ */
+ replaceRouteAvailable: {
+ type: Boolean,
+ value: true,
+ },
+
+ /**
* The route to show.
* @type {?media_router.Route|undefined}
*/
@@ -42,23 +61,42 @@ Polymer({
],
/**
- * Fires a close-route-click event. This is called when the button to close
+ * Fires a close-route event. This is called when the button to close
* the current route is clicked.
*
* @private
*/
closeRoute_: function() {
- this.fire('close-route-click', {route: this.route});
+ this.fire('close-route', {route: this.route});
},
/**
- * Fires a start-casting-to-route-click event. This is called when the button
- * to start casting to the current route is clicked.
+ * @param {?media_router.Route|undefined} route
+ * @param {number} availableCastModes
+ * @param {boolean} replaceRouteAvailable
+ * @return {boolean} Whether to show the button that allows casting to the
+ * current route or the current route's sink.
+ */
+ computeCastButtonHidden_: function(
+ route, availableCastModes, replaceRouteAvailable) {
+ return !((route && route.canJoin) ||
+ (availableCastModes && replaceRouteAvailable));
+ },
+
+ /**
+ * Fires a join-route-click event if the current route is joinable, otherwise
+ * it fires a replace-route-click event, which stops the current route and
+ * immediately launches a new route to the same sink. This is called when the
+ * button to start casting to the current route is clicked.
*
* @private
*/
startCastingToRoute_: function() {
- this.fire('start-casting-to-route-click', {route: this.route});
+ if (this.route.canJoin) {
+ this.fire('join-route-click', {route: this.route});
+ } else {
+ this.fire('replace-route-click', {route: this.route});
+ }
},
/**

Powered by Google App Engine
This is Rietveld 408576698