| 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(container, | 31 media_router.ui.setElements(container, container.header); |
| 32 /** @type {!MediaRouterHeaderElement} */(container.header)); | |
| 33 | 32 |
| 34 container.addEventListener('acknowledge-first-run-flow', | 33 container.addEventListener('acknowledge-first-run-flow', |
| 35 onAcknowledgeFirstRunFlow); | 34 onAcknowledgeFirstRunFlow); |
| 36 container.addEventListener('back-click', onNavigateToSinkList); | 35 container.addEventListener('back-click', onNavigateToSinkList); |
| 37 container.addEventListener('cast-mode-selected', onCastModeSelected); | 36 container.addEventListener('cast-mode-selected', onCastModeSelected); |
| 38 container.addEventListener('change-route-source-click', | 37 container.addEventListener('change-route-source-click', |
| 39 onChangeRouteSourceClick); | 38 onChangeRouteSourceClick); |
| 40 container.addEventListener('close-dialog', onCloseDialog); | 39 container.addEventListener('close-dialog', onCloseDialog); |
| 41 container.addEventListener('close-route', onCloseRoute); | 40 container.addEventListener('close-route', onCloseRoute); |
| 42 container.addEventListener('create-route', onCreateRoute); | 41 container.addEventListener('create-route', onCreateRoute); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 291 } |
| 293 | 292 |
| 294 /** | 293 /** |
| 295 * Reports whether or not the route creation was successful. | 294 * Reports whether or not the route creation was successful. |
| 296 * | 295 * |
| 297 * @param {!Event} event | 296 * @param {!Event} event |
| 298 * Parameters in |event|.detail: | 297 * Parameters in |event|.detail: |
| 299 * success - whether or not the route creation was successful. | 298 * success - whether or not the route creation was successful. |
| 300 */ | 299 */ |
| 301 function onReportRouteCreation(event) { | 300 function onReportRouteCreation(event) { |
| 301 /** @type {{success: boolean}} */ |
| 302 var detail = event.detail; | 302 var detail = event.detail; |
| 303 media_router.browserApi.reportRouteCreation(detail.success); | 303 media_router.browserApi.reportRouteCreation(detail.success); |
| 304 } | 304 } |
| 305 | 305 |
| 306 /** | 306 /** |
| 307 * Reports success or the type of failure for route creation response. | 307 * Reports success or the type of failure for route creation response. |
| 308 * Called when the route is resolved; either the route creation was a success | 308 * Called when the route is resolved; either the route creation was a success |
| 309 * or if there was no route or the route's corresponding sink is invalid; | 309 * or if there was no route or the route's corresponding sink is invalid; |
| 310 * either the sink does not exist or was not the sink we were looking for. | 310 * either the sink does not exist or was not the sink we were looking for. |
| 311 * | 311 * |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 function onWindowBlur() { | 389 function onWindowBlur() { |
| 390 media_router.browserApi.reportBlur(); | 390 media_router.browserApi.reportBlur(); |
| 391 } | 391 } |
| 392 | 392 |
| 393 return { | 393 return { |
| 394 initialize: initialize, | 394 initialize: initialize, |
| 395 }; | 395 }; |
| 396 }); | 396 }); |
| 397 | 397 |
| 398 window.addEventListener('load', media_router.initialize); | 398 window.addEventListener('load', media_router.initialize); |
| OLD | NEW |