Index: chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js |
diff --git a/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js b/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js |
index ff9296814a7eeddcf8752044bf520113b037fe76..4010f1b73444fa92c1dd9bb9af47b7dbf10f6aab 100644 |
--- a/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js |
+++ b/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js |
@@ -530,6 +530,11 @@ Polymer({ |
if (!this.castModeList.length) |
return; |
+ // If there is a forced mode make sure it is shown. |
+ if (this.findForcedCastMode_()) { |
+ this.rebuildSinksToShow_(); |
+ } |
+ |
// If we are currently showing auto mode, then nothing needs to be done. |
// Otherwise, if the cast mode currently shown no longer exists (regardless |
// of whether it was selected by user), then switch back to auto cast mode. |
@@ -611,13 +616,18 @@ Polymer({ |
}, |
/** |
- * If |allSinks| supports only a single cast mode, returns that cast mode. |
- * Otherwise, returns AUTO_MODE. Only called if |userHasSelectedCastMode_| is |
- * |false|. |
+ * If there is a forced cast mode, returns that cast mode. If |allSinks| |
+ * supports only a single cast mode, returns that cast mode. Otherwise, |
+ * returns AUTO_MODE. Only called if |userHasSelectedCastMode_| is |false|. |
+ * |
* @return {!media_router.CastMode} The single cast mode supported by |
* |allSinks|, or AUTO_MODE. |
*/ |
computeCastMode_: function() { |
+ /** @const */ var forcedMode = this.findForcedCastMode_(); |
+ if (forcedMode) |
+ return forcedMode; |
+ |
var allCastModes = this.allSinks.reduce(function(castModesSoFar, sink) { |
return castModesSoFar | sink.castModes; |
}, 0); |
@@ -1149,6 +1159,17 @@ Polymer({ |
}, |
/** |
+ * Helper function to return a forced CastMode, if any. |
+ * |
+ * @return {media_router.CastMode|undefined} CastMode object with |
+ * isForced = true, or undefined if not found. |
+ */ |
+ findForcedCastMode_: function() { |
+ return this.castModeList && |
+ this.castModeList.find(element => element.isForced); |
+ }, |
+ |
+ /** |
* @param {?Element} element Element to compute padding for. |
* @return {!Array<number>} Array containing the element's bottom padding |
* value and the element's top padding value, in that order. |