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 shows information from media that is currently cast | 5 // This Polymer element shows information from media that is currently cast |
6 // to a device. | 6 // to a device. |
7 Polymer({ | 7 Polymer({ |
8 is: 'route-details', | 8 is: 'route-details', |
9 | 9 |
10 properties: { | 10 properties: { |
(...skipping 15 matching lines...) Expand all Loading... |
26 computed: 'computeChangeRouteSourceAvailable_(route, sink,' + | 26 computed: 'computeChangeRouteSourceAvailable_(route, sink,' + |
27 'isAnySinkCurrentlyLaunching, shownCastModeValue)', | 27 'isAnySinkCurrentlyLaunching, shownCastModeValue)', |
28 }, | 28 }, |
29 | 29 |
30 /** | 30 /** |
31 * An enum value to represent the controller to show. | 31 * An enum value to represent the controller to show. |
32 * @private {number} | 32 * @private {number} |
33 */ | 33 */ |
34 controllerType_: { | 34 controllerType_: { |
35 type: Number, | 35 type: Number, |
36 computed: 'computeControllerType_(useWebUiRouteControls,' + | 36 computed: 'computeControllerType_(route, isExtensionViewReady)', |
37 'isExtensionViewReady)', | |
38 }, | 37 }, |
39 | 38 |
40 /** | 39 /** |
41 * Whether a sink is currently launching in the container. | 40 * Whether a sink is currently launching in the container. |
42 * @type {boolean} | 41 * @type {boolean} |
43 */ | 42 */ |
44 isAnySinkCurrentlyLaunching: { | 43 isAnySinkCurrentlyLaunching: { |
45 type: Boolean, | 44 type: Boolean, |
46 value: false, | 45 value: false, |
47 }, | 46 }, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 }, | 87 }, |
89 | 88 |
90 /** | 89 /** |
91 * Sink associated with |route|. | 90 * Sink associated with |route|. |
92 * @type {?media_router.Sink} | 91 * @type {?media_router.Sink} |
93 */ | 92 */ |
94 sink: { | 93 sink: { |
95 type: Object, | 94 type: Object, |
96 value: null, | 95 value: null, |
97 }, | 96 }, |
98 | |
99 /** | |
100 * Whether we should use the WebUI route controls. This value is used for | |
101 * updating |controllerType_|, | |
102 * @type {boolean} | |
103 */ | |
104 useWebUiRouteControls: { | |
105 type: Boolean, | |
106 value: false, | |
107 }, | |
108 }, | 97 }, |
109 | 98 |
110 behaviors: [ | 99 behaviors: [ |
111 I18nBehavior, | 100 I18nBehavior, |
112 ], | 101 ], |
113 | 102 |
114 /** | 103 /** |
115 * Fires a close-route event. This is called when the button to close | 104 * Fires a close-route event. This is called when the button to close |
116 * the current route is clicked. | 105 * the current route is clicked. |
117 * | 106 * |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 if (!route.currentCastMode) { | 143 if (!route.currentCastMode) { |
155 return true; | 144 return true; |
156 } | 145 } |
157 var selectedCastMode = | 146 var selectedCastMode = |
158 this.computeSelectedCastMode_(shownCastModeValue, sink); | 147 this.computeSelectedCastMode_(shownCastModeValue, sink); |
159 return (selectedCastMode != 0) && | 148 return (selectedCastMode != 0) && |
160 (selectedCastMode != route.currentCastMode); | 149 (selectedCastMode != route.currentCastMode); |
161 }, | 150 }, |
162 | 151 |
163 /** | 152 /** |
164 * @param {boolean} useWebUiRouteControls | 153 * @param {?media_router.Route} route |
165 * @param {boolean} isExtensionViewReady | 154 * @param {boolean} isExtensionViewReady |
166 * @return {number} An enum value to represent the controller to show. | 155 * @return {number} An enum value to represent the controller to show. |
167 * @private | 156 * @private |
168 */ | 157 */ |
169 computeControllerType_: function( | 158 computeControllerType_: function(route, isExtensionViewReady) { |
170 useWebUiRouteControls, isExtensionViewReady) { | 159 if (route && route.supportsWebUiController) { |
171 if (useWebUiRouteControls) { | |
172 return media_router.ControllerType.WEBUI; | 160 return media_router.ControllerType.WEBUI; |
173 } | 161 } |
174 if (isExtensionViewReady) { | 162 if (isExtensionViewReady) { |
175 return media_router.ControllerType.EXTENSION; | 163 return media_router.ControllerType.EXTENSION; |
176 } | 164 } |
177 return media_router.ControllerType.NONE; | 165 return media_router.ControllerType.NONE; |
178 }, | 166 }, |
179 | 167 |
180 /** | 168 /** |
181 * @param {number} castMode User selected cast mode or AUTO. | 169 * @param {number} castMode User selected cast mode or AUTO. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 this.updateActivityStatus_(); | 233 this.updateActivityStatus_(); |
246 } | 234 } |
247 if (newRoute && | 235 if (newRoute && |
248 this.controllerType_ === media_router.ControllerType.WEBUI && | 236 this.controllerType_ === media_router.ControllerType.WEBUI && |
249 this.$$('route-controls')) { | 237 this.$$('route-controls')) { |
250 this.$$('route-controls').onRouteUpdated(newRoute); | 238 this.$$('route-controls').onRouteUpdated(newRoute); |
251 } | 239 } |
252 }, | 240 }, |
253 | 241 |
254 /** | 242 /** |
| 243 * @param {?media_router.Route} route |
| 244 * @return {boolean} |
| 245 * @private |
| 246 */ |
| 247 shouldAttemptLoadingExtensionView_: function(route) { |
| 248 return !!route && !route.supportsWebUiController; |
| 249 }, |
| 250 |
| 251 /** |
255 * @param {number} controllerType | 252 * @param {number} controllerType |
256 * @return {boolean} Whether the extensionview should be shown instead of the | 253 * @return {boolean} Whether the extensionview should be shown instead of the |
257 * default route info element or the WebUI route controller. | 254 * default route info element or the WebUI route controller. |
258 * @private | 255 * @private |
259 */ | 256 */ |
260 shouldShowExtensionView_: function(controllerType) { | 257 shouldShowExtensionView_: function(controllerType) { |
261 return controllerType === media_router.ControllerType.EXTENSION; | 258 return controllerType === media_router.ControllerType.EXTENSION; |
262 }, | 259 }, |
263 | 260 |
264 /** | 261 /** |
(...skipping 30 matching lines...) Expand all Loading... |
295 this.fire('join-route-click', {route: this.route}); | 292 this.fire('join-route-click', {route: this.route}); |
296 } else { | 293 } else { |
297 this.fire('change-route-source-click', { | 294 this.fire('change-route-source-click', { |
298 route: this.route, | 295 route: this.route, |
299 selectedCastMode: | 296 selectedCastMode: |
300 this.computeSelectedCastMode_(this.shownCastModeValue, this.sink) | 297 this.computeSelectedCastMode_(this.shownCastModeValue, this.sink) |
301 }); | 298 }); |
302 } | 299 } |
303 }, | 300 }, |
304 }); | 301 }); |
OLD | NEW |