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

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

Issue 2040883002: [Media Router] Assign each route a current cast mode if possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use current cast mode for display routes, simplify sink launching for route details 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. 20 * Whether the external container will accept replace-route-click events.
31 * @type {boolean} 21 * @private {boolean}
32 */ 22 */
33 replaceRouteAvailable: { 23 replaceRouteAvailable_: {
34 type: Boolean, 24 type: Boolean,
35 value: true, 25 computed: 'computeReplaceRouteAvailable_(route, sink,' +
26 'sinkCurrentlyLaunching, shownCastModeValue)',
36 }, 27 },
37 28
38 /** 29 /**
39 * The route to show. 30 * The route to show.
40 * @type {?media_router.Route|undefined} 31 * @type {?media_router.Route|undefined}
41 */ 32 */
42 route: { 33 route: {
43 type: Object, 34 type: Object,
44 observer: 'maybeLoadCustomController_', 35 observer: 'maybeLoadCustomController_',
45 }, 36 },
46 37
47 /** 38 /**
39 * The cast mode shown to the user. Initially set to auto mode. (See
40 * media_router.CastMode documentation for details on auto mode.)
41 * @type {number}
42 */
43 shownCastModeValue: {
44 type: Number,
45 value: media_router.AUTO_CAST_MODE.type,
46 },
47
48 /**
49 * Sink associated with |route|.
50 * @type {?media_router.Sink}
51 */
52 sink: {
53 type: Object,
54 value: null,
55 },
56
57 /**
58 * Whether a sink is currently launching in the container.
59 * @type {boolean}
60 */
61 sinkCurrentlyLaunching: {
apacible 2016/06/07 12:13:42 nit: Rename as something like, |isAnySinkCurrently
btolsch 2016/06/07 19:45:34 Done.
62 type: Boolean,
63 value: false,
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} sinkCurrentlyLaunching Whether a sink is launching now.
107 * @param {number} shownCastModeValue Currently selected cast mode value or
108 * AUTO if no value has been explicitly selected.
109 * @return {boolean} Whether the replace route function should be available
110 * when displaying |currentRoute| in the route details view. Replace route
111 * should not be available when the source that would be cast from when
112 * creating a new route would be the same as the route's current source.
113 * @private
114 */
115 computeReplaceRouteAvailable_: function(
116 route, sink, sinkCurrentlyLaunching, shownCastModeValue) {
117 if (sinkCurrentlyLaunching || !route || !sink) {
118 return false;
119 }
120 if (!route.currentCastMode) {
121 return true;
122 }
123 var selectedCastMode = shownCastModeValue;
124 if (selectedCastMode == media_router.CastModeType.AUTO) {
125 selectedCastMode = sink.castModes & -sink.castModes;
126 }
127 return (selectedCastMode & sink.castModes) &&
128 (selectedCastMode != route.currentCastMode);
129 },
130
131 /**
87 * Fires a join-route-click event if the current route is joinable, otherwise 132 * 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 133 * 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 134 * 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. 135 * button to start casting to the current route is clicked.
91 * 136 *
92 * @private 137 * @private
93 */ 138 */
94 startCastingToRoute_: function() { 139 startCastingToRoute_: function() {
95 if (this.route.canJoin) { 140 if (this.route.canJoin) {
96 this.fire('join-route-click', {route: this.route}); 141 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) 174 extensionview.load(this.route.customControllerPath)
130 .then(function() { 175 .then(function() {
131 // Load was successful; show the custom controller. 176 // Load was successful; show the custom controller.
132 that.isCustomControllerHidden_ = false; 177 that.isCustomControllerHidden_ = false;
133 }, function() { 178 }, function() {
134 // Load was unsuccessful; fall back to default view. 179 // Load was unsuccessful; fall back to default view.
135 that.isCustomControllerHidden_ = true; 180 that.isCustomControllerHidden_ = true;
136 }); 181 });
137 }, 182 },
138 }); 183 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698