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

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: Fix a test 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();
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 * useTabMirroring - whether the cast mode should be set to TAB_MIRROR. 118 * useTabMirroring - whether the cast mode should be set to TAB_MIRROR.
108 */ 119 */
109 function setInitialData(data) { 120 function setInitialData(data) {
110 container.deviceMissingUrl = data['deviceMissingUrl']; 121 container.deviceMissingUrl = data['deviceMissingUrl'];
111 container.castModeList = data['castModes']; 122 container.castModeList = data['castModes'];
112 this.setSinkListAndIdentity(data['sinksAndIdentity']); 123 this.setSinkListAndIdentity(data['sinksAndIdentity']);
113 container.routeList = data['routes']; 124 container.routeList = data['routes'];
114 container.maybeShowRouteDetailsOnOpen(); 125 container.maybeShowRouteDetailsOnOpen();
115 if (data['useTabMirroring']) 126 if (data['useTabMirroring'])
116 container.selectCastMode(media_router.CastModeType.TAB_MIRROR); 127 container.selectCastMode(media_router.CastModeType.TAB_MIRROR);
128 container.useNewRouteControls = data['useNewRouteControls'];
117 media_router.browserApi.onInitialDataReceived(); 129 media_router.browserApi.onInitialDataReceived();
118 } 130 }
119 131
120 /** 132 /**
121 * Sets current issue to |issue|, or clears the current issue if |issue| is 133 * Sets current issue to |issue|, or clears the current issue if |issue| is
122 * null. 134 * null.
123 * 135 *
124 * @param {?media_router.Issue} issue 136 * @param {?media_router.Issue} issue
125 */ 137 */
126 function setIssue(issue) { 138 function setIssue(issue) {
127 container.issue = issue; 139 container.issue = issue;
128 } 140 }
129 141
130 /** 142 /**
143 * Sets |routeControls|. The argument may be null if the route details view is
144 * getting closed.
145 *
146 * @param {?MediaRouterRouteControlsElement} mediaRouterRouteControls
147 */
148 function setRouteControls(mediaRouterRouteControls) {
149 routeControls = mediaRouterRouteControls;
150 }
151
152 /**
131 * Sets the list of currently active routes. 153 * Sets the list of currently active routes.
132 * 154 *
133 * @param {!Array<!media_router.Route>} routeList 155 * @param {!Array<!media_router.Route>} routeList
134 */ 156 */
135 function setRouteList(routeList) { 157 function setRouteList(routeList) {
136 container.routeList = routeList; 158 container.routeList = routeList;
137 } 159 }
138 160
139 /** 161 /**
140 * Sets the list of discovered sinks along with properties of whether to hide 162 * Sets the list of discovered sinks along with properties of whether to hide
(...skipping 18 matching lines...) Expand all
159 181
160 /** 182 /**
161 * Updates the max height of the dialog 183 * Updates the max height of the dialog
162 * 184 *
163 * @param {number} height 185 * @param {number} height
164 */ 186 */
165 function updateMaxHeight(height) { 187 function updateMaxHeight(height) {
166 container.updateMaxDialogHeight(height); 188 container.updateMaxDialogHeight(height);
167 } 189 }
168 190
191 /**
192 * Updates the route status shown in the route controls.
193 *
194 * @param {!media_router.RouteStatus} status
195 */
196 function updateRouteStatus(status) {
197 if (routeControls)
198 routeControls.updateRouteStatus(status);
199 }
200
169 return { 201 return {
170 onCreateRouteResponseReceived: onCreateRouteResponseReceived, 202 onCreateRouteResponseReceived: onCreateRouteResponseReceived,
203 onRouteControllerInvalidated: onRouteControllerInvalidated,
171 receiveSearchResult: receiveSearchResult, 204 receiveSearchResult: receiveSearchResult,
172 setCastModeList: setCastModeList, 205 setCastModeList: setCastModeList,
173 setElements: setElements, 206 setElements: setElements,
174 setFirstRunFlowData: setFirstRunFlowData, 207 setFirstRunFlowData: setFirstRunFlowData,
175 setInitialData: setInitialData, 208 setInitialData: setInitialData,
176 setIssue: setIssue, 209 setIssue: setIssue,
210 setRouteControls: setRouteControls,
177 setRouteList: setRouteList, 211 setRouteList: setRouteList,
178 setSinkListAndIdentity: setSinkListAndIdentity, 212 setSinkListAndIdentity: setSinkListAndIdentity,
179 updateMaxHeight: updateMaxHeight, 213 updateMaxHeight: updateMaxHeight,
214 updateRouteStatus: updateRouteStatus,
180 }; 215 };
181 }); 216 });
182 217
183 // API invoked by this UI to communicate with the browser WebUI message handler. 218 // API invoked by this UI to communicate with the browser WebUI message handler.
184 cr.define('media_router.browserApi', function() { 219 cr.define('media_router.browserApi', function() {
185 'use strict'; 220 'use strict';
186 221
187 /** 222 /**
188 * Indicates that the user has acknowledged the first run flow. 223 * Indicates that the user has acknowledged the first run flow.
189 * 224 *
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 283 }
249 284
250 /** 285 /**
251 * Indicates that the initial data has been received. 286 * Indicates that the initial data has been received.
252 */ 287 */
253 function onInitialDataReceived() { 288 function onInitialDataReceived() {
254 chrome.send('onInitialDataReceived'); 289 chrome.send('onInitialDataReceived');
255 } 290 }
256 291
257 /** 292 /**
293 * Reports that the route details view was closed.
294 */
295 function onMediaControllerClosed() {
296 chrome.send('onMediaControllerClosed');
297 }
298
299 /**
300 * Reports that the route details view was opened for |routeId|.
301 *
302 * @param {string} routeId
303 */
304 function onMediaControllerAvailable(routeId) {
305 chrome.send('onMediaControllerAvailable', [{routeId: routeId}]);
306 }
307
308 /**
309 * Sends a command to pause the route shown in the route details view.
310 */
311 function pauseCurrentMedia() {
312 chrome.send('pauseCurrentMedia');
313 }
314
315 /**
316 * Sends a command to play the route shown in the route details view.
317 */
318 function playCurrentMedia() {
319 chrome.send('playCurrentMedia');
320 }
321
322 /**
258 * Reports when the user clicks outside the dialog. 323 * Reports when the user clicks outside the dialog.
259 */ 324 */
260 function reportBlur() { 325 function reportBlur() {
261 chrome.send('reportBlur'); 326 chrome.send('reportBlur');
262 } 327 }
263 328
264 /** 329 /**
265 * Reports the index of the selected sink. 330 * Reports the index of the selected sink.
266 * 331 *
267 * @param {number} sinkIndex 332 * @param {number} sinkIndex
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 */ 459 */
395 function searchSinksAndCreateRoute( 460 function searchSinksAndCreateRoute(
396 sinkId, searchCriteria, domain, selectedCastMode) { 461 sinkId, searchCriteria, domain, selectedCastMode) {
397 chrome.send('searchSinksAndCreateRoute', 462 chrome.send('searchSinksAndCreateRoute',
398 [{sinkId: sinkId, 463 [{sinkId: sinkId,
399 searchCriteria: searchCriteria, 464 searchCriteria: searchCriteria,
400 domain: domain, 465 domain: domain,
401 selectedCastMode: selectedCastMode}]); 466 selectedCastMode: selectedCastMode}]);
402 } 467 }
403 468
469 /**
470 * Sends a command to seek the route shown in the route details view.
471 *
472 * @param {number} time The new current time in seconds.
473 */
474 function seekCurrentMedia(time) {
475 chrome.send('seekCurrentMedia', [{time: time}]);
476 }
477
478 /**
479 * Sends a command to mute or unmute the route shown in the route details
480 * view.
481 *
482 * @param {boolean} mute Mute the route if true, unmute it if false.
483 */
484 function setCurrentMediaMute(mute) {
485 chrome.send('setCurrentMediaMute', [{mute: mute}]);
486 }
487
488 /**
489 * Sends a command to change the volume of the route shown in the route
490 * details view.
491 *
492 * @param {number} volume The volume between 0 and 1.
493 */
494 function setCurrentMediaVolume(volume) {
495 chrome.send('setCurrentMediaVolume', [{volume: volume}]);
496 }
497
404 return { 498 return {
405 acknowledgeFirstRunFlow: acknowledgeFirstRunFlow, 499 acknowledgeFirstRunFlow: acknowledgeFirstRunFlow,
406 actOnIssue: actOnIssue, 500 actOnIssue: actOnIssue,
407 changeRouteSource: changeRouteSource, 501 changeRouteSource: changeRouteSource,
408 closeDialog: closeDialog, 502 closeDialog: closeDialog,
409 closeRoute: closeRoute, 503 closeRoute: closeRoute,
410 joinRoute: joinRoute, 504 joinRoute: joinRoute,
411 onInitialDataReceived: onInitialDataReceived, 505 onInitialDataReceived: onInitialDataReceived,
506 onMediaControllerClosed: onMediaControllerClosed,
507 onMediaControllerAvailable: onMediaControllerAvailable,
508 pauseCurrentMedia: pauseCurrentMedia,
509 playCurrentMedia: playCurrentMedia,
412 reportBlur: reportBlur, 510 reportBlur: reportBlur,
413 reportClickedSinkIndex: reportClickedSinkIndex, 511 reportClickedSinkIndex: reportClickedSinkIndex,
414 reportFilter: reportFilter, 512 reportFilter: reportFilter,
415 reportInitialAction: reportInitialAction, 513 reportInitialAction: reportInitialAction,
416 reportInitialState: reportInitialState, 514 reportInitialState: reportInitialState,
417 reportNavigateToView: reportNavigateToView, 515 reportNavigateToView: reportNavigateToView,
418 reportRouteCreation: reportRouteCreation, 516 reportRouteCreation: reportRouteCreation,
419 reportRouteCreationOutcome: reportRouteCreationOutcome, 517 reportRouteCreationOutcome: reportRouteCreationOutcome,
420 reportSelectedCastMode: reportSelectedCastMode, 518 reportSelectedCastMode: reportSelectedCastMode,
421 reportSinkCount: reportSinkCount, 519 reportSinkCount: reportSinkCount,
422 reportTimeToClickSink: reportTimeToClickSink, 520 reportTimeToClickSink: reportTimeToClickSink,
423 reportTimeToInitialActionClose: reportTimeToInitialActionClose, 521 reportTimeToInitialActionClose: reportTimeToInitialActionClose,
424 requestInitialData: requestInitialData, 522 requestInitialData: requestInitialData,
425 requestRoute: requestRoute, 523 requestRoute: requestRoute,
426 searchSinksAndCreateRoute: searchSinksAndCreateRoute, 524 searchSinksAndCreateRoute: searchSinksAndCreateRoute,
525 seekCurrentMedia: seekCurrentMedia,
526 setCurrentMediaMute: setCurrentMediaMute,
527 setCurrentMediaVolume: setCurrentMediaVolume,
427 }; 528 };
428 }); 529 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698