| 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   // The media-router-container element. Initialized after polymer is ready. | 12   // The media-router-container element. Initialized after polymer is ready. | 
| 13   var container = null; | 13   var container = null; | 
| 14 | 14 | 
| 15   /** | 15   /** | 
| 16    * Initializes the Media Router WebUI and requests initial media | 16    * Initializes the Media Router WebUI and requests initial media | 
| 17    * router content, such as the media sink and media route lists. | 17    * router content, such as the media sink and media route lists. | 
| 18    */ | 18    */ | 
| 19   function initialize() { | 19   function initialize() { | 
| 20     media_router.browserApi.requestInitialData(); | 20     media_router.browserApi.requestInitialData(); | 
| 21 | 21 | 
| 22     container = $('media-router-container'); | 22     container = $('media-router-container'); | 
| 23     media_router.ui.setContainer(container); | 23     media_router.ui.setContainer(container); | 
| 24 | 24 | 
| 25     container.addEventListener('close-button-click', onCloseDialogEvent); | 25     container.addEventListener('close-button-click', onCloseDialogEvent); | 
| 26     container.addEventListener('close-dialog', onCloseDialogEvent); | 26     container.addEventListener('close-dialog', onCloseDialogEvent); | 
| 27     container.addEventListener('close-route-click', onCloseRouteClick); | 27     container.addEventListener('close-route-click', onCloseRouteClick); | 
|  | 28     container.addEventListener('join-route-click', onJoinRouteClick); | 
| 28     container.addEventListener('create-route', onCreateRoute); | 29     container.addEventListener('create-route', onCreateRoute); | 
| 29     container.addEventListener('issue-action-click', onIssueActionClick); | 30     container.addEventListener('issue-action-click', onIssueActionClick); | 
| 30     container.addEventListener('report-sink-count', onSinkCountReported); | 31     container.addEventListener('report-sink-count', onSinkCountReported); | 
| 31   } | 32   } | 
| 32 | 33 | 
| 33   /** | 34   /** | 
| 34    * Closes the dialog. | 35    * Closes the dialog. | 
| 35    * Called when the user clicks the close button on the dialog. | 36    * Called when the user clicks the close button on the dialog. | 
| 36    */ | 37    */ | 
| 37   function onCloseDialogEvent() { | 38   function onCloseDialogEvent() { | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 67    */ | 68    */ | 
| 68   function onCreateRoute(data) { | 69   function onCreateRoute(data) { | 
| 69     media_router.browserApi.requestRoute(data.detail.sinkId, | 70     media_router.browserApi.requestRoute(data.detail.sinkId, | 
| 70                                          data.detail.selectedCastModeValue); | 71                                          data.detail.selectedCastModeValue); | 
| 71   } | 72   } | 
| 72 | 73 | 
| 73   /** | 74   /** | 
| 74    * Stops a route. | 75    * Stops a route. | 
| 75    * Called when the user requests to stop a media route. | 76    * Called when the user requests to stop a media route. | 
| 76    * | 77    * | 
| 77    * @param {{detail: {route: string}}} data | 78    * @param {{detail: {route: media_router.Route}}} data | 
| 78    * Parameters in |data|.detail: | 79    * Parameters in |data|.detail: | 
| 79    *   route - route ID. | 80    *   route - route to close. | 
| 80    */ | 81    */ | 
| 81   function onCloseRouteClick(data) { | 82   function onCloseRouteClick(data) { | 
| 82     media_router.browserApi.closeRoute(data.detail.route); | 83     media_router.browserApi.closeRoute(data.detail.route); | 
| 83   } | 84   } | 
| 84 | 85 | 
| 85   /** | 86   /** | 
|  | 87    * Joins a route. | 
|  | 88    * Called when the user requests to join a media route. | 
|  | 89    * | 
|  | 90    * @param {{detail: {route: media_router.Route}}} data | 
|  | 91    * Parameters in |data|.detail: | 
|  | 92    *   route - route to join. | 
|  | 93    */ | 
|  | 94   function onJoinRouteClick(data) { | 
|  | 95     media_router.browserApi.joinRoute(data.detail.route); | 
|  | 96   } | 
|  | 97 | 
|  | 98   /** | 
| 86    * Reports the current sink count. | 99    * Reports the current sink count. | 
| 87    * Called 3 seconds after the dialog is initially opened. | 100    * Called 3 seconds after the dialog is initially opened. | 
| 88    * | 101    * | 
| 89    * @param {{detail: {sinkCount: number}}} data | 102    * @param {{detail: {sinkCount: number}}} data | 
| 90    * Parameters in |data|.detail: | 103    * Parameters in |data|.detail: | 
| 91    *   sinkCount - the number of sinks. | 104    *   sinkCount - the number of sinks. | 
| 92    */ | 105    */ | 
| 93   function onSinkCountReported(data) { | 106   function onSinkCountReported(data) { | 
| 94     media_router.browserApi.reportSinkCount(data.detail.sinkCount); | 107     media_router.browserApi.reportSinkCount(data.detail.sinkCount); | 
| 95   } | 108   } | 
| 96 | 109 | 
| 97   return { | 110   return { | 
| 98     initialize: initialize, | 111     initialize: initialize, | 
| 99   }; | 112   }; | 
| 100 }); | 113 }); | 
| 101 | 114 | 
| 102 window.addEventListener('load', media_router.initialize); | 115 window.addEventListener('load', media_router.initialize); | 
| OLD | NEW | 
|---|