| 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..b6e04ef1c6802605a166717c84d895abddcb9d35 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] ?
|
| this.sinkMap_[this.currentRoute_.sinkId].name : '';
|
| case media_router.MediaRouterView.SINK_LIST:
|
| case media_router.MediaRouterView.FILTER:
|
| @@ -1571,15 +1600,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;
|
| + this.launchingSinkAwaitingRouteClose_ = true;
|
| + 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_();
|
| @@ -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_();
|
| }
|
|
|