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

Side by Side Diff: chrome/browser/resources/media_router/media_router_ui_interface.js

Issue 2725503002: [Media Router] Custom Controls 4 - Implement details view WebUI (Closed)
Patch Set: Address Mark's comments Created 3 years, 7 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 // API invoked by the browser MediaRouterWebUIMessageHandler to communicate 5 // API invoked by the browser MediaRouterWebUIMessageHandler to communicate
6 // with this UI. 6 // with this UI.
7 cr.define('media_router.ui', function() { 7 cr.define('media_router.ui', function() {
8 'use strict'; 8 'use strict';
9 9
10 // The media-router-container element. 10 // The media-router-container element.
11 var container = null; 11 var container = null;
12 12
13 // The media-router-header element. 13 // The media-router-header element.
14 var header = null; 14 var header = null;
15 15
16 // The route-controls element. Is null if the route details view isn't open.
17 var routeControls = null;
18
16 /** 19 /**
17 * Handles response of previous create route attempt. 20 * Handles response of previous create route attempt.
18 * 21 *
19 * @param {string} sinkId The ID of the sink to which the Media Route was 22 * @param {string} sinkId The ID of the sink to which the Media Route was
20 * creating a route. 23 * creating a route.
21 * @param {?media_router.Route} route The newly created route that 24 * @param {?media_router.Route} route The newly created route that
22 * corresponds to the sink if route creation succeeded; null otherwise. 25 * corresponds to the sink if route creation succeeded; null otherwise.
23 * @param {boolean} isForDisplay Whether or not |route| is for display. 26 * @param {boolean} isForDisplay Whether or not |route| is for display.
24 */ 27 */
25 function onCreateRouteResponseReceived(sinkId, route, isForDisplay) { 28 function onCreateRouteResponseReceived(sinkId, route, isForDisplay) {
26 container.onCreateRouteResponseReceived(sinkId, route, isForDisplay); 29 container.onCreateRouteResponseReceived(sinkId, route, isForDisplay);
27 } 30 }
28 31
29 /** 32 /**
33 * Called when the route controller for the route that is currently selected
34 * is invalidated.
35 */
36 function onRouteControllerInvalidated() {
37 container.onRouteControllerInvalidated();
imcheng 2017/05/05 21:36:41 Do you need to set routeControls to null here?
takumif 2017/05/09 00:14:57 We already do that in RouteControls.reset(), altho
38 }
39
40 /**
30 * Handles the search response by forwarding |sinkId| to the container. 41 * Handles the search response by forwarding |sinkId| to the container.
31 * 42 *
32 * @param {string} sinkId The ID of the sink found by search. 43 * @param {string} sinkId The ID of the sink found by search.
33 */ 44 */
34 function receiveSearchResult(sinkId) { 45 function receiveSearchResult(sinkId) {
35 container.onReceiveSearchResult(sinkId); 46 container.onReceiveSearchResult(sinkId);
36 } 47 }
37 48
38 /** 49 /**
39 * Sets the cast mode list. 50 * Sets the cast mode list.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 * }, 109 * },
99 * routes: !Array<!media_router.Route>, 110 * routes: !Array<!media_router.Route>,
100 * castModes: !Array<!media_router.CastMode>, 111 * castModes: !Array<!media_router.CastMode>,
101 * useTabMirroring: boolean}} data 112 * useTabMirroring: boolean}} data
102 * Parameters in data: 113 * Parameters in data:
103 * deviceMissingUrl - url to be opened on "Device missing?" clicked. 114 * deviceMissingUrl - url to be opened on "Device missing?" clicked.
104 * sinksAndIdentity - list of sinks to be displayed and user identity. 115 * sinksAndIdentity - list of sinks to be displayed and user identity.
105 * routes - list of routes that are associated with the sinks. 116 * routes - list of routes that are associated with the sinks.
106 * castModes - list of available cast modes. 117 * castModes - list of available cast modes.
107 * useTabMirroring - whether the cast mode should be set to TAB_MIRROR. 118 * useTabMirroring - whether the cast mode should be set to TAB_MIRROR.
119 * useNewRouteControls - whether the new WebUI route controls should be
120 * used.
108 */ 121 */
109 function setInitialData(data) { 122 function setInitialData(data) {
110 container.deviceMissingUrl = data['deviceMissingUrl']; 123 container.deviceMissingUrl = data['deviceMissingUrl'];
111 container.castModeList = data['castModes']; 124 container.castModeList = data['castModes'];
112 this.setSinkListAndIdentity(data['sinksAndIdentity']); 125 this.setSinkListAndIdentity(data['sinksAndIdentity']);
113 container.routeList = data['routes']; 126 container.routeList = data['routes'];
114 container.maybeShowRouteDetailsOnOpen(); 127 container.maybeShowRouteDetailsOnOpen();
115 if (data['useTabMirroring']) 128 if (data['useTabMirroring'])
116 container.selectCastMode(media_router.CastModeType.TAB_MIRROR); 129 container.selectCastMode(media_router.CastModeType.TAB_MIRROR);
130 container.useWebUiRouteControls = data['useNewRouteControls'];
117 media_router.browserApi.onInitialDataReceived(); 131 media_router.browserApi.onInitialDataReceived();
118 } 132 }
119 133
120 /** 134 /**
121 * Sets current issue to |issue|, or clears the current issue if |issue| is 135 * Sets current issue to |issue|, or clears the current issue if |issue| is
122 * null. 136 * null.
123 * 137 *
124 * @param {?media_router.Issue} issue 138 * @param {?media_router.Issue} issue
125 */ 139 */
126 function setIssue(issue) { 140 function setIssue(issue) {
127 container.issue = issue; 141 container.issue = issue;
128 } 142 }
129 143
130 /** 144 /**
145 * Sets |routeControls|. The argument may be null if the route details view is
146 * getting closed.
147 *
148 * @param {?MediaRouterRouteControlsElement} mediaRouterRouteControls
149 */
150 function setRouteControls(mediaRouterRouteControls) {
151 routeControls = mediaRouterRouteControls;
152 }
153
154 /**
131 * Sets the list of currently active routes. 155 * Sets the list of currently active routes.
132 * 156 *
133 * @param {!Array<!media_router.Route>} routeList 157 * @param {!Array<!media_router.Route>} routeList
134 */ 158 */
135 function setRouteList(routeList) { 159 function setRouteList(routeList) {
136 container.routeList = routeList; 160 container.routeList = routeList;
137 } 161 }
138 162
139 /** 163 /**
140 * Sets the list of discovered sinks along with properties of whether to hide 164 * Sets the list of discovered sinks along with properties of whether to hide
(...skipping 18 matching lines...) Expand all
159 183
160 /** 184 /**
161 * Updates the max height of the dialog 185 * Updates the max height of the dialog
162 * 186 *
163 * @param {number} height 187 * @param {number} height
164 */ 188 */
165 function updateMaxHeight(height) { 189 function updateMaxHeight(height) {
166 container.updateMaxDialogHeight(height); 190 container.updateMaxDialogHeight(height);
167 } 191 }
168 192
193 /**
194 * Updates the route status shown in the route controls.
195 *
196 * @param {!media_router.RouteStatus} status
197 */
198 function updateRouteStatus(status) {
199 if (routeControls)
200 routeControls.routeStatus = status;
201 }
202
169 return { 203 return {
170 onCreateRouteResponseReceived: onCreateRouteResponseReceived, 204 onCreateRouteResponseReceived: onCreateRouteResponseReceived,
205 onRouteControllerInvalidated: onRouteControllerInvalidated,
171 receiveSearchResult: receiveSearchResult, 206 receiveSearchResult: receiveSearchResult,
172 setCastModeList: setCastModeList, 207 setCastModeList: setCastModeList,
173 setElements: setElements, 208 setElements: setElements,
174 setFirstRunFlowData: setFirstRunFlowData, 209 setFirstRunFlowData: setFirstRunFlowData,
175 setInitialData: setInitialData, 210 setInitialData: setInitialData,
176 setIssue: setIssue, 211 setIssue: setIssue,
212 setRouteControls: setRouteControls,
177 setRouteList: setRouteList, 213 setRouteList: setRouteList,
178 setSinkListAndIdentity: setSinkListAndIdentity, 214 setSinkListAndIdentity: setSinkListAndIdentity,
179 updateMaxHeight: updateMaxHeight, 215 updateMaxHeight: updateMaxHeight,
216 updateRouteStatus: updateRouteStatus,
180 }; 217 };
181 }); 218 });
182 219
183 // API invoked by this UI to communicate with the browser WebUI message handler. 220 // API invoked by this UI to communicate with the browser WebUI message handler.
184 cr.define('media_router.browserApi', function() { 221 cr.define('media_router.browserApi', function() {
185 'use strict'; 222 'use strict';
186 223
187 /** 224 /**
188 * Indicates that the user has acknowledged the first run flow. 225 * Indicates that the user has acknowledged the first run flow.
189 * 226 *
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 285 }
249 286
250 /** 287 /**
251 * Indicates that the initial data has been received. 288 * Indicates that the initial data has been received.
252 */ 289 */
253 function onInitialDataReceived() { 290 function onInitialDataReceived() {
254 chrome.send('onInitialDataReceived'); 291 chrome.send('onInitialDataReceived');
255 } 292 }
256 293
257 /** 294 /**
295 * Reports that the route details view was closed.
296 */
297 function onMediaControllerClosed() {
298 chrome.send('onMediaControllerClosed');
299 }
300
301 /**
302 * Reports that the route details view was opened for |routeId|.
303 *
304 * @param {string} routeId
305 */
306 function onMediaControllerAvailable(routeId) {
307 chrome.send('onMediaControllerAvailable', [{routeId: routeId}]);
308 }
309
310 /**
311 * Sends a command to pause the route shown in the route details view.
312 */
313 function pauseCurrentMedia() {
314 chrome.send('pauseCurrentMedia');
315 }
316
317 /**
318 * Sends a command to play the route shown in the route details view.
319 */
320 function playCurrentMedia() {
321 chrome.send('playCurrentMedia');
322 }
323
324 /**
258 * Reports when the user clicks outside the dialog. 325 * Reports when the user clicks outside the dialog.
259 */ 326 */
260 function reportBlur() { 327 function reportBlur() {
261 chrome.send('reportBlur'); 328 chrome.send('reportBlur');
262 } 329 }
263 330
264 /** 331 /**
265 * Reports the index of the selected sink. 332 * Reports the index of the selected sink.
266 * 333 *
267 * @param {number} sinkIndex 334 * @param {number} sinkIndex
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 */ 461 */
395 function searchSinksAndCreateRoute( 462 function searchSinksAndCreateRoute(
396 sinkId, searchCriteria, domain, selectedCastMode) { 463 sinkId, searchCriteria, domain, selectedCastMode) {
397 chrome.send('searchSinksAndCreateRoute', 464 chrome.send('searchSinksAndCreateRoute',
398 [{sinkId: sinkId, 465 [{sinkId: sinkId,
399 searchCriteria: searchCriteria, 466 searchCriteria: searchCriteria,
400 domain: domain, 467 domain: domain,
401 selectedCastMode: selectedCastMode}]); 468 selectedCastMode: selectedCastMode}]);
402 } 469 }
403 470
471 /**
472 * Sends a command to seek the route shown in the route details view.
473 *
474 * @param {number} time The new current time in seconds.
475 */
476 function seekCurrentMedia(time) {
477 chrome.send('seekCurrentMedia', [{time: time}]);
478 }
479
480 /**
481 * Sends a command to mute or unmute the route shown in the route details
482 * view.
483 *
484 * @param {boolean} mute Mute the route if true, unmute it if false.
485 */
486 function setCurrentMediaMute(mute) {
487 chrome.send('setCurrentMediaMute', [{mute: mute}]);
488 }
489
490 /**
491 * Sends a command to change the volume of the route shown in the route
492 * details view.
493 *
494 * @param {number} volume The volume between 0 and 1.
495 */
496 function setCurrentMediaVolume(volume) {
497 chrome.send('setCurrentMediaVolume', [{volume: volume}]);
498 }
499
404 return { 500 return {
405 acknowledgeFirstRunFlow: acknowledgeFirstRunFlow, 501 acknowledgeFirstRunFlow: acknowledgeFirstRunFlow,
406 actOnIssue: actOnIssue, 502 actOnIssue: actOnIssue,
407 changeRouteSource: changeRouteSource, 503 changeRouteSource: changeRouteSource,
408 closeDialog: closeDialog, 504 closeDialog: closeDialog,
409 closeRoute: closeRoute, 505 closeRoute: closeRoute,
410 joinRoute: joinRoute, 506 joinRoute: joinRoute,
411 onInitialDataReceived: onInitialDataReceived, 507 onInitialDataReceived: onInitialDataReceived,
508 onMediaControllerClosed: onMediaControllerClosed,
509 onMediaControllerAvailable: onMediaControllerAvailable,
510 pauseCurrentMedia: pauseCurrentMedia,
511 playCurrentMedia: playCurrentMedia,
412 reportBlur: reportBlur, 512 reportBlur: reportBlur,
413 reportClickedSinkIndex: reportClickedSinkIndex, 513 reportClickedSinkIndex: reportClickedSinkIndex,
414 reportFilter: reportFilter, 514 reportFilter: reportFilter,
415 reportInitialAction: reportInitialAction, 515 reportInitialAction: reportInitialAction,
416 reportInitialState: reportInitialState, 516 reportInitialState: reportInitialState,
417 reportNavigateToView: reportNavigateToView, 517 reportNavigateToView: reportNavigateToView,
418 reportRouteCreation: reportRouteCreation, 518 reportRouteCreation: reportRouteCreation,
419 reportRouteCreationOutcome: reportRouteCreationOutcome, 519 reportRouteCreationOutcome: reportRouteCreationOutcome,
420 reportSelectedCastMode: reportSelectedCastMode, 520 reportSelectedCastMode: reportSelectedCastMode,
421 reportSinkCount: reportSinkCount, 521 reportSinkCount: reportSinkCount,
422 reportTimeToClickSink: reportTimeToClickSink, 522 reportTimeToClickSink: reportTimeToClickSink,
423 reportTimeToInitialActionClose: reportTimeToInitialActionClose, 523 reportTimeToInitialActionClose: reportTimeToInitialActionClose,
424 requestInitialData: requestInitialData, 524 requestInitialData: requestInitialData,
425 requestRoute: requestRoute, 525 requestRoute: requestRoute,
426 searchSinksAndCreateRoute: searchSinksAndCreateRoute, 526 searchSinksAndCreateRoute: searchSinksAndCreateRoute,
527 seekCurrentMedia: seekCurrentMedia,
528 setCurrentMediaMute: setCurrentMediaMute,
529 setCurrentMediaVolume: setCurrentMediaVolume,
427 }; 530 };
428 }); 531 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698