Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // <include src="media_router_data.js"> | 5 // <include src="media_router_data.js"> |
| 6 // <include src="media_router_ui_interface.js"> | 6 // <include src="media_router_ui_interface.js"> |
| 7 | 7 |
| 8 // Handles user events for the Media Router UI. | 8 // Handles user events for the Media Router UI. |
| 9 cr.define('media_router', function() { | 9 cr.define('media_router', function() { |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 /** @type {!MediaRouterHeaderElement} */(container.header)); | 31 /** @type {!MediaRouterHeaderElement} */(container.header)); |
| 32 | 32 |
| 33 container.addEventListener('acknowledge-first-run-flow', | 33 container.addEventListener('acknowledge-first-run-flow', |
| 34 onAcknowledgeFirstRunFlow); | 34 onAcknowledgeFirstRunFlow); |
| 35 container.addEventListener('back-click', onNavigateToSinkList); | 35 container.addEventListener('back-click', onNavigateToSinkList); |
| 36 container.addEventListener('cast-mode-selected', onCastModeSelected); | 36 container.addEventListener('cast-mode-selected', onCastModeSelected); |
| 37 container.addEventListener('change-route-source-click', | 37 container.addEventListener('change-route-source-click', |
| 38 onChangeRouteSourceClick); | 38 onChangeRouteSourceClick); |
| 39 container.addEventListener('close-dialog', onCloseDialog); | 39 container.addEventListener('close-dialog', onCloseDialog); |
| 40 container.addEventListener('close-route', onCloseRoute); | 40 container.addEventListener('close-route', onCloseRoute); |
| 41 container.addEventListener('close-route-details', onRouteDetailsClosed); | |
| 41 container.addEventListener('create-route', onCreateRoute); | 42 container.addEventListener('create-route', onCreateRoute); |
| 42 container.addEventListener('issue-action-click', onIssueActionClick); | 43 container.addEventListener('issue-action-click', onIssueActionClick); |
| 43 container.addEventListener('join-route-click', onJoinRouteClick); | 44 container.addEventListener('join-route-click', onJoinRouteClick); |
| 44 container.addEventListener('navigate-sink-list-to-details', | 45 container.addEventListener('navigate-sink-list-to-details', |
| 45 onNavigateToDetails); | 46 onNavigateToDetails); |
| 46 container.addEventListener('navigate-to-cast-mode-list', | 47 container.addEventListener('navigate-to-cast-mode-list', |
| 47 onNavigateToCastMode); | 48 onNavigateToCastMode); |
| 49 container.addEventListener('open-route-details', onRouteDetailsOpened); | |
| 50 container.addEventListener('pause-route', onPauseRoute); | |
|
imcheng
2017/03/02 02:25:47
While I appreciate the isolation of browser API fr
takumif
2017/03/08 23:34:58
It looks like the layer of event firing is there f
imcheng
2017/03/11 21:57:39
It looks like we should be able to define chrome.b
takumif
2017/03/16 20:16:02
Done.
| |
| 51 container.addEventListener('play-route', onPlayRoute); | |
| 48 container.addEventListener('report-filter', onFilter); | 52 container.addEventListener('report-filter', onFilter); |
| 49 container.addEventListener('report-initial-action', onInitialAction); | 53 container.addEventListener('report-initial-action', onInitialAction); |
| 50 container.addEventListener('report-initial-action-close', | 54 container.addEventListener('report-initial-action-close', |
| 51 onInitialActionClose); | 55 onInitialActionClose); |
| 52 container.addEventListener('report-route-creation', onReportRouteCreation); | 56 container.addEventListener('report-route-creation', onReportRouteCreation); |
| 53 container.addEventListener('report-sink-click-time', | 57 container.addEventListener('report-sink-click-time', |
| 54 onSinkClickTimeReported); | 58 onSinkClickTimeReported); |
| 55 container.addEventListener('report-sink-count', onSinkCountReported); | 59 container.addEventListener('report-sink-count', onSinkCountReported); |
| 56 container.addEventListener('report-resolved-route', | 60 container.addEventListener('report-resolved-route', |
| 57 onReportRouteCreationOutcome); | 61 onReportRouteCreationOutcome); |
| 58 container.addEventListener('request-initial-data', | 62 container.addEventListener('request-initial-data', |
| 59 onRequestInitialData); | 63 onRequestInitialData); |
| 60 container.addEventListener('search-sinks-and-create-route', | 64 container.addEventListener('search-sinks-and-create-route', |
| 61 onSearchSinksAndCreateRoute); | 65 onSearchSinksAndCreateRoute); |
| 66 container.addEventListener('seek-route', onSeekRoute); | |
| 67 container.addEventListener('set-route-volume', onSetRouteVolume); | |
| 62 container.addEventListener('show-initial-state', onShowInitialState); | 68 container.addEventListener('show-initial-state', onShowInitialState); |
| 63 container.addEventListener('sink-click', onSinkClick); | 69 container.addEventListener('sink-click', onSinkClick); |
| 70 container.addEventListener('set-route-mute', onSetRouteMute); | |
| 64 | 71 |
| 65 window.addEventListener('blur', onWindowBlur); | 72 window.addEventListener('blur', onWindowBlur); |
| 66 } | 73 } |
| 67 | 74 |
| 68 /** | 75 /** |
| 69 * Requests that the Media Router searches for a sink with criteria | 76 * Requests that the Media Router searches for a sink with criteria |
| 70 * |event.detail.name|. | 77 * |event.detail.name|. |
| 71 * @param {!Event} event | 78 * @param {!Event} event |
| 72 * Parameters in |event|.detail: | 79 * Parameters in |event|.detail: |
| 73 * id - id of the pseudo sink generating the request. | 80 * id - id of the pseudo sink generating the request. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 * services. | 131 * services. |
| 125 */ | 132 */ |
| 126 function onAcknowledgeFirstRunFlow(event) { | 133 function onAcknowledgeFirstRunFlow(event) { |
| 127 /** @type {{optedIntoCloudServices: boolean}} */ | 134 /** @type {{optedIntoCloudServices: boolean}} */ |
| 128 var detail = event.detail; | 135 var detail = event.detail; |
| 129 media_router.browserApi.acknowledgeFirstRunFlow( | 136 media_router.browserApi.acknowledgeFirstRunFlow( |
| 130 detail.optedIntoCloudServices); | 137 detail.optedIntoCloudServices); |
| 131 } | 138 } |
| 132 | 139 |
| 133 /** | 140 /** |
| 141 * Sends a command to set the volume of the route shown in the route details | |
| 142 * view. Called when the user manipulates the volume slider. | |
| 143 * | |
| 144 * @param {!Event} event | |
| 145 * Parameters in |event|.detail: | |
| 146 * volume - The volume between 0 and 1. | |
| 147 */ | |
| 148 function onSetRouteVolume(event) { | |
| 149 /** @type {{volume: number}} */ | |
| 150 var detail = event.detail; | |
| 151 media_router.browserApi.setRouteVolume(detail.volume); | |
| 152 } | |
| 153 | |
| 154 /** | |
| 134 * Closes the dialog. | 155 * Closes the dialog. |
| 135 * Called when the user clicks the close button on the dialog. Reports | 156 * Called when the user clicks the close button on the dialog. Reports |
| 136 * whether the user closed the dialog via the ESC key. | 157 * whether the user closed the dialog via the ESC key. |
| 137 * | 158 * |
| 138 * @param {!Event} event | 159 * @param {!Event} event |
| 139 * Parameters in |event|.detail: | 160 * Parameters in |event|.detail: |
| 140 * pressEscToClose - whether or not the user pressed ESC to close the | 161 * pressEscToClose - whether or not the user pressed ESC to close the |
| 141 * dialog. | 162 * dialog. |
| 142 */ | 163 */ |
| 143 function onCloseDialog(event) { | 164 function onCloseDialog(event) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 /** | 230 /** |
| 210 * Creates a media route. | 231 * Creates a media route. |
| 211 * Called when the user requests to create a media route. | 232 * Called when the user requests to create a media route. |
| 212 * | 233 * |
| 213 * @param {!Event} event | 234 * @param {!Event} event |
| 214 * Parameters in |event|.detail: | 235 * Parameters in |event|.detail: |
| 215 * sinkId - sink ID selected by the user. | 236 * sinkId - sink ID selected by the user. |
| 216 * selectedCastModeValue - cast mode selected by the user. | 237 * selectedCastModeValue - cast mode selected by the user. |
| 217 */ | 238 */ |
| 218 function onCreateRoute(event) { | 239 function onCreateRoute(event) { |
| 219 /** @type {{sinkId: string, selectedCastModeValue, number}} */ | 240 /** @type {{sinkId: string, selectedCastModeValue: number}} */ |
| 220 var detail = event.detail; | 241 var detail = event.detail; |
| 221 media_router.browserApi.requestRoute(detail.sinkId, | 242 media_router.browserApi.requestRoute(detail.sinkId, |
| 222 detail.selectedCastModeValue); | 243 detail.selectedCastModeValue); |
| 223 } | 244 } |
| 224 | 245 |
| 225 /** | 246 /** |
| 226 * Stops a route. | 247 * Stops a route. |
| 227 * Called when the user requests to stop a media route. | 248 * Called when the user requests to stop a media route. |
| 228 * | 249 * |
| 229 * @param {!Event} event | 250 * @param {!Event} event |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 * Reports the user navigation the sink list view. | 296 * Reports the user navigation the sink list view. |
| 276 * Called when the user clicks on the back button from the route details view | 297 * Called when the user clicks on the back button from the route details view |
| 277 * to the sink list view. | 298 * to the sink list view. |
| 278 */ | 299 */ |
| 279 function onNavigateToSinkList() { | 300 function onNavigateToSinkList() { |
| 280 media_router.browserApi.reportNavigateToView( | 301 media_router.browserApi.reportNavigateToView( |
| 281 media_router.MediaRouterView.SINK_LIST); | 302 media_router.MediaRouterView.SINK_LIST); |
| 282 } | 303 } |
| 283 | 304 |
| 284 /** | 305 /** |
| 306 * Sends a command to pause the route shown in the route details view. | |
| 307 * Called when the user clicks on the pause button. | |
| 308 */ | |
| 309 function onPauseRoute() { | |
| 310 media_router.browserApi.pauseRoute(); | |
| 311 } | |
| 312 | |
| 313 /** | |
| 314 * Sends a command to play the route shown in the route details view. | |
| 315 * Called when the user clicks on the play button. | |
| 316 */ | |
| 317 function onPlayRoute() { | |
| 318 media_router.browserApi.playRoute(); | |
| 319 } | |
| 320 | |
| 321 /** | |
| 285 * Reports whether or not the route creation was successful. | 322 * Reports whether or not the route creation was successful. |
| 286 * | 323 * |
| 287 * @param {!Event} event | 324 * @param {!Event} event |
| 288 * Parameters in |event|.detail: | 325 * Parameters in |event|.detail: |
| 289 * success - whether or not the route creation was successful. | 326 * success - whether or not the route creation was successful. |
| 290 */ | 327 */ |
| 291 function onReportRouteCreation(event) { | 328 function onReportRouteCreation(event) { |
| 292 var detail = event.detail; | 329 var detail = event.detail; |
| 293 media_router.browserApi.reportRouteCreation(detail.success); | 330 media_router.browserApi.reportRouteCreation(detail.success); |
| 294 } | 331 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 311 } | 348 } |
| 312 | 349 |
| 313 /** | 350 /** |
| 314 * Requests for initial data to load into the dialog. | 351 * Requests for initial data to load into the dialog. |
| 315 */ | 352 */ |
| 316 function onRequestInitialData() { | 353 function onRequestInitialData() { |
| 317 media_router.browserApi.requestInitialData(); | 354 media_router.browserApi.requestInitialData(); |
| 318 } | 355 } |
| 319 | 356 |
| 320 /** | 357 /** |
| 358 * Reports that the route details view has been closed. | |
| 359 */ | |
| 360 function onRouteDetailsClosed() { | |
| 361 media_router.browserApi.onRouteDetailsClosed(); | |
| 362 } | |
| 363 | |
| 364 /** | |
| 365 * Reports that the route details view has been opened. | |
| 366 * | |
| 367 * @param {!Event} event | |
| 368 * Parameters in |event|.detail: | |
| 369 * routeId - The ID of the media route shown in the details view. | |
| 370 */ | |
| 371 function onRouteDetailsOpened(event) { | |
| 372 /** @type {{routeId: string}} */ | |
| 373 var detail = event.detail; | |
| 374 media_router.browserApi.onRouteDetailsOpened(detail.routeId); | |
| 375 } | |
| 376 | |
| 377 /** | |
| 378 * Sends a command to seek the route shown in the route details view. Called | |
| 379 * when the user manipulates the seek slider. | |
| 380 * | |
| 381 * @param {!Event} event | |
| 382 * Parameters in |event|.detail: | |
| 383 * mute - whether to mute the route. | |
| 384 */ | |
| 385 function onSeekRoute(event) { | |
| 386 /** @type {{time: number}} */ | |
| 387 var detail = event.detail; | |
| 388 media_router.browserApi.seekRoute(detail.time); | |
| 389 } | |
| 390 | |
| 391 /** | |
| 392 * Sends a command to mute or unmute the route shown in the route details | |
| 393 * view. Called when the user clicks on the mute/unmute button. | |
| 394 * | |
| 395 * @param {!Event} event | |
| 396 * Parameters in |event|.detail: | |
| 397 * mute - whether to mute the route. | |
| 398 */ | |
| 399 function onSetRouteMute(event) { | |
| 400 /** @type {{mute: boolean}} */ | |
| 401 var detail = event.detail; | |
| 402 media_router.browserApi.setRouteMute(detail.mute); | |
| 403 } | |
| 404 | |
| 405 /** | |
| 321 * Reports the initial state of the dialog after it is opened. | 406 * Reports the initial state of the dialog after it is opened. |
| 322 * Called after initial data is populated. | 407 * Called after initial data is populated. |
| 323 * | 408 * |
| 324 * @param {!Event} event | 409 * @param {!Event} event |
| 325 * Parameters in |event|.detail: | 410 * Parameters in |event|.detail: |
| 326 * currentView - the current dialog's current view. | 411 * currentView - the current dialog's current view. |
| 327 */ | 412 */ |
| 328 function onShowInitialState(event) { | 413 function onShowInitialState(event) { |
| 329 /** @type {{currentView: string}} */ | 414 /** @type {{currentView: string}} */ |
| 330 var detail = event.detail; | 415 var detail = event.detail; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 function onWindowBlur() { | 464 function onWindowBlur() { |
| 380 media_router.browserApi.reportBlur(); | 465 media_router.browserApi.reportBlur(); |
| 381 } | 466 } |
| 382 | 467 |
| 383 return { | 468 return { |
| 384 initialize: initialize, | 469 initialize: initialize, |
| 385 }; | 470 }; |
| 386 }); | 471 }); |
| 387 | 472 |
| 388 window.addEventListener('load', media_router.initialize); | 473 window.addEventListener('load', media_router.initialize); |
| OLD | NEW |