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..31bed7d089db9e4dcfafab3a3271bb6a79daf894 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 |
| @@ -200,6 +200,17 @@ Polymer({ |
| }, |
| /** |
| + * Whether the currently launching sink, whose ID is given by |
| + * |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} |
| */ |
| @@ -614,6 +625,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 +740,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] ? |
|
apacible
2016/05/25 22:37:01
Is this relevant to your main changes? I was looki
btolsch
2016/05/26 00:31:12
This change doesn't have to be made here, but I th
apacible
2016/05/26 17:20:46
Ah, I thought the WebUI filtered out sinks by cast
|
| this.sinkMap_[this.currentRoute_.sinkId].name : ''; |
| case media_router.MediaRouterView.SINK_LIST: |
| case media_router.MediaRouterView.FILTER: |
| @@ -1571,6 +1600,28 @@ 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) { |
| + /** @type {{route: !media_router.Route}} */ |
| + var detail = event.detail; |
| + this.currentLaunchingSinkId_ = detail.route.sinkId; |
| + this.launchingSinkAwaitingRouteClose_ = true; |
| + this.fire('close-route-for-new-media', detail); |
|
apacible
2016/05/25 22:37:01
Fire 'close-route-click' (or 'close-route' and ren
btolsch
2016/05/26 00:31:12
Done.
|
| + this.showSinkList_(); |
| + this.maybeReportUserFirstAction( |
| + media_router.MediaRouterUserAction.START_LOCAL); |
| + }, |
| + |
| + /** |
| * 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 +1987,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_]); |
| + } |
| }, |
| /** |
| @@ -2157,7 +2216,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 ? |
| @@ -2184,7 +2245,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_(); |
| } |