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: {{ |
| 85 * sinks: !Array<!media_router.Sink>, |
| 86 * showEmail: boolean, |
| 87 * userEmail: string, |
| 88 * showDomain: boolean, |
| 89 * userDomain: string |
| 90 * }}, |
80 * routes: !Array<!media_router.Route>, | 91 * routes: !Array<!media_router.Route>, |
| 92 * userEmail: string, |
| 93 * userDomain: string, |
| 94 * identityVisibility: number, |
81 * castModes: !Array<!media_router.CastMode>}} data | 95 * castModes: !Array<!media_router.CastMode>}} data |
82 * Parameters in data: | 96 * Parameters in data: |
83 * deviceMissingUrl - url to be opened on "Device missing?" clicked. | 97 * deviceMissingUrl - url to be opened on "Device missing?" clicked. |
84 * sinks - list of sinks to be displayed. | 98 * sinksAndIdentity - list of sinks to be displayed and user identity. |
85 * routes - list of routes that are associated with the sinks. | 99 * routes - list of routes that are associated with the sinks. |
86 * castModes - list of available cast modes. | 100 * castModes - list of available cast modes. |
87 */ | 101 */ |
88 function setInitialData(data) { | 102 function setInitialData(data) { |
89 container.deviceMissingUrl = data['deviceMissingUrl']; | 103 container.deviceMissingUrl = data['deviceMissingUrl']; |
90 container.castModeList = data['castModes']; | 104 container.castModeList = data['castModes']; |
91 container.allSinks = data['sinks']; | 105 this.setSinkListAndIdentity(data['sinksAndIdentity']); |
92 container.routeList = data['routes']; | 106 container.routeList = data['routes']; |
93 container.maybeShowRouteDetailsOnOpen(); | 107 container.maybeShowRouteDetailsOnOpen(); |
94 media_router.browserApi.onInitialDataReceived(); | 108 media_router.browserApi.onInitialDataReceived(); |
95 } | 109 } |
96 | 110 |
97 /** | 111 /** |
98 * Sets current issue to |issue|, or clears the current issue if |issue| is | 112 * Sets current issue to |issue|, or clears the current issue if |issue| is |
99 * null. | 113 * null. |
100 * | 114 * |
101 * @param {?media_router.Issue} issue | 115 * @param {?media_router.Issue} issue |
102 */ | 116 */ |
103 function setIssue(issue) { | 117 function setIssue(issue) { |
104 container.issue = issue; | 118 container.issue = issue; |
105 } | 119 } |
106 | 120 |
107 /** | 121 /** |
108 * Sets the list of currently active routes. | 122 * Sets the list of currently active routes. |
109 * | 123 * |
110 * @param {!Array<!media_router.Route>} routeList | 124 * @param {!Array<!media_router.Route>} routeList |
111 */ | 125 */ |
112 function setRouteList(routeList) { | 126 function setRouteList(routeList) { |
113 container.routeList = routeList; | 127 container.routeList = routeList; |
114 } | 128 } |
115 | 129 |
116 /** | 130 /** |
117 * Sets the list of discovered sinks. | 131 * Sets the list of discovered sinks along with properties of whether to hide |
| 132 * identity of the user email and domain. |
118 * | 133 * |
119 * @param {!Array<!media_router.Sink>} sinkList | 134 * @param {{sinks: !Array<!media_router.Sink>, |
| 135 * showEmail: boolean, |
| 136 * userEmail: string, |
| 137 * showDomain: boolean, |
| 138 * userDomain: string,}} data |
| 139 * Parameters in data: |
| 140 * sinks - list of sinks to be displayed. |
| 141 * showEmail - true if the user email should be shown. |
| 142 * userEmail - email of the user if the user is signed in. |
| 143 * showDomain - true if the user domain should be shown. |
| 144 * userDomain - domain of the user if the user is signed in. |
120 */ | 145 */ |
121 function setSinkList(sinkList) { | 146 function setSinkListAndIdentity(data) { |
122 container.allSinks = sinkList; | 147 container.allSinks = data['sinks']; |
| 148 container.showDomain = data['showDomain']; |
| 149 container.userDomain = data['userDomain']; |
| 150 header.showEmail = data['showEmail']; |
| 151 header.userEmail = data['userEmail']; |
123 } | 152 } |
124 | 153 |
125 /** | 154 /** |
126 * Updates the max height of the dialog | 155 * Updates the max height of the dialog |
127 * | 156 * |
128 * @param {number} height | 157 * @param {number} height |
129 */ | 158 */ |
130 function updateMaxHeight(height) { | 159 function updateMaxHeight(height) { |
131 container.updateMaxDialogHeight(height); | 160 container.updateMaxDialogHeight(height); |
132 } | 161 } |
133 | 162 |
134 return { | 163 return { |
135 onCreateRouteResponseReceived: onCreateRouteResponseReceived, | 164 onCreateRouteResponseReceived: onCreateRouteResponseReceived, |
136 setCastModeList: setCastModeList, | 165 setCastModeList: setCastModeList, |
137 setContainer: setContainer, | 166 setElements: setElements, |
138 setFirstRunFlowData: setFirstRunFlowData, | 167 setFirstRunFlowData: setFirstRunFlowData, |
139 setInitialData: setInitialData, | 168 setInitialData: setInitialData, |
140 setIssue: setIssue, | 169 setIssue: setIssue, |
141 setRouteList: setRouteList, | 170 setRouteList: setRouteList, |
142 setSinkList: setSinkList, | 171 setSinkListAndIdentity: setSinkListAndIdentity, |
143 updateMaxHeight: updateMaxHeight, | 172 updateMaxHeight: updateMaxHeight, |
144 }; | 173 }; |
145 }); | 174 }); |
146 | 175 |
147 // API invoked by this UI to communicate with the browser WebUI message handler. | 176 // API invoked by this UI to communicate with the browser WebUI message handler. |
148 cr.define('media_router.browserApi', function() { | 177 cr.define('media_router.browserApi', function() { |
149 'use strict'; | 178 'use strict'; |
150 | 179 |
151 /** | 180 /** |
152 * Indicates that the user has acknowledged the first run flow. | 181 * 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, | 347 reportNavigateToView: reportNavigateToView, |
319 reportSelectedCastMode: reportSelectedCastMode, | 348 reportSelectedCastMode: reportSelectedCastMode, |
320 reportRouteCreation: reportRouteCreation, | 349 reportRouteCreation: reportRouteCreation, |
321 reportSinkCount: reportSinkCount, | 350 reportSinkCount: reportSinkCount, |
322 reportTimeToClickSink: reportTimeToClickSink, | 351 reportTimeToClickSink: reportTimeToClickSink, |
323 reportTimeToInitialActionClose: reportTimeToInitialActionClose, | 352 reportTimeToInitialActionClose: reportTimeToInitialActionClose, |
324 requestInitialData: requestInitialData, | 353 requestInitialData: requestInitialData, |
325 requestRoute: requestRoute, | 354 requestRoute: requestRoute, |
326 }; | 355 }; |
327 }); | 356 }); |
OLD | NEW |