OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This Polymer element contains the entire media router interface. It handles | 5 /** |
6 // hiding and showing specific components. | 6 * This Polymer element contains the entire media router interface. It handles |
| 7 * hiding and showing specific components. |
| 8 * @implements {MediaRouterContainerInterface} |
| 9 */ |
7 Polymer({ | 10 Polymer({ |
8 is: 'media-router-container', | 11 is: 'media-router-container', |
9 | 12 |
10 properties: { | 13 properties: { |
11 /** | 14 /** |
12 * The list of available sinks. | 15 * The list of available sinks. |
13 * @type {!Array<!media_router.Sink>} | 16 * @type {!Array<!media_router.Sink>} |
14 */ | 17 */ |
15 allSinks: { | 18 allSinks: { |
16 type: Array, | 19 type: Array, |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 /** | 383 /** |
381 * Sinks to show for the currently selected cast mode. | 384 * Sinks to show for the currently selected cast mode. |
382 * @private {!Array<!media_router.Sink>|undefined} | 385 * @private {!Array<!media_router.Sink>|undefined} |
383 */ | 386 */ |
384 sinksToShow_: { | 387 sinksToShow_: { |
385 type: Array, | 388 type: Array, |
386 observer: 'updateElementPositioning_', | 389 observer: 'updateElementPositioning_', |
387 }, | 390 }, |
388 | 391 |
389 /** | 392 /** |
| 393 * Whether the WebUI route controls should be shown instead of the |
| 394 * extensionview in the route details view. |
| 395 * @type {boolean} |
| 396 */ |
| 397 useWebUiRouteControls: { |
| 398 type: Boolean, |
| 399 value: false, |
| 400 }, |
| 401 |
| 402 /** |
390 * Whether the user has explicitly selected a cast mode. | 403 * Whether the user has explicitly selected a cast mode. |
391 * @private {boolean} | 404 * @private {boolean} |
392 */ | 405 */ |
393 userHasSelectedCastMode_: { | 406 userHasSelectedCastMode_: { |
394 type: Boolean, | 407 type: Boolean, |
395 value: false, | 408 value: false, |
396 }, | 409 }, |
397 | 410 |
398 /** | 411 /** |
399 * Whether the user has already taken an action. | 412 * Whether the user has already taken an action. |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 | 869 |
857 /** | 870 /** |
858 * Computes whether the search results list should be hidden. | 871 * Computes whether the search results list should be hidden. |
859 * @param {!Array<!{sinkItem: !media_router.Sink, | 872 * @param {!Array<!{sinkItem: !media_router.Sink, |
860 * substrings: Array<!Array<number>>}>} searchResultsToShow | 873 * substrings: Array<!Array<number>>}>} searchResultsToShow |
861 * The sinks currently matching the search text. | 874 * The sinks currently matching the search text. |
862 * @param {boolean} isSearchListHidden Whether the search list is hidden. | 875 * @param {boolean} isSearchListHidden Whether the search list is hidden. |
863 * @return {boolean} Whether the search results list should be hidden. | 876 * @return {boolean} Whether the search results list should be hidden. |
864 * @private | 877 * @private |
865 */ | 878 */ |
866 computeSearchResultsHidden_: function(searchResultsToShow, | 879 computeSearchResultsHidden_: function( |
867 isSearchListHidden) { | 880 searchResultsToShow, isSearchListHidden) { |
868 return isSearchListHidden || searchResultsToShow.length == 0; | 881 return isSearchListHidden || searchResultsToShow.length == 0; |
869 }, | 882 }, |
870 | 883 |
871 /** | 884 /** |
872 * @param {!Array<!media_router.CastMode>} castModeList The current list of | 885 * @param {!Array<!media_router.CastMode>} castModeList The current list of |
873 * cast modes. | 886 * cast modes. |
874 * @return {boolean} Whether or not to hide the share screen subheading text. | 887 * @return {boolean} Whether or not to hide the share screen subheading text. |
875 * @private | 888 * @private |
876 */ | 889 */ |
877 computeShareScreenSubheadingHidden_: function(castModeList) { | 890 computeShareScreenSubheadingHidden_: function(castModeList) { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 return Math.min(contentHeight, maxHeight) + searchOffsetHeight; | 1086 return Math.min(contentHeight, maxHeight) + searchOffsetHeight; |
1074 }, | 1087 }, |
1075 | 1088 |
1076 /** | 1089 /** |
1077 * Updates element positioning when the view changes and possibly triggers | 1090 * Updates element positioning when the view changes and possibly triggers |
1078 * reporting of a user filter action. If there is no filter text, it defers | 1091 * reporting of a user filter action. If there is no filter text, it defers |
1079 * the reporting until some text is entered, but otherwise it reports the | 1092 * the reporting until some text is entered, but otherwise it reports the |
1080 * filter action here. | 1093 * filter action here. |
1081 * @param {?media_router.MediaRouterView} currentView The current view of the | 1094 * @param {?media_router.MediaRouterView} currentView The current view of the |
1082 * dialog. | 1095 * dialog. |
| 1096 * @param {?media_router.MediaRouterView} previousView The previous |
| 1097 * |currentView|. |
1083 * @private | 1098 * @private |
1084 */ | 1099 */ |
1085 currentViewChanged_: function(currentView) { | 1100 currentViewChanged_: function(currentView, previousView) { |
1086 if (currentView == media_router.MediaRouterView.FILTER) { | 1101 if (currentView == media_router.MediaRouterView.FILTER) { |
1087 this.reportFilterOnInput_ = true; | 1102 this.reportFilterOnInput_ = true; |
1088 this.maybeReportFilter_(); | 1103 this.maybeReportFilter_(); |
1089 } | 1104 } |
1090 this.updateElementPositioning_(); | 1105 this.updateElementPositioning_(); |
| 1106 |
| 1107 if (previousView == media_router.MediaRouterView.ROUTE_DETAILS) { |
| 1108 media_router.browserApi.onMediaControllerClosed(); |
| 1109 if (this.$$('route-details')) |
| 1110 this.$$('route-details').onClosed(); |
| 1111 } |
1091 }, | 1112 }, |
1092 | 1113 |
1093 /** | 1114 /** |
1094 * Filters all sinks based on fuzzy matching to the currently entered search | 1115 * Filters all sinks based on fuzzy matching to the currently entered search |
1095 * text. | 1116 * text. |
1096 * @param {string} searchInputText The currently entered search text. | 1117 * @param {string} searchInputText The currently entered search text. |
1097 * @private | 1118 * @private |
1098 */ | 1119 */ |
1099 filterSinks_: function(searchInputText) { | 1120 filterSinks_: function(searchInputText) { |
1100 if (searchInputText.length == 0) { | 1121 if (searchInputText.length == 0) { |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1760 this.pseudoSinkSearchState_.checkForRealSink(this.allSinks); | 1781 this.pseudoSinkSearchState_.checkForRealSink(this.allSinks); |
1761 this.rebuildSinksToShow_(); | 1782 this.rebuildSinksToShow_(); |
1762 // If we're in filter view, make sure the |sinksToShow_| change is picked | 1783 // If we're in filter view, make sure the |sinksToShow_| change is picked |
1763 // up. | 1784 // up. |
1764 if (this.currentView_ == media_router.MediaRouterView.FILTER) { | 1785 if (this.currentView_ == media_router.MediaRouterView.FILTER) { |
1765 this.filterSinks_(this.searchInputText_); | 1786 this.filterSinks_(this.searchInputText_); |
1766 } | 1787 } |
1767 }, | 1788 }, |
1768 | 1789 |
1769 /** | 1790 /** |
| 1791 * Called when the connection to the route controller is invalidated. Switches |
| 1792 * from route details view to the sink list view. |
| 1793 */ |
| 1794 onRouteControllerInvalidated: function() { |
| 1795 if (this.useWebUiRouteControls && |
| 1796 this.currentView_ == media_router.MediaRouterView.ROUTE_DETAILS) { |
| 1797 this.currentRoute_ = null; |
| 1798 this.showSinkList_(); |
| 1799 } |
| 1800 }, |
| 1801 |
| 1802 /** |
1770 * Called when a sink is clicked. | 1803 * Called when a sink is clicked. |
1771 * | 1804 * |
1772 * @param {!Event} event The event object. | 1805 * @param {!Event} event The event object. |
1773 * @private | 1806 * @private |
1774 */ | 1807 */ |
1775 onSinkClick_: function(event) { | 1808 onSinkClick_: function(event) { |
1776 var clickedSink = | 1809 var clickedSink = |
1777 (this.currentView_ == media_router.MediaRouterView.FILTER) ? | 1810 (this.currentView_ == media_router.MediaRouterView.FILTER) ? |
1778 this.$$('#searchResults').itemForElement(event.target).sinkItem : | 1811 this.$$('#searchResults').itemForElement(event.target).sinkItem : |
1779 this.$$('#sinkList').itemForElement(event.target); | 1812 this.$$('#sinkList').itemForElement(event.target); |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 | 2304 |
2272 /** | 2305 /** |
2273 * Shows the route details. | 2306 * Shows the route details. |
2274 * | 2307 * |
2275 * @param {!media_router.Route} route The route to show. | 2308 * @param {!media_router.Route} route The route to show. |
2276 * @private | 2309 * @private |
2277 */ | 2310 */ |
2278 showRouteDetails_: function(route) { | 2311 showRouteDetails_: function(route) { |
2279 this.currentRoute_ = route; | 2312 this.currentRoute_ = route; |
2280 this.currentView_ = media_router.MediaRouterView.ROUTE_DETAILS; | 2313 this.currentView_ = media_router.MediaRouterView.ROUTE_DETAILS; |
| 2314 if (this.useWebUiRouteControls) { |
| 2315 media_router.browserApi.onMediaControllerAvailable(route.id); |
| 2316 } |
| 2317 if (this.$$('route-details')) { |
| 2318 this.$$('route-details').onOpened(); |
| 2319 } |
2281 }, | 2320 }, |
2282 | 2321 |
2283 /** | 2322 /** |
2284 * Shows the search results. | 2323 * Shows the search results. |
2285 * | 2324 * |
2286 * @private | 2325 * @private |
2287 */ | 2326 */ |
2288 showSearchResults_: function() { | 2327 showSearchResults_: function() { |
2289 if (this.currentView_ != media_router.MediaRouterView.FILTER) { | 2328 if (this.currentView_ != media_router.MediaRouterView.FILTER) { |
2290 this.currentView_ = media_router.MediaRouterView.FILTER; | 2329 this.currentView_ = media_router.MediaRouterView.FILTER; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2388 /** | 2427 /** |
2389 * Update the max dialog height and update the positioning of the elements. | 2428 * Update the max dialog height and update the positioning of the elements. |
2390 * | 2429 * |
2391 * @param {number} height The max height of the Media Router dialog. | 2430 * @param {number} height The max height of the Media Router dialog. |
2392 */ | 2431 */ |
2393 updateMaxDialogHeight: function(height) { | 2432 updateMaxDialogHeight: function(height) { |
2394 this.dialogHeight_ = height; | 2433 this.dialogHeight_ = height; |
2395 this.updateElementPositioning_(); | 2434 this.updateElementPositioning_(); |
2396 }, | 2435 }, |
2397 }); | 2436 }); |
OLD | NEW |