Chromium Code Reviews| 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: { |
| 11 /** | 11 /** |
| 12 * The text for the current casting activity status. | 12 * The text for the current casting activity status. |
| 13 * @private {string|undefined} | 13 * @private {string|undefined} |
| 14 */ | 14 */ |
| 15 activityStatus_: { | 15 activityStatus_: { |
| 16 type: String, | 16 type: String, |
| 17 }, | 17 }, |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * Bitmask of available cast modes compatible with the sink of the current | |
| 21 * route. | |
| 22 * @type {number} | |
| 23 */ | |
| 24 availableCastModes: { | |
| 25 type: Number, | |
| 26 value: 0, | |
| 27 }, | |
| 28 | |
| 29 /** | |
| 20 * The route to show. | 30 * The route to show. |
| 21 * @type {?media_router.Route|undefined} | 31 * @type {?media_router.Route|undefined} |
| 22 */ | 32 */ |
| 23 route: { | 33 route: { |
| 24 type: Object, | 34 type: Object, |
| 25 observer: 'maybeLoadCustomController_', | 35 observer: 'maybeLoadCustomController_', |
| 26 }, | 36 }, |
| 27 | 37 |
| 28 /** | 38 /** |
| 29 * Whether the custom controller should be hidden. | 39 * Whether the custom controller should be hidden. |
| 30 * A custom controller is shown iff |route| specifies customControllerPath | 40 * A custom controller is shown iff |route| specifies customControllerPath |
| 31 * and the view can be loaded. | 41 * and the view can be loaded. |
| 32 * @private {boolean} | 42 * @private {boolean} |
| 33 */ | 43 */ |
| 34 isCustomControllerHidden_: { | 44 isCustomControllerHidden_: { |
| 35 type: Boolean, | 45 type: Boolean, |
| 36 value: true, | 46 value: true, |
| 37 }, | 47 }, |
| 38 }, | 48 }, |
| 39 | 49 |
| 40 behaviors: [ | 50 behaviors: [ |
| 41 I18nBehavior, | 51 I18nBehavior, |
| 42 ], | 52 ], |
| 43 | 53 |
| 44 /** | 54 /** |
| 45 * Fires a close-route-click event. This is called when the button to close | 55 * Fires a close-route event. This is called when the button to close |
| 46 * the current route is clicked. | 56 * the current route is clicked. |
| 47 * | 57 * |
| 48 * @private | 58 * @private |
| 49 */ | 59 */ |
| 50 closeRoute_: function() { | 60 closeRoute_: function() { |
| 51 this.fire('close-route-click', {route: this.route}); | 61 this.fire('close-route', {route: this.route}); |
| 52 }, | 62 }, |
| 53 | 63 |
| 54 /** | 64 /** |
| 55 * Fires a start-casting-to-route-click event. This is called when the button | 65 * @param {?media_router.Route|undefined} route |
| 56 * to start casting to the current route is clicked. | 66 * @param {number} availableCastModes |
| 67 * @return {boolean} Whether to show the button that allows casting to the | |
| 68 * current route or the current route's sink. | |
| 69 */ | |
| 70 computeCastButtonHidden_: function(route, availableCastModes) { | |
| 71 return !(route && route.canJoin) && !availableCastModes; | |
|
mark a. foltz
2016/05/31 22:30:06
Can you use || here instead?
btolsch
2016/06/01 01:58:16
Maybe I'm misunderstanding the suggestion but sayi
| |
| 72 }, | |
| 73 | |
| 74 /** | |
| 75 * Fires a join-route-click event if the current route is joinable, otherwise | |
| 76 * it fires a cast-new-media-click event, which stops the current route and | |
| 77 * immediately launches a new route to the same sink. This is called when the | |
| 78 * button to start casting to the current route is clicked. | |
| 57 * | 79 * |
| 58 * @private | 80 * @private |
| 59 */ | 81 */ |
| 60 startCastingToRoute_: function() { | 82 startCastingToRoute_: function() { |
| 61 this.fire('start-casting-to-route-click', {route: this.route}); | 83 if (this.route.canJoin) { |
| 84 this.fire('join-route-click', {route: this.route}); | |
| 85 } else { | |
| 86 this.fire('cast-new-media-click', {route: this.route}); | |
|
mark a. foltz
2016/05/31 22:30:06
Slight preference for replace-route-click, but I d
btolsch
2016/06/01 01:58:16
Done.
| |
| 87 } | |
| 62 }, | 88 }, |
| 63 | 89 |
| 64 /** | 90 /** |
| 65 * Loads the custom controller if |route.customControllerPath| exists. | 91 * Loads the custom controller if |route.customControllerPath| exists. |
| 66 * Falls back to the default route details view otherwise, or if load fails. | 92 * Falls back to the default route details view otherwise, or if load fails. |
| 67 * Updates |activityStatus_| for the default view. | 93 * Updates |activityStatus_| for the default view. |
| 68 * | 94 * |
| 69 * @private | 95 * @private |
| 70 */ | 96 */ |
| 71 maybeLoadCustomController_: function() { | 97 maybeLoadCustomController_: function() { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 91 extensionview.load(this.route.customControllerPath) | 117 extensionview.load(this.route.customControllerPath) |
| 92 .then(function() { | 118 .then(function() { |
| 93 // Load was successful; show the custom controller. | 119 // Load was successful; show the custom controller. |
| 94 that.isCustomControllerHidden_ = false; | 120 that.isCustomControllerHidden_ = false; |
| 95 }, function() { | 121 }, function() { |
| 96 // Load was unsuccessful; fall back to default view. | 122 // Load was unsuccessful; fall back to default view. |
| 97 that.isCustomControllerHidden_ = true; | 123 that.isCustomControllerHidden_ = true; |
| 98 }); | 124 }); |
| 99 }, | 125 }, |
| 100 }); | 126 }); |
| OLD | NEW |