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

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

Issue 2862393002: [Media Router] Force DEFAULT cast mode when starting presentations from content. (Closed)
Patch Set: Update unittests Created 3 years, 7 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/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.

Powered by Google App Engine
This is Rietveld 408576698