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_browser_api.js"> | 5 // <include src="media_router_browser_api.js"> |
6 // <include src="media_router_data.js"> | 6 // <include src="media_router_data.js"> |
7 // <include src="media_router_ui_interface.js"> | 7 // <include src="media_router_ui_interface.js"> |
8 | 8 |
9 // Handles user events for the Media Router UI. | 9 // Handles user events for the Media Router UI. |
10 cr.define('media_router', function() { | 10 cr.define('media_router', function() { |
11 'use strict'; | 11 'use strict'; |
12 | 12 |
13 /** | 13 /** |
14 * The media-router-container element. Initialized after polymer is ready. | 14 * The media-router-container element. Initialized after polymer is ready. |
15 * @type {?MediaRouterContainerElement} | 15 * @type {?MediaRouterContainerInterface} |
16 */ | 16 */ |
17 var container = null; | 17 var container = null; |
18 | 18 |
19 /** | 19 /** |
20 * Initializes the Media Router WebUI and requests initial media | 20 * Initializes the Media Router WebUI and requests initial media |
21 * router content, such as the media sink and media route lists. | 21 * router content, such as the media sink and media route lists. |
22 */ | 22 */ |
23 function initialize() { | 23 function initialize() { |
24 // For non-Mac platforms, request data immediately after initialization. | 24 // For non-Mac platforms, request data immediately after initialization. |
25 if (!cr.isMac) | 25 if (!cr.isMac) |
26 onRequestInitialData(); | 26 onRequestInitialData(); |
27 | 27 |
28 container = /** @type {!MediaRouterContainerElement} */ | 28 container = /** @type {!MediaRouterContainerInterface} */ |
29 ($('media-router-container')); | 29 ($('media-router-container')); |
30 | 30 |
31 media_router.ui.setElements( | 31 media_router.ui.setElements(container, container.header); |
32 container, | |
33 /** @type {!MediaRouterHeaderElement} */ (container.header)); | |
34 | 32 |
35 container.addEventListener( | 33 container.addEventListener( |
36 'acknowledge-first-run-flow', onAcknowledgeFirstRunFlow); | 34 'acknowledge-first-run-flow', onAcknowledgeFirstRunFlow); |
37 container.addEventListener('back-click', onNavigateToSinkList); | 35 container.addEventListener('back-click', onNavigateToSinkList); |
38 container.addEventListener('cast-mode-selected', onCastModeSelected); | 36 container.addEventListener('cast-mode-selected', onCastModeSelected); |
39 container.addEventListener( | 37 container.addEventListener( |
40 'change-route-source-click', onChangeRouteSourceClick); | 38 'change-route-source-click', onChangeRouteSourceClick); |
41 container.addEventListener('close-dialog', onCloseDialog); | 39 container.addEventListener('close-dialog', onCloseDialog); |
42 container.addEventListener('close-route', onCloseRoute); | 40 container.addEventListener('close-route', onCloseRoute); |
43 container.addEventListener('create-route', onCreateRoute); | 41 container.addEventListener('create-route', onCreateRoute); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 } | 289 } |
292 | 290 |
293 /** | 291 /** |
294 * Reports whether or not the route creation was successful. | 292 * Reports whether or not the route creation was successful. |
295 * | 293 * |
296 * @param {!Event} event | 294 * @param {!Event} event |
297 * Parameters in |event|.detail: | 295 * Parameters in |event|.detail: |
298 * success - whether or not the route creation was successful. | 296 * success - whether or not the route creation was successful. |
299 */ | 297 */ |
300 function onReportRouteCreation(event) { | 298 function onReportRouteCreation(event) { |
| 299 /** @type {{success: boolean}} */ |
301 var detail = event.detail; | 300 var detail = event.detail; |
302 media_router.browserApi.reportRouteCreation(detail.success); | 301 media_router.browserApi.reportRouteCreation(detail.success); |
303 } | 302 } |
304 | 303 |
305 /** | 304 /** |
306 * Reports success or the type of failure for route creation response. | 305 * Reports success or the type of failure for route creation response. |
307 * Called when the route is resolved; either the route creation was a success | 306 * Called when the route is resolved; either the route creation was a success |
308 * or if there was no route or the route's corresponding sink is invalid; | 307 * or if there was no route or the route's corresponding sink is invalid; |
309 * either the sink does not exist or was not the sink we were looking for. | 308 * either the sink does not exist or was not the sink we were looking for. |
310 * | 309 * |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 function onWindowBlur() { | 387 function onWindowBlur() { |
389 media_router.browserApi.reportBlur(); | 388 media_router.browserApi.reportBlur(); |
390 } | 389 } |
391 | 390 |
392 return { | 391 return { |
393 initialize: initialize, | 392 initialize: initialize, |
394 }; | 393 }; |
395 }); | 394 }); |
396 | 395 |
397 window.addEventListener('load', media_router.initialize); | 396 window.addEventListener('load', media_router.initialize); |
OLD | NEW |