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 from Media Router. | 50 * Populates the WebUI with data obtained from Media Router. |
46 * | 51 * |
47 * @param {{firstRunFlowCloudPrefLearnMoreUrl: string, | 52 * @param {{firstRunFlowCloudPrefLearnMoreUrl: string, |
48 * firstRunFlowLearnMoreUrl: string, | 53 * firstRunFlowLearnMoreUrl: string, |
49 * deviceMissingUrl: string, | 54 * deviceMissingUrl: string, |
50 * sinks: !Array<!media_router.Sink>, | 55 * sinks: !Array<!media_router.Sink>, |
51 * routes: !Array<!media_router.Route>, | 56 * routes: !Array<!media_router.Route>, |
52 * castModes: !Array<!media_router.CastMode>, | 57 * castModes: !Array<!media_router.CastMode>, |
53 * wasFirstRunFlowAcknowledged: boolean, | 58 * wasFirstRunFlowAcknowledged: boolean, |
| 59 * userEmail: string, |
| 60 * userDomain: string, |
| 61 * identityVisibility: number, |
54 * showFirstRunFlowCloudPref: boolean}} data | 62 * showFirstRunFlowCloudPref: boolean}} data |
55 * Parameters in data: | 63 * Parameters in data: |
56 * firstRunFlowCloudPrefLearnMoreUrl - url to open when the cloud services | 64 * firstRunFlowCloudPrefLearnMoreUrl - url to open when the cloud services |
57 * pref learn more link is clicked. | 65 * pref learn more link is clicked. |
58 * firstRunFlowLearnMoreUrl - url to open when the first run flow learn | 66 * firstRunFlowLearnMoreUrl - url to open when the first run flow learn |
59 * more link is clicked. | 67 * more link is clicked. |
60 * deviceMissingUrl - url to be opened on "Device missing?" clicked. | 68 * deviceMissingUrl - url to be opened on "Device missing?" clicked. |
61 * sinks - list of sinks to be displayed. | 69 * sinks - list of sinks to be displayed. |
62 * routes - list of routes that are associated with the sinks. | 70 * routes - list of routes that are associated with the sinks. |
63 * castModes - list of available cast modes. | 71 * castModes - list of available cast modes. |
64 * wasFirstRunFlowAcknowledged - true if first run flow was previously | 72 * wasFirstRunFlowAcknowledged - true if first run flow was previously |
65 * acknowledged by user. | 73 * acknowledged by user. |
| 74 * userEmail - The email of the user if the user is signed in. |
| 75 * userDomain - The domain of the user if the user is signed in. |
| 76 * identityVisibility - State of showing email and user domain. |
66 * showFirstRunFlowCloudPref - true if the cloud pref option should be | 77 * showFirstRunFlowCloudPref - true if the cloud pref option should be |
67 * shown. | 78 * shown. |
68 */ | 79 */ |
69 function setInitialData(data) { | 80 function setInitialData(data) { |
70 container.firstRunFlowCloudPrefLearnMoreUrl = | 81 container.firstRunFlowCloudPrefLearnMoreUrl = |
71 data['firstRunFlowCloudPrefLearnMoreUrl']; | 82 data['firstRunFlowCloudPrefLearnMoreUrl']; |
72 container.firstRunFlowLearnMoreUrl = | 83 container.firstRunFlowLearnMoreUrl = |
73 data['firstRunFlowLearnMoreUrl']; | 84 data['firstRunFlowLearnMoreUrl']; |
74 container.deviceMissingUrl = data['deviceMissingUrl']; | 85 container.deviceMissingUrl = data['deviceMissingUrl']; |
75 container.castModeList = data['castModes']; | 86 container.castModeList = data['castModes']; |
76 container.allSinks = data['sinks']; | 87 container.allSinks = data['sinks']; |
77 container.routeList = data['routes']; | 88 container.routeList = data['routes']; |
| 89 container.userDomain = data['userDomain']; |
| 90 container.showDomain = data['identityVisibility'] == 2; |
| 91 header.userEmail = data['userEmail']; |
| 92 header.showEmail = data['identityVisibility'] > 0; |
78 container.showFirstRunFlowCloudPref = | 93 container.showFirstRunFlowCloudPref = |
79 data['showFirstRunFlowCloudPref']; | 94 data['showFirstRunFlowCloudPref']; |
80 // Some users acknowledged the first run flow before the cloud prefs | 95 // Some users acknowledged the first run flow before the cloud prefs |
81 // setting was implemented. These users will see the first run flow | 96 // setting was implemented. These users will see the first run flow |
82 // again. | 97 // again. |
83 container.showFirstRunFlow = !data['wasFirstRunFlowAcknowledged'] || | 98 container.showFirstRunFlow = !data['wasFirstRunFlowAcknowledged'] || |
84 container.showFirstRunFlowCloudPref; | 99 container.showFirstRunFlowCloudPref; |
85 container.maybeShowRouteDetailsOnOpen(); | 100 container.maybeShowRouteDetailsOnOpen(); |
86 media_router.browserApi.onInitialDataReceived(); | 101 media_router.browserApi.onInitialDataReceived(); |
87 } | 102 } |
(...skipping 11 matching lines...) Expand all Loading... |
99 /** | 114 /** |
100 * Sets the list of currently active routes. | 115 * Sets the list of currently active routes. |
101 * | 116 * |
102 * @param {!Array<!media_router.Route>} routeList | 117 * @param {!Array<!media_router.Route>} routeList |
103 */ | 118 */ |
104 function setRouteList(routeList) { | 119 function setRouteList(routeList) { |
105 container.routeList = routeList; | 120 container.routeList = routeList; |
106 } | 121 } |
107 | 122 |
108 /** | 123 /** |
109 * Sets the list of discovered sinks. | 124 * Sets the list of discovered sinks along with properties of whether to hide |
| 125 * identity of the user email and domain. |
110 * | 126 * |
111 * @param {!Array<!media_router.Sink>} sinkList | 127 * @param {{sinks: !Array<!media_router.Sink>, |
| 128 * identityVisibility: number}} data |
| 129 * Parameters in data: |
| 130 * sinks - list of sinks to be displayed. |
| 131 * identityVisibility - State of showing email and user domain. |
112 */ | 132 */ |
113 function setSinkList(sinkList) { | 133 function setSinkListAndIdentityVisibility(data) { |
114 container.allSinks = sinkList; | 134 container.allSinks = data['sinks']; |
| 135 container.showDomain = data['identityVisibility'] == 2; |
| 136 header.showEmail = data['identityVisibility'] > 0; |
115 } | 137 } |
116 | 138 |
117 /** | 139 /** |
118 * Updates the max height of the dialog | 140 * Updates the max height of the dialog |
119 * | 141 * |
120 * @param {number} height | 142 * @param {number} height |
121 */ | 143 */ |
122 function updateMaxHeight(height) { | 144 function updateMaxHeight(height) { |
123 container.updateMaxDialogHeight(height); | 145 container.updateMaxDialogHeight(height); |
124 } | 146 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 reportNavigateToView: reportNavigateToView, | 331 reportNavigateToView: reportNavigateToView, |
310 reportSelectedCastMode: reportSelectedCastMode, | 332 reportSelectedCastMode: reportSelectedCastMode, |
311 reportRouteCreation: reportRouteCreation, | 333 reportRouteCreation: reportRouteCreation, |
312 reportSinkCount: reportSinkCount, | 334 reportSinkCount: reportSinkCount, |
313 reportTimeToClickSink: reportTimeToClickSink, | 335 reportTimeToClickSink: reportTimeToClickSink, |
314 reportTimeToInitialActionClose: reportTimeToInitialActionClose, | 336 reportTimeToInitialActionClose: reportTimeToInitialActionClose, |
315 requestInitialData: requestInitialData, | 337 requestInitialData: requestInitialData, |
316 requestRoute: requestRoute, | 338 requestRoute: requestRoute, |
317 }; | 339 }; |
318 }); | 340 }); |
OLD | NEW |