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 // API invoked by the browser MediaRouterWebUIMessageHandler to communicate | 5 // API invoked by the browser MediaRouterWebUIMessageHandler to communicate |
6 // with this UI. | 6 // with this UI. |
7 cr.define('media_router.ui', function() { | 7 cr.define('media_router.ui', function() { |
8 'use strict'; | 8 'use strict'; |
9 | 9 |
10 // The media-router-container element. | 10 // The media-router-container element. |
11 var container = null; | 11 var container = null; |
12 | 12 |
13 // The media-router-header element. | |
14 var header = null; | |
15 | |
13 /** | 16 /** |
14 * Handles response of previous create route attempt. | 17 * Handles response of previous create route attempt. |
15 * | 18 * |
16 * @param {string} sinkId The ID of the sink to which the Media Route was | 19 * @param {string} sinkId The ID of the sink to which the Media Route was |
17 * creating a route. | 20 * creating a route. |
18 * @param {?media_router.Route} route The newly created route that | 21 * @param {?media_router.Route} route The newly created route that |
19 * corresponds to the sink if route creation succeeded; null otherwise. | 22 * corresponds to the sink if route creation succeeded; null otherwise. |
20 * @param {boolean} isForDisplay Whether or not |route| is for display. | 23 * @param {boolean} isForDisplay Whether or not |route| is for display. |
21 */ | 24 */ |
22 function onCreateRouteResponseReceived(sinkId, route, isForDisplay) { | 25 function onCreateRouteResponseReceived(sinkId, route, isForDisplay) { |
23 container.onCreateRouteResponseReceived(sinkId, route, isForDisplay); | 26 container.onCreateRouteResponseReceived(sinkId, route, isForDisplay); |
24 } | 27 } |
25 | 28 |
26 /** | 29 /** |
27 * Sets the cast mode list. | 30 * Sets the cast mode list. |
28 * | 31 * |
29 * @param {!Array<!media_router.CastMode>} castModeList | 32 * @param {!Array<!media_router.CastMode>} castModeList |
30 */ | 33 */ |
31 function setCastModeList(castModeList) { | 34 function setCastModeList(castModeList) { |
32 container.castModeList = castModeList; | 35 container.castModeList = castModeList; |
33 } | 36 } |
34 | 37 |
35 /** | 38 /** |
36 * Sets |container|. | 39 * Sets |container| and |header|. |
37 * | 40 * |
38 * @param {!MediaRouterContainerElement} mediaRouterContainer | 41 * @param {!MediaRouterContainerElement} mediaRouterContainer |
42 * @param {!MediaRouterHeaderElement} mediaRouterHeader | |
39 */ | 43 */ |
40 function setContainer(mediaRouterContainer) { | 44 function setElements(mediaRouterContainer, mediaRouterHeader) { |
41 container = mediaRouterContainer; | 45 container = mediaRouterContainer; |
46 header = mediaRouterHeader; | |
42 } | 47 } |
43 | 48 |
44 /** | 49 /** |
45 * Populates the WebUI with data obtained about the first run flow. | 50 * Populates the WebUI with data obtained about the first run flow. |
46 * | 51 * |
47 * @param {{firstRunFlowCloudPrefLearnMoreUrl: string, | 52 * @param {{firstRunFlowCloudPrefLearnMoreUrl: string, |
48 * firstRunFlowLearnMoreUrl: string, | 53 * firstRunFlowLearnMoreUrl: string, |
49 * wasFirstRunFlowAcknowledged: boolean, | 54 * wasFirstRunFlowAcknowledged: boolean, |
50 * showFirstRunFlowCloudPref: boolean}} data | 55 * showFirstRunFlowCloudPref: boolean}} data |
51 * Parameters in data: | 56 * Parameters in data: |
(...skipping 17 matching lines...) Expand all Loading... | |
69 // setting was implemented. These users will see the first run flow | 74 // setting was implemented. These users will see the first run flow |
70 // again. | 75 // again. |
71 container.showFirstRunFlow = !data['wasFirstRunFlowAcknowledged'] || | 76 container.showFirstRunFlow = !data['wasFirstRunFlowAcknowledged'] || |
72 container.showFirstRunFlowCloudPref; | 77 container.showFirstRunFlowCloudPref; |
73 } | 78 } |
74 | 79 |
75 /** | 80 /** |
76 * Populates the WebUI with data obtained from Media Router. | 81 * Populates the WebUI with data obtained from Media Router. |
77 * | 82 * |
78 * @param {{deviceMissingUrl: string, | 83 * @param {{deviceMissingUrl: string, |
79 * sinks: !Array<!media_router.Sink>, | 84 * sinksAndIdentity: {{ |
Dan Beam
2016/02/25 16:30:08
{{ -> {
| |
85 * sinks: !Array<!media_router.Sink>, | |
86 * showEmail: boolean, | |
87 * userEmail: string, | |
88 * showDomain: boolean, | |
89 * userDomain: string | |
90 * }}, | |
Dan Beam
2016/02/25 16:30:08
}} -> }
| |
80 * routes: !Array<!media_router.Route>, | 91 * routes: !Array<!media_router.Route>, |
81 * castModes: !Array<!media_router.CastMode>}} data | 92 * castModes: !Array<!media_router.CastMode>}} data |
82 * Parameters in data: | 93 * Parameters in data: |
83 * deviceMissingUrl - url to be opened on "Device missing?" clicked. | 94 * deviceMissingUrl - url to be opened on "Device missing?" clicked. |
84 * sinks - list of sinks to be displayed. | 95 * sinksAndIdentity - list of sinks to be displayed and user identity. |
85 * routes - list of routes that are associated with the sinks. | 96 * routes - list of routes that are associated with the sinks. |
86 * castModes - list of available cast modes. | 97 * castModes - list of available cast modes. |
87 */ | 98 */ |
88 function setInitialData(data) { | 99 function setInitialData(data) { |
89 container.deviceMissingUrl = data['deviceMissingUrl']; | 100 container.deviceMissingUrl = data['deviceMissingUrl']; |
90 container.castModeList = data['castModes']; | 101 container.castModeList = data['castModes']; |
91 container.allSinks = data['sinks']; | 102 this.setSinkListAndIdentity(data['sinksAndIdentity']); |
92 container.routeList = data['routes']; | 103 container.routeList = data['routes']; |
93 container.maybeShowRouteDetailsOnOpen(); | 104 container.maybeShowRouteDetailsOnOpen(); |
94 media_router.browserApi.onInitialDataReceived(); | 105 media_router.browserApi.onInitialDataReceived(); |
95 } | 106 } |
96 | 107 |
97 /** | 108 /** |
98 * Sets current issue to |issue|, or clears the current issue if |issue| is | 109 * Sets current issue to |issue|, or clears the current issue if |issue| is |
99 * null. | 110 * null. |
100 * | 111 * |
101 * @param {?media_router.Issue} issue | 112 * @param {?media_router.Issue} issue |
102 */ | 113 */ |
103 function setIssue(issue) { | 114 function setIssue(issue) { |
104 container.issue = issue; | 115 container.issue = issue; |
105 } | 116 } |
106 | 117 |
107 /** | 118 /** |
108 * Sets the list of currently active routes. | 119 * Sets the list of currently active routes. |
109 * | 120 * |
110 * @param {!Array<!media_router.Route>} routeList | 121 * @param {!Array<!media_router.Route>} routeList |
111 */ | 122 */ |
112 function setRouteList(routeList) { | 123 function setRouteList(routeList) { |
113 container.routeList = routeList; | 124 container.routeList = routeList; |
114 } | 125 } |
115 | 126 |
116 /** | 127 /** |
117 * Sets the list of discovered sinks. | 128 * Sets the list of discovered sinks along with properties of whether to hide |
129 * identity of the user email and domain. | |
118 * | 130 * |
119 * @param {!Array<!media_router.Sink>} sinkList | 131 * @param {{sinks: !Array<!media_router.Sink>, |
132 * showEmail: boolean, | |
133 * userEmail: string, | |
134 * showDomain: boolean, | |
135 * userDomain: string,}} data | |
136 * Parameters in data: | |
137 * sinks - list of sinks to be displayed. | |
138 * showEmail - true if the user email should be shown. | |
139 * userEmail - email of the user if the user is signed in. | |
140 * showDomain - true if the user domain should be shown. | |
141 * userDomain - domain of the user if the user is signed in. | |
120 */ | 142 */ |
121 function setSinkList(sinkList) { | 143 function setSinkListAndIdentity(data) { |
122 container.allSinks = sinkList; | 144 container.allSinks = data['sinks']; |
145 container.showDomain = data['showDomain']; | |
146 container.userDomain = data['userDomain']; | |
147 header.showEmail = data['showEmail']; | |
148 header.userEmail = data['userEmail']; | |
123 } | 149 } |
124 | 150 |
125 /** | 151 /** |
126 * Updates the max height of the dialog | 152 * Updates the max height of the dialog |
127 * | 153 * |
128 * @param {number} height | 154 * @param {number} height |
129 */ | 155 */ |
130 function updateMaxHeight(height) { | 156 function updateMaxHeight(height) { |
131 container.updateMaxDialogHeight(height); | 157 container.updateMaxDialogHeight(height); |
132 } | 158 } |
133 | 159 |
134 return { | 160 return { |
135 onCreateRouteResponseReceived: onCreateRouteResponseReceived, | 161 onCreateRouteResponseReceived: onCreateRouteResponseReceived, |
136 setCastModeList: setCastModeList, | 162 setCastModeList: setCastModeList, |
137 setContainer: setContainer, | 163 setElements: setElements, |
138 setFirstRunFlowData: setFirstRunFlowData, | 164 setFirstRunFlowData: setFirstRunFlowData, |
139 setInitialData: setInitialData, | 165 setInitialData: setInitialData, |
140 setIssue: setIssue, | 166 setIssue: setIssue, |
141 setRouteList: setRouteList, | 167 setRouteList: setRouteList, |
142 setSinkList: setSinkList, | 168 setSinkListAndIdentity: setSinkListAndIdentity, |
143 updateMaxHeight: updateMaxHeight, | 169 updateMaxHeight: updateMaxHeight, |
144 }; | 170 }; |
145 }); | 171 }); |
146 | 172 |
147 // API invoked by this UI to communicate with the browser WebUI message handler. | 173 // API invoked by this UI to communicate with the browser WebUI message handler. |
148 cr.define('media_router.browserApi', function() { | 174 cr.define('media_router.browserApi', function() { |
149 'use strict'; | 175 'use strict'; |
150 | 176 |
151 /** | 177 /** |
152 * Indicates that the user has acknowledged the first run flow. | 178 * Indicates that the user has acknowledged the first run flow. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 reportNavigateToView: reportNavigateToView, | 344 reportNavigateToView: reportNavigateToView, |
319 reportSelectedCastMode: reportSelectedCastMode, | 345 reportSelectedCastMode: reportSelectedCastMode, |
320 reportRouteCreation: reportRouteCreation, | 346 reportRouteCreation: reportRouteCreation, |
321 reportSinkCount: reportSinkCount, | 347 reportSinkCount: reportSinkCount, |
322 reportTimeToClickSink: reportTimeToClickSink, | 348 reportTimeToClickSink: reportTimeToClickSink, |
323 reportTimeToInitialActionClose: reportTimeToInitialActionClose, | 349 reportTimeToInitialActionClose: reportTimeToInitialActionClose, |
324 requestInitialData: requestInitialData, | 350 requestInitialData: requestInitialData, |
325 requestRoute: requestRoute, | 351 requestRoute: requestRoute, |
326 }; | 352 }; |
327 }); | 353 }); |
OLD | NEW |