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

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

Issue 2068593002: [Media Router] Assign each route a current cast mode if possible (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 20 * Whether a sink is currently launching in the container.
21 * route. 21 * @type {boolean}
22 * @type {number}
23 */ 22 */
24 availableCastModes: { 23 isAnySinkCurrentlyLaunching: {
25 type: Number, 24 type: Boolean,
26 value: 0, 25 value: false,
27 }, 26 },
28 27
29 /** 28 /**
30 * Whether the external container will accept replace-route-click events. 29 * Whether the external container will accept replace-route-click events.
31 * @type {boolean} 30 * @private {boolean}
32 */ 31 */
33 replaceRouteAvailable: { 32 replaceRouteAvailable_: {
34 type: Boolean, 33 type: Boolean,
35 value: true, 34 computed: 'computeReplaceRouteAvailable_(route, sink,' +
35 'isAnySinkCurrentlyLaunching, shownCastModeValue)',
36 }, 36 },
37 37
38 /** 38 /**
39 * The route to show. 39 * The route to show.
40 * @type {?media_router.Route|undefined} 40 * @type {?media_router.Route|undefined}
41 */ 41 */
42 route: { 42 route: {
43 type: Object, 43 type: Object,
44 observer: 'maybeLoadCustomController_', 44 observer: 'maybeLoadCustomController_',
45 }, 45 },
46 46
47 /** 47 /**
48 * The cast mode shown to the user. Initially set to auto mode. (See
49 * media_router.CastMode documentation for details on auto mode.)
50 * @type {number}
51 */
52 shownCastModeValue: {
53 type: Number,
54 value: media_router.AUTO_CAST_MODE.type,
55 },
56
57 /**
58 * Sink associated with |route|.
59 * @type {?media_router.Sink}
60 */
61 sink: {
62 type: Object,
63 value: null,
64 },
65
66 /**
48 * Whether the custom controller should be hidden. 67 * Whether the custom controller should be hidden.
49 * A custom controller is shown iff |route| specifies customControllerPath 68 * A custom controller is shown iff |route| specifies customControllerPath
50 * and the view can be loaded. 69 * and the view can be loaded.
51 * @private {boolean} 70 * @private {boolean}
52 */ 71 */
53 isCustomControllerHidden_: { 72 isCustomControllerHidden_: {
54 type: Boolean, 73 type: Boolean,
55 value: true, 74 value: true,
56 }, 75 },
57 }, 76 },
58 77
59 behaviors: [ 78 behaviors: [
60 I18nBehavior, 79 I18nBehavior,
61 ], 80 ],
62 81
63 /** 82 /**
64 * Fires a close-route event. This is called when the button to close 83 * Fires a close-route event. This is called when the button to close
65 * the current route is clicked. 84 * the current route is clicked.
66 * 85 *
67 * @private 86 * @private
68 */ 87 */
69 closeRoute_: function() { 88 closeRoute_: function() {
70 this.fire('close-route', {route: this.route}); 89 this.fire('close-route', {route: this.route});
71 }, 90 },
72 91
73 /** 92 /**
74 * @param {?media_router.Route|undefined} route 93 * @param {?media_router.Route|undefined} route
75 * @param {number} availableCastModes
76 * @param {boolean} replaceRouteAvailable 94 * @param {boolean} replaceRouteAvailable
77 * @return {boolean} Whether to show the button that allows casting to the 95 * @return {boolean} Whether to show the button that allows casting to the
78 * current route or the current route's sink. 96 * current route or the current route's sink.
79 */ 97 */
80 computeCastButtonHidden_: function( 98 computeCastButtonHidden_: function(route, replaceRouteAvailable) {
81 route, availableCastModes, replaceRouteAvailable) { 99 return !((route && route.canJoin) || replaceRouteAvailable);
82 return !((route && route.canJoin) ||
83 (availableCastModes && replaceRouteAvailable));
84 }, 100 },
85 101
86 /** 102 /**
103 * @param {?media_router.Route|undefined} route The current route for the
104 * route details view.
105 * @param {?media_router.Sink|undefined} sink Sink associated with |route|.
106 * @param {boolean} isAnySinkCurrentlyLaunching Whether a sink is launching
107 * now.
108 * @param {number} shownCastModeValue Currently selected cast mode value or
109 * AUTO if no value has been explicitly selected.
110 * @return {boolean} Whether the replace route function should be available
111 * when displaying |currentRoute| in the route details view. Replace route
112 * should not be available when the source that would be cast from when
113 * creating a new route would be the same as the route's current source.
114 * @private
115 */
116 computeReplaceRouteAvailable_: function(
117 route, sink, isAnySinkCurrentlyLaunching, shownCastModeValue) {
118 if (isAnySinkCurrentlyLaunching || !route || !sink) {
119 return false;
120 }
121 if (!route.currentCastMode) {
122 return true;
123 }
124 var selectedCastMode = shownCastModeValue;
125 if (selectedCastMode == media_router.CastModeType.AUTO) {
126 selectedCastMode = sink.castModes & -sink.castModes;
127 }
128 return ((selectedCastMode & sink.castModes) != 0) &&
129 (selectedCastMode != route.currentCastMode);
130 },
131
132 /**
87 * Fires a join-route-click event if the current route is joinable, otherwise 133 * 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 134 * 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 135 * 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. 136 * button to start casting to the current route is clicked.
91 * 137 *
92 * @private 138 * @private
93 */ 139 */
94 startCastingToRoute_: function() { 140 startCastingToRoute_: function() {
95 if (this.route.canJoin) { 141 if (this.route.canJoin) {
96 this.fire('join-route-click', {route: this.route}); 142 this.fire('join-route-click', {route: this.route});
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 extensionview.load(this.route.customControllerPath) 175 extensionview.load(this.route.customControllerPath)
130 .then(function() { 176 .then(function() {
131 // Load was successful; show the custom controller. 177 // Load was successful; show the custom controller.
132 that.isCustomControllerHidden_ = false; 178 that.isCustomControllerHidden_ = false;
133 }, function() { 179 }, function() {
134 // Load was unsuccessful; fall back to default view. 180 // Load was unsuccessful; fall back to default view.
135 that.isCustomControllerHidden_ = true; 181 that.isCustomControllerHidden_ = true;
136 }); 182 });
137 }, 183 },
138 }); 184 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698