| 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 media_router.browserApi.requestInitialData(); | 23 // For non-Mac platforms, request data immediately after initialization. |
| 24 if (!cr.isMac) |
| 25 onRequestInitialData(); |
| 24 | 26 |
| 25 container = /** @type {!MediaRouterContainerElement} */ | 27 container = /** @type {!MediaRouterContainerElement} */ |
| 26 ($('media-router-container')); | 28 ($('media-router-container')); |
| 27 | 29 |
| 28 media_router.ui.setElements(container, | 30 media_router.ui.setElements(container, |
| 29 /** @type {!MediaRouterHeaderElement} */ | 31 /** @type {!MediaRouterHeaderElement} */ |
| 30 (container.$['container-header'])); | 32 (container.$['container-header'])); |
| 31 | 33 |
| 32 container.addEventListener('acknowledge-first-run-flow', | 34 container.addEventListener('acknowledge-first-run-flow', |
| 33 onAcknowledgeFirstRunFlow); | 35 onAcknowledgeFirstRunFlow); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 44 container.addEventListener('report-filter', onFilter); | 46 container.addEventListener('report-filter', onFilter); |
| 45 container.addEventListener('report-initial-action', onInitialAction); | 47 container.addEventListener('report-initial-action', onInitialAction); |
| 46 container.addEventListener('report-initial-action-close', | 48 container.addEventListener('report-initial-action-close', |
| 47 onInitialActionClose); | 49 onInitialActionClose); |
| 48 container.addEventListener('report-route-creation', onReportRouteCreation); | 50 container.addEventListener('report-route-creation', onReportRouteCreation); |
| 49 container.addEventListener('report-sink-click-time', | 51 container.addEventListener('report-sink-click-time', |
| 50 onSinkClickTimeReported); | 52 onSinkClickTimeReported); |
| 51 container.addEventListener('report-sink-count', onSinkCountReported); | 53 container.addEventListener('report-sink-count', onSinkCountReported); |
| 52 container.addEventListener('report-resolved-route', | 54 container.addEventListener('report-resolved-route', |
| 53 onReportRouteCreationOutcome); | 55 onReportRouteCreationOutcome); |
| 56 container.addEventListener('request-initial-data', |
| 57 onRequestInitialData); |
| 54 container.addEventListener('search-sinks-and-create-route', | 58 container.addEventListener('search-sinks-and-create-route', |
| 55 onSearchSinksAndCreateRoute); | 59 onSearchSinksAndCreateRoute); |
| 56 container.addEventListener('show-initial-state', onShowInitialState); | 60 container.addEventListener('show-initial-state', onShowInitialState); |
| 57 container.addEventListener('sink-click', onSinkClick); | 61 container.addEventListener('sink-click', onSinkClick); |
| 58 container.addEventListener('start-casting-to-route-click', | 62 container.addEventListener('start-casting-to-route-click', |
| 59 onStartCastingToRouteClick); | 63 onStartCastingToRouteClick); |
| 60 | 64 |
| 61 window.addEventListener('blur', onWindowBlur); | 65 window.addEventListener('blur', onWindowBlur); |
| 62 } | 66 } |
| 63 | 67 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 * outcome - the outcome of a create route response. | 287 * outcome - the outcome of a create route response. |
| 284 * | 288 * |
| 285 */ | 289 */ |
| 286 function onReportRouteCreationOutcome(event) { | 290 function onReportRouteCreationOutcome(event) { |
| 287 /** @type {{outcome: number}} */ | 291 /** @type {{outcome: number}} */ |
| 288 var detail = event.detail; | 292 var detail = event.detail; |
| 289 media_router.browserApi.reportRouteCreationOutcome(detail.outcome); | 293 media_router.browserApi.reportRouteCreationOutcome(detail.outcome); |
| 290 } | 294 } |
| 291 | 295 |
| 292 /** | 296 /** |
| 297 * Requests for initial data to load into the dialog. |
| 298 */ |
| 299 function onRequestInitialData() { |
| 300 media_router.browserApi.requestInitialData(); |
| 301 } |
| 302 |
| 303 /** |
| 293 * Reports the initial state of the dialog after it is opened. | 304 * Reports the initial state of the dialog after it is opened. |
| 294 * Called after initial data is populated. | 305 * Called after initial data is populated. |
| 295 * | 306 * |
| 296 * @param {!Event} event | 307 * @param {!Event} event |
| 297 * Parameters in |event|.detail: | 308 * Parameters in |event|.detail: |
| 298 * currentView - the current dialog's current view. | 309 * currentView - the current dialog's current view. |
| 299 */ | 310 */ |
| 300 function onShowInitialState(event) { | 311 function onShowInitialState(event) { |
| 301 /** @type {{currentView: string}} */ | 312 /** @type {{currentView: string}} */ |
| 302 var detail = event.detail; | 313 var detail = event.detail; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 function onWindowBlur() { | 362 function onWindowBlur() { |
| 352 media_router.browserApi.reportBlur(); | 363 media_router.browserApi.reportBlur(); |
| 353 } | 364 } |
| 354 | 365 |
| 355 return { | 366 return { |
| 356 initialize: initialize, | 367 initialize: initialize, |
| 357 }; | 368 }; |
| 358 }); | 369 }); |
| 359 | 370 |
| 360 window.addEventListener('load', media_router.initialize); | 371 window.addEventListener('load', media_router.initialize); |
| OLD | NEW |