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 2978c9742f2a4c918c4da1deffd76d4e95491ebf..0cbb231807d07a3d28ffd1b5078befb6e0e44ddb 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 |
| @@ -191,6 +191,17 @@ Polymer({ |
| }, |
| /** |
| + * Whether the currently launching sink, whose ID is given by |
|
mark a. foltz
2016/05/31 22:30:06
The term "launching sink" sounds a bit funny to me
btolsch
2016/06/01 01:58:16
Done.
|
| + * |currentLaunchingSinkId_|, is waiting for the current route to it to be |
| + * closed so a new one can be started. |
| + * @private {boolean} |
| + */ |
| + launchingSinkAwaitingRouteClose_: { |
| + type: Boolean, |
| + value: false, |
| + }, |
| + |
| + /** |
| * Whether the user's mouse is positioned over the dialog. |
| * @private {boolean|undefined} |
| */ |
| @@ -606,6 +617,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|. |
| @@ -703,7 +732,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: |
| @@ -1563,15 +1592,37 @@ Polymer({ |
| }, |
| /** |
| - * 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. |
| + * 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 |
| */ |
| - onCloseRouteClick_: function(event) { |
| + onCastNewMediaClick_: function(event) { |
| + /** @type {{route: !media_router.Route}} */ |
| + var detail = event.detail; |
| + this.currentLaunchingSinkId_ = detail.route.sinkId; |
|
mark a. foltz
2016/05/31 22:30:06
Is it possible to get this event when there is alr
btolsch
2016/06/01 01:58:16
Jennifer asked the same question earlier (https://
|
| + this.launchingSinkAwaitingRouteClose_ = true; |
|
mark a. foltz
2016/05/31 22:30:06
What if this was already true?
btolsch
2016/06/01 01:58:16
That would cause the first sink (the one originall
|
| + this.fire('close-route', detail); |
| + this.showSinkList_(); |
| + this.maybeReportUserFirstAction( |
| + media_router.MediaRouterUserAction.CAST_TO_ROUTE); |
| + }, |
| + |
| + /** |
| + * Handles a close-route event. Shows the sink list and starts a timer to |
| + * close the dialog if there is no click within three seconds. |
| + * |
| + * @param {!Event} event The event object. |
| + * Parameters in |event|.detail: |
| + * route - route to close. |
| + * @private |
| + */ |
| + onCloseRoute_: function(event) { |
| /** @type {{route: media_router.Route}} */ |
| var detail = event.detail; |
| this.showSinkList_(); |
| @@ -1928,6 +1979,14 @@ 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.launchingSinkAwaitingRouteClose_ && |
| + !(this.currentLaunchingSinkId_ in this.sinkToRouteMap_) && |
| + this.currentLaunchingSinkId_ in this.sinkMap_) { |
| + this.showOrCreateRoute_(this.sinkMap_[this.currentLaunchingSinkId_]); |
| + } |
| }, |
| /** |
| @@ -2147,7 +2206,9 @@ Polymer({ |
| this.fire('navigate-sink-list-to-details'); |
| this.maybeReportUserFirstAction( |
| media_router.MediaRouterUserAction.STATUS_REMOTE); |
| - } else if (this.currentLaunchingSinkId_ == '') { |
| + } else if ((this.launchingSinkAwaitingRouteClose_ && |
| + this.currentLaunchingSinkId_ == sink.id) || |
| + this.currentLaunchingSinkId_ == '') { |
| // Allow one launch at a time. |
| var selectedCastModeValue = |
| this.shownCastModeValue_ == media_router.CastModeType.AUTO ? |
| @@ -2174,7 +2235,11 @@ Polymer({ |
| performance.now() - this.populatedSinkListSeenTimeMs_; |
| this.fire('report-sink-click-time', {timeMs: timeToSelectSink}); |
| } |
| - this.currentLaunchingSinkId_ = sink.id; |
| + if (!this.launchingSinkAwaitingRouteClose_) { |
| + this.currentLaunchingSinkId_ = sink.id; |
| + } else { |
| + this.launchingSinkAwaitingRouteClose_ = false; |
| + } |
| if (sink.isPseudoSink) { |
| this.rebuildSinksToShow_(); |
| } |