Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: chrome/browser/resources/media_router/elements/route_details/route_details.js

Issue 2062913002: [Media Router] Allow casting new media to sink with existing route. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /**
30 * Whether the external container will accept replace-route-click events.
31 * @type {boolean}
32 */
33 replaceRouteAvailable: {
34 type: Boolean,
35 value: true,
36 },
37
38 /**
20 * The route to show. 39 * The route to show.
21 * @type {?media_router.Route|undefined} 40 * @type {?media_router.Route|undefined}
22 */ 41 */
23 route: { 42 route: {
24 type: Object, 43 type: Object,
25 observer: 'maybeLoadCustomController_', 44 observer: 'maybeLoadCustomController_',
26 }, 45 },
27 46
28 /** 47 /**
29 * Whether the custom controller should be hidden. 48 * Whether the custom controller should be hidden.
30 * A custom controller is shown iff |route| specifies customControllerPath 49 * A custom controller is shown iff |route| specifies customControllerPath
31 * and the view can be loaded. 50 * and the view can be loaded.
32 * @private {boolean} 51 * @private {boolean}
33 */ 52 */
34 isCustomControllerHidden_: { 53 isCustomControllerHidden_: {
35 type: Boolean, 54 type: Boolean,
36 value: true, 55 value: true,
37 }, 56 },
38 }, 57 },
39 58
40 behaviors: [ 59 behaviors: [
41 I18nBehavior, 60 I18nBehavior,
42 ], 61 ],
43 62
44 /** 63 /**
45 * Fires a close-route-click event. This is called when the button to close 64 * Fires a close-route event. This is called when the button to close
46 * the current route is clicked. 65 * the current route is clicked.
47 * 66 *
48 * @private 67 * @private
49 */ 68 */
50 closeRoute_: function() { 69 closeRoute_: function() {
51 this.fire('close-route-click', {route: this.route}); 70 this.fire('close-route', {route: this.route});
52 }, 71 },
53 72
54 /** 73 /**
55 * Fires a start-casting-to-route-click event. This is called when the button 74 * @param {?media_router.Route|undefined} route
56 * to start casting to the current route is clicked. 75 * @param {number} availableCastModes
76 * @param {boolean} replaceRouteAvailable
77 * @return {boolean} Whether to show the button that allows casting to the
78 * current route or the current route's sink.
79 */
80 computeCastButtonHidden_: function(
81 route, availableCastModes, replaceRouteAvailable) {
82 return !((route && route.canJoin) ||
83 (availableCastModes && replaceRouteAvailable));
84 },
85
86 /**
87 * Fires a join-route-click event if the current route is joinable, otherwise
88 * it fires a replace-route-click event, which stops the current route and
89 * immediately launches a new route to the same sink. This is called when the
90 * button to start casting to the current route is clicked.
57 * 91 *
58 * @private 92 * @private
59 */ 93 */
60 startCastingToRoute_: function() { 94 startCastingToRoute_: function() {
61 this.fire('start-casting-to-route-click', {route: this.route}); 95 if (this.route.canJoin) {
96 this.fire('join-route-click', {route: this.route});
97 } else {
98 this.fire('replace-route-click', {route: this.route});
99 }
62 }, 100 },
63 101
64 /** 102 /**
65 * Loads the custom controller if |route.customControllerPath| exists. 103 * Loads the custom controller if |route.customControllerPath| exists.
66 * Falls back to the default route details view otherwise, or if load fails. 104 * Falls back to the default route details view otherwise, or if load fails.
67 * Updates |activityStatus_| for the default view. 105 * Updates |activityStatus_| for the default view.
68 * 106 *
69 * @private 107 * @private
70 */ 108 */
71 maybeLoadCustomController_: function() { 109 maybeLoadCustomController_: function() {
(...skipping 19 matching lines...) Expand all
91 extensionview.load(this.route.customControllerPath) 129 extensionview.load(this.route.customControllerPath)
92 .then(function() { 130 .then(function() {
93 // Load was successful; show the custom controller. 131 // Load was successful; show the custom controller.
94 that.isCustomControllerHidden_ = false; 132 that.isCustomControllerHidden_ = false;
95 }, function() { 133 }, function() {
96 // Load was unsuccessful; fall back to default view. 134 // Load was unsuccessful; fall back to default view.
97 that.isCustomControllerHidden_ = true; 135 that.isCustomControllerHidden_ = true;
98 }); 136 });
99 }, 137 },
100 }); 138 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698