| 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'; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * The media-router-container element. Initialized after polymer is ready. | 13 * The media-router-container element. Initialized after polymer is ready. |
| 14 * @type {?MediaRouterContainerElement} | 14 * @type {?MediaRouterContainerElement} |
| 15 */ | 15 */ |
| 16 var container = null; | 16 var container = null; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * Initializes the Media Router WebUI and requests initial media | 19 * Initializes the Media Router WebUI and requests initial media |
| 20 * router content, such as the media sink and media route lists. | 20 * router content, such as the media sink and media route lists. |
| 21 */ | 21 */ |
| 22 function initialize() { | 22 function initialize() { |
| 23 // For non-Mac platforms, request data immediately after initialization. | 23 // For non-Mac platforms, request data immediately after initialization. |
| 24 if (!cr.isMac) | 24 if (!cr.isMac) |
| 25 onRequestInitialData(); | 25 onRequestInitialData(); |
| 26 | 26 |
| 27 container = /** @type {!MediaRouterContainerElement} */ | 27 container = /** @type {!MediaRouterContainerElement} */ |
| 28 ($('media-router-container')); | 28 ($('media-router-container')); |
| 29 | 29 |
| 30 media_router.ui.setElements(container, | 30 media_router.ui.setElements( |
| 31 /** @type {!MediaRouterHeaderElement} */(container.header)); | 31 container, |
| 32 /** @type {!MediaRouterHeaderElement} */ (container.header)); |
| 32 | 33 |
| 33 container.addEventListener('acknowledge-first-run-flow', | 34 container.addEventListener( |
| 34 onAcknowledgeFirstRunFlow); | 35 'acknowledge-first-run-flow', onAcknowledgeFirstRunFlow); |
| 35 container.addEventListener('back-click', onNavigateToSinkList); | 36 container.addEventListener('back-click', onNavigateToSinkList); |
| 36 container.addEventListener('cast-mode-selected', onCastModeSelected); | 37 container.addEventListener('cast-mode-selected', onCastModeSelected); |
| 37 container.addEventListener('change-route-source-click', | 38 container.addEventListener( |
| 38 onChangeRouteSourceClick); | 39 'change-route-source-click', onChangeRouteSourceClick); |
| 39 container.addEventListener('close-dialog', onCloseDialog); | 40 container.addEventListener('close-dialog', onCloseDialog); |
| 40 container.addEventListener('close-route', onCloseRoute); | 41 container.addEventListener('close-route', onCloseRoute); |
| 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( |
| 45 onNavigateToDetails); | 46 'navigate-sink-list-to-details', onNavigateToDetails); |
| 46 container.addEventListener('navigate-to-cast-mode-list', | 47 container.addEventListener( |
| 47 onNavigateToCastMode); | 48 'navigate-to-cast-mode-list', onNavigateToCastMode); |
| 48 container.addEventListener('report-filter', onFilter); | 49 container.addEventListener('report-filter', onFilter); |
| 49 container.addEventListener('report-initial-action', onInitialAction); | 50 container.addEventListener('report-initial-action', onInitialAction); |
| 50 container.addEventListener('report-initial-action-close', | 51 container.addEventListener( |
| 51 onInitialActionClose); | 52 'report-initial-action-close', onInitialActionClose); |
| 52 container.addEventListener('report-route-creation', onReportRouteCreation); | 53 container.addEventListener('report-route-creation', onReportRouteCreation); |
| 53 container.addEventListener('report-sink-click-time', | 54 container.addEventListener( |
| 54 onSinkClickTimeReported); | 55 'report-sink-click-time', onSinkClickTimeReported); |
| 55 container.addEventListener('report-sink-count', onSinkCountReported); | 56 container.addEventListener('report-sink-count', onSinkCountReported); |
| 56 container.addEventListener('report-resolved-route', | 57 container.addEventListener( |
| 57 onReportRouteCreationOutcome); | 58 'report-resolved-route', onReportRouteCreationOutcome); |
| 58 container.addEventListener('request-initial-data', | 59 container.addEventListener('request-initial-data', onRequestInitialData); |
| 59 onRequestInitialData); | 60 container.addEventListener( |
| 60 container.addEventListener('search-sinks-and-create-route', | 61 'search-sinks-and-create-route', onSearchSinksAndCreateRoute); |
| 61 onSearchSinksAndCreateRoute); | |
| 62 container.addEventListener('show-initial-state', onShowInitialState); | 62 container.addEventListener('show-initial-state', onShowInitialState); |
| 63 container.addEventListener('sink-click', onSinkClick); | 63 container.addEventListener('sink-click', onSinkClick); |
| 64 | 64 |
| 65 window.addEventListener('blur', onWindowBlur); | 65 window.addEventListener('blur', onWindowBlur); |
| 66 } | 66 } |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * Requests that the Media Router searches for a sink with criteria | 69 * Requests that the Media Router searches for a sink with criteria |
| 70 * |event.detail.name|. | 70 * |event.detail.name|. |
| 71 * @param {!Event} event | 71 * @param {!Event} event |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 * | 193 * |
| 194 * @param {!Event} event | 194 * @param {!Event} event |
| 195 * Parameters in |event|.detail: | 195 * Parameters in |event|.detail: |
| 196 * id - issue ID. | 196 * id - issue ID. |
| 197 * actionType - type of action performed by the user. | 197 * actionType - type of action performed by the user. |
| 198 * helpPageId - the numeric help center ID. | 198 * helpPageId - the numeric help center ID. |
| 199 */ | 199 */ |
| 200 function onIssueActionClick(event) { | 200 function onIssueActionClick(event) { |
| 201 /** @type {{id: number, actionType: number, helpPageId: number}} */ | 201 /** @type {{id: number, actionType: number, helpPageId: number}} */ |
| 202 var detail = event.detail; | 202 var detail = event.detail; |
| 203 media_router.browserApi.actOnIssue(detail.id, | 203 media_router.browserApi.actOnIssue( |
| 204 detail.actionType, | 204 detail.id, detail.actionType, detail.helpPageId); |
| 205 detail.helpPageId); | |
| 206 container.issue = null; | 205 container.issue = null; |
| 207 } | 206 } |
| 208 | 207 |
| 209 /** | 208 /** |
| 210 * Creates a media route. | 209 * Creates a media route. |
| 211 * Called when the user requests to create a media route. | 210 * Called when the user requests to create a media route. |
| 212 * | 211 * |
| 213 * @param {!Event} event | 212 * @param {!Event} event |
| 214 * Parameters in |event|.detail: | 213 * Parameters in |event|.detail: |
| 215 * sinkId - sink ID selected by the user. | 214 * sinkId - sink ID selected by the user. |
| 216 * selectedCastModeValue - cast mode selected by the user. | 215 * selectedCastModeValue - cast mode selected by the user. |
| 217 */ | 216 */ |
| 218 function onCreateRoute(event) { | 217 function onCreateRoute(event) { |
| 219 /** @type {{sinkId: string, selectedCastModeValue, number}} */ | 218 /** @type {{sinkId: string, selectedCastModeValue, number}} */ |
| 220 var detail = event.detail; | 219 var detail = event.detail; |
| 221 media_router.browserApi.requestRoute(detail.sinkId, | 220 media_router.browserApi.requestRoute( |
| 222 detail.selectedCastModeValue); | 221 detail.sinkId, detail.selectedCastModeValue); |
| 223 } | 222 } |
| 224 | 223 |
| 225 /** | 224 /** |
| 226 * Stops a route. | 225 * Stops a route. |
| 227 * Called when the user requests to stop a media route. | 226 * Called when the user requests to stop a media route. |
| 228 * | 227 * |
| 229 * @param {!Event} event | 228 * @param {!Event} event |
| 230 * Parameters in |event|.detail: | 229 * Parameters in |event|.detail: |
| 231 * route - The route to close. | 230 * route - The route to close. |
| 232 */ | 231 */ |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 function onWindowBlur() { | 378 function onWindowBlur() { |
| 380 media_router.browserApi.reportBlur(); | 379 media_router.browserApi.reportBlur(); |
| 381 } | 380 } |
| 382 | 381 |
| 383 return { | 382 return { |
| 384 initialize: initialize, | 383 initialize: initialize, |
| 385 }; | 384 }; |
| 386 }); | 385 }); |
| 387 | 386 |
| 388 window.addEventListener('load', media_router.initialize); | 387 window.addEventListener('load', media_router.initialize); |
| OLD | NEW |