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

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

Issue 2040883002: [Media Router] Assign each route a current cast mode if possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use current cast mode for display routes, simplify sink launching for route details 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 148f04361a2c6fad712773218c40f76643f57fe7..7716e253bbb06d0119d4c53174b3615da7e84a1f 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,22 +17,13 @@ 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}
+ * @private {boolean}
*/
- replaceRouteAvailable: {
+ replaceRouteAvailable_: {
type: Boolean,
- value: true,
+ computed: 'computeReplaceRouteAvailable_(route, sink,' +
+ 'sinkCurrentlyLaunching, shownCastModeValue)',
},
/**
@@ -45,6 +36,34 @@ Polymer({
},
/**
+ * The cast mode shown to the user. Initially set to auto mode. (See
+ * media_router.CastMode documentation for details on auto mode.)
+ * @type {number}
+ */
+ shownCastModeValue: {
+ type: Number,
+ value: media_router.AUTO_CAST_MODE.type,
+ },
+
+ /**
+ * Sink associated with |route|.
+ * @type {?media_router.Sink}
+ */
+ sink: {
+ type: Object,
+ value: null,
+ },
+
+ /**
+ * Whether a sink is currently launching in the container.
+ * @type {boolean}
+ */
+ sinkCurrentlyLaunching: {
apacible 2016/06/07 12:13:42 nit: Rename as something like, |isAnySinkCurrently
btolsch 2016/06/07 19:45:34 Done.
+ type: Boolean,
+ value: false,
+ },
+
+ /**
* Whether the custom controller should be hidden.
* A custom controller is shown iff |route| specifies customControllerPath
* and the view can be loaded.
@@ -72,15 +91,41 @@ Polymer({
/**
* @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));
+ computeCastButtonHidden_: function(route, replaceRouteAvailable) {
+ return !((route && route.canJoin) || replaceRouteAvailable);
+ },
+
+ /**
+ * @param {?media_router.Route|undefined} route The current route for the
+ * route details view.
+ * @param {?media_router.Sink|undefined} sink Sink associated with |route|.
+ * @param {boolean} sinkCurrentlyLaunching Whether a sink is launching now.
+ * @param {number} shownCastModeValue Currently selected cast mode value or
+ * AUTO if no value has been explicitly selected.
+ * @return {boolean} Whether the replace route function should be available
+ * when displaying |currentRoute| in the route details view. Replace route
+ * should not be available when the source that would be cast from when
+ * creating a new route would be the same as the route's current source.
+ * @private
+ */
+ computeReplaceRouteAvailable_: function(
+ route, sink, sinkCurrentlyLaunching, shownCastModeValue) {
+ if (sinkCurrentlyLaunching || !route || !sink) {
+ return false;
+ }
+ if (!route.currentCastMode) {
+ return true;
+ }
+ var selectedCastMode = shownCastModeValue;
+ if (selectedCastMode == media_router.CastModeType.AUTO) {
+ selectedCastMode = sink.castModes & -sink.castModes;
+ }
+ return (selectedCastMode & sink.castModes) &&
+ (selectedCastMode != route.currentCastMode);
},
/**

Powered by Google App Engine
This is Rietveld 408576698