| 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..f679294de9f574772daaa14407b480c6a794927c 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
|
| @@ -153,6 +153,24 @@ Polymer({
|
| },
|
|
|
| /**
|
| + * Whether |routeList| has already been updated.
|
| + * @private {boolean}
|
| + */
|
| + initialRoutesReceived_: {
|
| + type: Boolean,
|
| + value: false,
|
| + },
|
| +
|
| + /**
|
| + * Whether we have already shown either the details view or the sink list.
|
| + * @private {boolean}
|
| + */
|
| + initialViewShown_: {
|
| + type: Boolean,
|
| + value: false,
|
| + },
|
| +
|
| + /**
|
| * Records whether the search input is focused when a window blur event is
|
| * received. This is used to handle search focus edge cases. See
|
| * |setSearchFocusHandlers_| for details.
|
| @@ -255,7 +273,7 @@ Polymer({
|
| */
|
| routeList: {
|
| type: Array,
|
| - observer: 'rebuildRouteMaps_',
|
| + observer: 'routeListChanged_',
|
| },
|
|
|
| /**
|
| @@ -462,6 +480,8 @@ Polymer({
|
| this.fire('report-sink-count', {
|
| sinkCount: this.allSinks.length,
|
| });
|
| + if (!this.initialRoutesReceived_)
|
| + this.routeList = [];
|
| }, 3000 /* 3 seconds */);
|
|
|
| // For Mac platforms, request data after a short delay after load. This
|
| @@ -935,13 +955,15 @@ Polymer({
|
| /**
|
| * @param {?media_router.MediaRouterView} view The current view.
|
| * @param {?media_router.Issue} issue The current issue.
|
| + * @param {boolean} initialViewShown Whether or not the initial view should
|
| + * already be shown.
|
| * @return {boolean} Whether or not to hide entire the sink list view.
|
| * @private
|
| */
|
| - computeSinkListViewHidden_: function(view, issue) {
|
| + computeSinkListViewHidden_: function(view, issue, initialViewShown) {
|
| return (view != media_router.MediaRouterView.SINK_LIST &&
|
| view != media_router.MediaRouterView.FILTER) ||
|
| - (!!issue && issue.isBlocking);
|
| + (!!issue && issue.isBlocking) || !initialViewShown;
|
| },
|
|
|
| /**
|
| @@ -1214,26 +1236,32 @@ Polymer({
|
| },
|
|
|
| /**
|
| - * Updates |currentView_| if the dialog had just opened and there's
|
| - * only one local route.
|
| + * Shows the route details view if there is only one local route, or the sink
|
| + * list view otherwise.
|
| */
|
| - maybeShowRouteDetailsOnOpen: function() {
|
| + showInitialView: function() {
|
| + this.initialViewShown_ = true;
|
| var localRoute = null;
|
| - for (var i = 0; i < this.routeList.length; i++) {
|
| - var route = this.routeList[i];
|
| - if (!route.isLocal)
|
| - continue;
|
| - if (!localRoute) {
|
| - localRoute = route;
|
| - } else {
|
| - // Don't show route details if there are more than one local route.
|
| - localRoute = null;
|
| - break;
|
| + if (this.routeList) {
|
| + for (var i = 0; i < this.routeList.length; i++) {
|
| + var route = this.routeList[i];
|
| + if (!route.isLocal)
|
| + continue;
|
| + if (!localRoute) {
|
| + localRoute = route;
|
| + } else {
|
| + // Don't show route details if there are more than one local route.
|
| + localRoute = null;
|
| + break;
|
| + }
|
| }
|
| }
|
|
|
| - if (localRoute)
|
| + if (localRoute) {
|
| this.showRouteDetails_(localRoute);
|
| + } else {
|
| + this.showSinkList_();
|
| + }
|
| this.fire('show-initial-state', {currentView: this.currentView_});
|
| },
|
|
|
| @@ -1254,7 +1282,7 @@ Polymer({
|
| // Make space for the non-blocking issue in the sink list.
|
| this.updateElementPositioning_();
|
| }
|
| - } else {
|
| + } else if (this.currentView_ == media_router.MediaRouterView.ISSUE) {
|
| // Switch back to the sink list if the issue was cleared. If the previous
|
| // issue was non-blocking, this would be a no-op. It is expected that
|
| // the only way to clear an issue is by user action; the IssueManager
|
| @@ -1917,8 +1945,7 @@ Polymer({
|
| },
|
|
|
| /**
|
| - * Called when |routeList| is updated. Rebuilds |routeMap_| and
|
| - * |sinkToRouteMap_|.
|
| + * Rebuilds |routeMap_| and |sinkToRouteMap_|.
|
| *
|
| * @private
|
| */
|
| @@ -2082,6 +2109,20 @@ Polymer({
|
| },
|
|
|
| /**
|
| + * Called when |routeList| is updated. Shows the initial view if it has yet to
|
| + * be shown.
|
| + *
|
| + * @private
|
| + */
|
| + routeListChanged_: function() {
|
| + if (!this.initialRoutesReceived_) {
|
| + this.initialRoutesReceived_ = true;
|
| + this.showInitialView();
|
| + }
|
| + this.rebuildRouteMaps_();
|
| + },
|
| +
|
| + /**
|
| * Responds to a click on the search button by toggling sink filtering.
|
| */
|
| searchButtonClick_: function() {
|
|
|