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 9e149ca7aadec32a7cad87d47b20e35c48e610cd..6580294638ba2f3ab524a089e1d75703735d21cc 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 |
@@ -1561,16 +1561,8 @@ Polymer({ |
if (!clickedMode) |
return; |
- this.userHasSelectedCastMode_ = true; |
+ this.selectCastMode(clickedMode.type); |
this.fire('cast-mode-selected', {castModeType: clickedMode.type}); |
- |
- // The list of sinks to show will be the same if the shown cast mode did |
- // not change, regardless of whether the user selected it explicitly. |
- if (clickedMode.type != this.shownCastModeValue_) { |
- this.setShownCastMode_(clickedMode); |
- this.rebuildSinksToShow_(); |
- } |
- |
this.showSinkList_(); |
this.maybeReportUserFirstAction( |
media_router.MediaRouterUserAction.CHANGE_MODE); |
@@ -2122,6 +2114,20 @@ Polymer({ |
}, |
/** |
+ * Sets the selected cast mode to the one associated with |castModeType|, |
+ * and rebuilds sinks to reflect the change. |
+ * @param {number} castModeType The type of the selected cast mode. |
+ */ |
+ selectCastMode: function(castModeType) { |
+ var castMode = this.findCastModeByType_(castModeType); |
+ if (castMode && castModeType != this.shownCastModeValue_) { |
+ this.setShownCastMode_(castMode); |
+ this.userHasSelectedCastMode_ = true; |
+ this.rebuildSinksToShow_(); |
+ } |
+ }, |
+ |
+ /** |
* Sets various focus and blur event handlers to handle showing search results |
* when the search input is focused. |
* @private |