Chromium Code Reviews| 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 26362e10a694143a51d0fba9b523a486a1fd99af..40e66aaec8b0b446b3329ee2a9477f45972c15fc 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 |
| @@ -360,6 +360,16 @@ Polymer({ |
| }, |
| /** |
| + * ID of the sink waiting for the current route to it to be closed so a new |
| + * one can be started, or the empty string when no such sink is waiting. |
| + * @private {string} |
| + */ |
| + sinkIdAwaitingNewRoute_: { |
|
apacible
2016/05/25 00:56:34
Could we generalize |currentLaunchingSinkId_| for
btolsch
2016/05/25 20:53:44
Done. I think we still need a boolean indicating w
|
| + type: String, |
| + value: '', |
| + }, |
| + |
| + /** |
| * Max height for the sink list. |
| * @private {number} |
| */ |
| @@ -614,6 +624,24 @@ Polymer({ |
| }, |
| /** |
| + * @param {!media_router.Route} route |
| + * @return {number} Bitmask of cast modes available for the sink of |route|. |
| + * There will be no more than 1 bit set if the user has selected a |
| + * specific cast mode. |
| + */ |
| + computeAvailableCastModesForRoute_: function(route) { |
| + if (route && route.sinkId && this.sinkMap_[route.sinkId]) { |
| + var sinkCastModes = this.sinkMap_[route.sinkId].castModes; |
| + if (this.shownCastModeValue_ == media_router.CastModeType.AUTO) { |
| + return sinkCastModes; |
| + } else { |
| + return this.shownCastModeValue_ & sinkCastModes; |
| + } |
| + } |
| + return 0; |
| + }, |
| + |
| + /** |
| * If |allSinks| supports only a single cast mode, returns that cast mode. |
| * Otherwise, returns AUTO_MODE. Only called if |userHasSelectedCastMode_| is |
| * |false|. |
| @@ -711,7 +739,7 @@ Polymer({ |
| case media_router.MediaRouterView.ISSUE: |
| return this.i18n('issueHeaderText'); |
| case media_router.MediaRouterView.ROUTE_DETAILS: |
| - return this.currentRoute_ ? |
| + return this.currentRoute_ && this.sinkMap_[this.currentRoute_.sinkId] ? |
| this.sinkMap_[this.currentRoute_.sinkId].name : ''; |
| case media_router.MediaRouterView.SINK_LIST: |
| case media_router.MediaRouterView.FILTER: |
| @@ -1571,6 +1599,25 @@ Polymer({ |
| }, |
| /** |
| + * Handles a cast-new-media-click event. Closes the currently displayed local |
| + * route and shows the sink list. When the current route has been successfully |
| + * removed from the route map, the container will launch a new route for the |
| + * same sink. |
| + * |
| + * @param {!Event} event The event object. |
| + * Parameters in |event|.detail: |
| + * route - route to close. |
| + * @private |
| + */ |
| + onCastNewMediaClick_: function(event) { |
|
apacible
2016/05/25 00:56:34
We should keep track if this is the first user act
btolsch
2016/05/25 20:53:44
Done. I reused START_LOCAL for this, but let me kn
apacible
2016/05/25 22:37:01
I'd prefer a new event, since it may be useful to
btolsch
2016/05/26 00:31:12
Done. Used CAST_TO_ROUTE.
|
| + /** @type {{route: !media_router.Route}} */ |
| + var detail = event.detail; |
| + this.sinkIdAwaitingNewRoute_ = detail.route.sinkId; |
|
apacible
2016/05/25 00:56:34
UX question: Do we expect the dialog to close afte
btolsch
2016/05/25 20:53:44
That's what I would expect. Do you think it shoul
apacible
2016/05/25 22:37:01
No, that sg.
|
| + this.fire('close-route-for-new-media', detail); |
| + this.showSinkList_(); |
| + }, |
| + |
| + /** |
| * Handles a close-route-click event. Shows the sink list and starts a timer |
| * to close the dialog if there is no click within three seconds. |
| * |
| @@ -1936,6 +1983,15 @@ Polymer({ |
| this.sinkToRouteMap_ = tempSinkToRouteMap; |
| this.rebuildSinksToShow_(); |
| + |
| + // A sink was waiting for its route to be closed and removed from the route |
| + // map so a new route to it can be started. |
| + if (this.sinkIdAwaitingNewRoute_ != '' && |
| + !(this.sinkIdAwaitingNewRoute_ in this.sinkToRouteMap_) && |
| + this.sinkIdAwaitingNewRoute_ in this.sinkMap_) { |
| + this.showOrCreateRoute_(this.sinkMap_[this.sinkIdAwaitingNewRoute_]); |
| + this.sinkIdAwaitingNewRoute_ = ''; |
| + } |
| }, |
| /** |