Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: chrome/browser/resources/media_router/media_router_ui_interface.js

Issue 1415103006: Non-Local Join for Media Router and Presentation API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing Logging Statements Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /** 13 /**
14 * Handles timeout of previous create route attempt. 14 * Handles timeout of previous create route attempt.
15 */ 15 */
16 function onNotifyRouteCreationTimeout() { 16 function onNotifyRouteCreationTimeout() {
17 container.onNotifyRouteCreationTimeout(); 17 container.onNotifyRouteCreationTimeout();
18 } 18 }
19 19
20 /** 20 /**
21 * Handles response of previous create route attempt. 21 * Handles response of previous create route attempt.
22 * 22 *
23 * @param {string} sinkId The ID of the sink to which the Media Route was 23 * @param {string} sinkId The ID of the sink to which the Media Route was
24 * creating a route. 24 * creating a route.
25 * @param {?media_router.Route} route The newly create route to the sink 25 * @param {?media_router.Route} route The newly create route to the sink
26 * if route creation succeeded; null otherwise 26 * if route creation succeeded; null otherwise
27 */ 27 */
28 function onCreateRouteResponseReceived(sinkId, route) { 28 function onCreateRouteResponseReceived(sinkId, route) {
29 console.log('media_router.ui.onCreateRouteResponseReceived: ' + sinkId);
29 container.onCreateRouteResponseReceived(sinkId, route); 30 container.onCreateRouteResponseReceived(sinkId, route);
30 } 31 }
31 32
33
34 function onCanJoin(canJoin) { container.setCanJoin(canJoin); }
35
32 /** 36 /**
33 * Sets the cast mode list. 37 * Sets the cast mode list.
34 * 38 *
35 * @param {!Array<!media_router.CastMode>} castModeList 39 * @param {!Array<!media_router.CastMode>} castModeList
36 */ 40 */
37 function setCastModeList(castModeList) { 41 function setCastModeList(castModeList) {
38 container.castModeList = castModeList; 42 container.castModeList = castModeList;
39 } 43 }
40 44
41 /** 45 /**
(...skipping 18 matching lines...) Expand all
60 * sinks - list of sinks to be displayed. 64 * sinks - list of sinks to be displayed.
61 * routes - list of routes that are associated with the sinks. 65 * routes - list of routes that are associated with the sinks.
62 * castModes - list of available cast modes. 66 * castModes - list of available cast modes.
63 * initialCastModeType - cast mode to show initially. Expected to be 67 * initialCastModeType - cast mode to show initially. Expected to be
64 * included in |castModes|. 68 * included in |castModes|.
65 */ 69 */
66 function setInitialData(data) { 70 function setInitialData(data) {
67 container.deviceMissingUrl = data['deviceMissingUrl']; 71 container.deviceMissingUrl = data['deviceMissingUrl'];
68 container.allSinks = data['sinks']; 72 container.allSinks = data['sinks'];
69 container.routeList = data['routes']; 73 container.routeList = data['routes'];
70 container.initializeCastModes(data['castModes'], 74 container.initializeCastModes(
71 data['initialCastModeType']); 75 data['castModes'], data['initialCastModeType']);
72 } 76 }
73 77
74 /** 78 /**
75 * Sets current issue to |issue|, or clears the current issue if |issue| is 79 * Sets current issue to |issue|, or clears the current issue if |issue| is
76 * null. 80 * null.
77 * 81 *
78 * @param {?media_router.Issue} issue 82 * @param {?media_router.Issue} issue
79 */ 83 */
80 function setIssue(issue) { 84 function setIssue(issue) { container.issue = issue; }
81 container.issue = issue;
82 }
83 85
84 /** 86 /**
85 * Sets the list of currently active routes. 87 * Sets the list of currently active routes.
86 * 88 *
87 * @param {!Array<!media_router.Route>} routeList 89 * @param {!Array<!media_router.Route>} routeList
88 */ 90 */
89 function setRouteList(routeList) { 91 function setRouteList(routeList) { container.routeList = routeList; }
90 container.routeList = routeList;
91 }
92 92
93 /** 93 /**
94 * Sets the list of discovered sinks. 94 * Sets the list of discovered sinks.
95 * 95 *
96 * @param {!Array<!media_router.Sink>} sinkList 96 * @param {!Array<!media_router.Sink>} sinkList
97 */ 97 */
98 function setSinkList(sinkList) { 98 function setSinkList(sinkList) { container.allSinks = sinkList; }
99 container.allSinks = sinkList;
100 }
101 99
102 return { 100 return {
103 onNotifyRouteCreationTimeout: onNotifyRouteCreationTimeout, 101 onNotifyRouteCreationTimeout: onNotifyRouteCreationTimeout,
104 onCreateRouteResponseReceived: onCreateRouteResponseReceived, 102 onCreateRouteResponseReceived: onCreateRouteResponseReceived,
103 onCanJoin: onCanJoin,
105 setCastModeList: setCastModeList, 104 setCastModeList: setCastModeList,
106 setContainer: setContainer, 105 setContainer: setContainer,
107 setInitialData: setInitialData, 106 setInitialData: setInitialData,
108 setIssue: setIssue, 107 setIssue: setIssue,
109 setRouteList: setRouteList, 108 setRouteList: setRouteList,
110 setSinkList: setSinkList, 109 setSinkList: setSinkList,
111 }; 110 };
112 }); 111 });
113 112
114 // API invoked by this UI to communicate with the browser WebUI message handler. 113 // API invoked by this UI to communicate with the browser WebUI message handler.
115 cr.define('media_router.browserApi', function() { 114 cr.define('media_router.browserApi', function() {
116 'use strict'; 115 'use strict';
117 116
118 /** 117 /**
119 * Acts on the given issue. 118 * Acts on the given issue.
120 * 119 *
121 * @param {string} issueId 120 * @param {string} issueId
122 * @param {number} actionType Type of action that the user clicked. 121 * @param {number} actionType Type of action that the user clicked.
123 * @param {?number} helpPageId The numeric help center ID. 122 * @param {?number} helpPageId The numeric help center ID.
124 */ 123 */
125 function actOnIssue(issueId, actionType, helpPageId) { 124 function actOnIssue(issueId, actionType, helpPageId) {
126 chrome.send('actOnIssue', [{issueId: issueId, actionType: actionType, 125 chrome.send(
127 helpPageId: helpPageId}]); 126 'actOnIssue',
127 [{issueId: issueId, actionType: actionType, helpPageId: helpPageId}]);
128 } 128 }
129 129
130 /** 130 /**
131 * Closes the dialog. 131 * Closes the dialog.
132 */ 132 */
133 function closeDialog() { 133 function closeDialog() { chrome.send('closeDialog'); }
134 chrome.send('closeDialog');
135 }
136 134
137 /** 135 /**
138 * Closes the given route. 136 * Closes the given route.
139 * 137 *
140 * @param {!media_router.Route} route 138 * @param {!media_router.Route} route
141 */ 139 */
142 function closeRoute(route) { 140 function closeRoute(route) {
143 chrome.send('closeRoute', [{routeId: route.id}]); 141 chrome.send('closeRoute', [{routeId: route.id}]);
144 } 142 }
145 143
146 /** 144 /**
145 * Joins the given route.
146 *
147 * @param {!media_router.Route} route
148 */
149 function joinRoute(route) {
150 chrome.send('joinRoute', [{sinkId: route.sinkId, routeId: route.id}]);
151 }
152
153 /**
154 * Asks the provider if the given route can be joined.
155 *
156 * @param {!media_router.Route} route
157 */
158 function canJoinRoute(route) {
159 chrome.send('canJoin', [{routeId: route.id}]);
160 }
161
162 /**
147 * Reports the current number of sinks. 163 * Reports the current number of sinks.
148 * 164 *
149 * @param {number} sinkCount 165 * @param {number} sinkCount
150 */ 166 */
151 function reportSinkCount(sinkCount) { 167 function reportSinkCount(sinkCount) {
152 chrome.send('reportSinkCount', [sinkCount]); 168 chrome.send('reportSinkCount', [sinkCount]);
153 } 169 }
154 170
155 /** 171 /**
156 * Requests data to initialize the WebUI with. 172 * Requests data to initialize the WebUI with.
157 * The data will be returned via media_router.ui.setInitialData. 173 * The data will be returned via media_router.ui.setInitialData.
158 */ 174 */
159 function requestInitialData() { 175 function requestInitialData() { chrome.send('requestInitialData'); }
160 chrome.send('requestInitialData');
161 }
162 176
163 /** 177 /**
164 * Requests that a media route be started with the given sink. 178 * Requests that a media route be started with the given sink.
165 * 179 *
166 * @param {string} sinkId The sink ID. 180 * @param {string} sinkId The sink ID.
167 * @param {number} selectedCastMode The value of the cast mode the user 181 * @param {number} selectedCastMode The value of the cast mode the user
168 * selected. 182 * selected.
169 */ 183 */
170 function requestRoute(sinkId, selectedCastMode) { 184 function requestRoute(sinkId, selectedCastMode) {
171 chrome.send('requestRoute', 185 chrome.send(
172 [{sinkId: sinkId, selectedCastMode: selectedCastMode}]); 186 'requestRoute', [{sinkId: sinkId, selectedCastMode: selectedCastMode}]);
173 } 187 }
174 188
175 return { 189 return {
176 actOnIssue: actOnIssue, 190 actOnIssue: actOnIssue,
177 closeDialog: closeDialog, 191 closeDialog: closeDialog,
178 closeRoute: closeRoute, 192 closeRoute: closeRoute,
193 joinRoute: joinRoute,
194 canJoinRoute: canJoinRoute,
179 reportSinkCount: reportSinkCount, 195 reportSinkCount: reportSinkCount,
180 requestInitialData: requestInitialData, 196 requestInitialData: requestInitialData,
181 requestRoute: requestRoute, 197 requestRoute: requestRoute,
182 }; 198 };
183 }); 199 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698