| 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 * Whether the browser is currently incognito. | 30 * Whether the browser is currently incognito. |
| 21 * @type {boolean|undefined} | 31 * @type {boolean|undefined} |
| 22 */ | 32 */ |
| 23 isOffTheRecord: { | 33 isOffTheRecord: { |
| 24 type: Boolean, | 34 type: Boolean, |
| 25 }, | 35 }, |
| 26 | 36 |
| 27 /** | 37 /** |
| 28 * The route to show. | 38 * The route to show. |
| 29 * @type {?media_router.Route|undefined} | 39 * @type {?media_router.Route|undefined} |
| (...skipping 13 matching lines...) Expand all Loading... |
| 43 type: Boolean, | 53 type: Boolean, |
| 44 value: true, | 54 value: true, |
| 45 }, | 55 }, |
| 46 }, | 56 }, |
| 47 | 57 |
| 48 behaviors: [ | 58 behaviors: [ |
| 49 I18nBehavior, | 59 I18nBehavior, |
| 50 ], | 60 ], |
| 51 | 61 |
| 52 /** | 62 /** |
| 53 * Fires a close-route-click event. This is called when the button to close | 63 * Fires a close-route event. This is called when the button to close |
| 54 * the current route is clicked. | 64 * the current route is clicked. |
| 55 * | 65 * |
| 56 * @private | 66 * @private |
| 57 */ | 67 */ |
| 58 closeRoute_: function() { | 68 closeRoute_: function() { |
| 59 this.fire('close-route-click', {route: this.route}); | 69 this.fire('close-route', {route: this.route}); |
| 60 }, | 70 }, |
| 61 | 71 |
| 62 /** | 72 /** |
| 63 * Fires a start-casting-to-route-click event. This is called when the button | 73 * @param {?media_router.Route|undefined} route |
| 64 * to start casting to the current route is clicked. | 74 * @param {number} availableCastModes |
| 75 * @return {boolean} Whether to show the button that allows casting to the |
| 76 * current route or the current route's sink. |
| 77 */ |
| 78 computeCastButtonHidden_: function(route, availableCastModes) { |
| 79 return !(route && route.canJoin) && !availableCastModes; |
| 80 }, |
| 81 |
| 82 /** |
| 83 * Fires a join-route-click event if the current route is joinable, otherwise |
| 84 * it fires a cast-new-media-click event, which stops the current route and |
| 85 * immediately launches a new route to the same sink. This is called when the |
| 86 * button to start casting to the current route is clicked. |
| 65 * | 87 * |
| 66 * @private | 88 * @private |
| 67 */ | 89 */ |
| 68 startCastingToRoute_: function() { | 90 startCastingToRoute_: function() { |
| 69 this.fire('start-casting-to-route-click', {route: this.route}); | 91 if (this.route.canJoin) { |
| 92 this.fire('join-route-click', {route: this.route}); |
| 93 } else { |
| 94 this.fire('cast-new-media-click', {route: this.route}); |
| 95 } |
| 70 }, | 96 }, |
| 71 | 97 |
| 72 /** | 98 /** |
| 73 * Loads the custom controller if |route.customControllerPath| exists. | 99 * Loads the custom controller if |route.customControllerPath| exists. |
| 74 * Falls back to the default route details view otherwise, or if load fails. | 100 * Falls back to the default route details view otherwise, or if load fails. |
| 75 * Updates |activityStatus_| for the default view. | 101 * Updates |activityStatus_| for the default view. |
| 76 * | 102 * |
| 77 * @private | 103 * @private |
| 78 */ | 104 */ |
| 79 maybeLoadCustomController_: function() { | 105 maybeLoadCustomController_: function() { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 100 extensionview.load(this.route.customControllerPath) | 126 extensionview.load(this.route.customControllerPath) |
| 101 .then(function() { | 127 .then(function() { |
| 102 // Load was successful; show the custom controller. | 128 // Load was successful; show the custom controller. |
| 103 that.isCustomControllerHidden_ = false; | 129 that.isCustomControllerHidden_ = false; |
| 104 }, function() { | 130 }, function() { |
| 105 // Load was unsuccessful; fall back to default view. | 131 // Load was unsuccessful; fall back to default view. |
| 106 that.isCustomControllerHidden_ = true; | 132 that.isCustomControllerHidden_ = true; |
| 107 }); | 133 }); |
| 108 }, | 134 }, |
| 109 }); | 135 }); |
| OLD | NEW |