OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Functions related to the 'client screen' for Chromoting. | 7 * Functions related to the 'client screen' for Chromoting. |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 */ | 244 */ |
245 remoting.connectMe2MeHostVersionAcknowledged_ = function(host) { | 245 remoting.connectMe2MeHostVersionAcknowledged_ = function(host) { |
246 if (!remoting.connector) { | 246 if (!remoting.connector) { |
247 remoting.connector = new remoting.SessionConnector( | 247 remoting.connector = new remoting.SessionConnector( |
248 document.getElementById('session-mode'), | 248 document.getElementById('session-mode'), |
249 remoting.onConnected, | 249 remoting.onConnected, |
250 showConnectError_); | 250 showConnectError_); |
251 } | 251 } |
252 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); | 252 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); |
253 | 253 |
| 254 /** |
| 255 * @param {string} tokenUrl Token-issue URL received from the host. |
| 256 * @param {string} scope OAuth scope to request the token for. |
| 257 * @param {function(string, string):void} onThirdPartyTokenFetched Callback. |
| 258 */ |
| 259 var fetchThirdPartyToken = function( |
| 260 tokenUrl, hostPublicKey, scope, onThirdPartyTokenFetched) { |
| 261 var thirdPartyTokenFetcher = new remoting.ThirdPartyTokenFetcher( |
| 262 tokenUrl, hostPublicKey, scope, host.tokenUrlPatterns, |
| 263 onThirdPartyTokenFetched); |
| 264 thirdPartyTokenFetcher.fetchToken(); |
| 265 }; |
| 266 |
254 /** @param {function(string):void} onPinFetched */ | 267 /** @param {function(string):void} onPinFetched */ |
255 var requestPin = function(onPinFetched) { | 268 var requestPin = function(onPinFetched) { |
256 /** @type {Element} */ | 269 /** @type {Element} */ |
257 var pinForm = document.getElementById('pin-form'); | 270 var pinForm = document.getElementById('pin-form'); |
258 /** @type {Element} */ | 271 /** @type {Element} */ |
259 var pinCancel = document.getElementById('cancel-pin-entry-button'); | 272 var pinCancel = document.getElementById('cancel-pin-entry-button'); |
260 /** | 273 /** |
261 * Event handler for both the 'submit' and 'cancel' actions. Using | 274 * Event handler for both the 'submit' and 'cancel' actions. Using |
262 * a single handler for both greatly simplifies the task of making | 275 * a single handler for both greatly simplifies the task of making |
263 * them one-shot. If separate handlers were used, each would have | 276 * them one-shot. If separate handlers were used, each would have |
(...skipping 15 matching lines...) Expand all Loading... |
279 remoting.setMode(remoting.AppMode.HOME); | 292 remoting.setMode(remoting.AppMode.HOME); |
280 } | 293 } |
281 }; | 294 }; |
282 pinForm.addEventListener('submit', onSubmitOrCancel, false); | 295 pinForm.addEventListener('submit', onSubmitOrCancel, false); |
283 pinCancel.addEventListener('click', onSubmitOrCancel, false); | 296 pinCancel.addEventListener('click', onSubmitOrCancel, false); |
284 | 297 |
285 var message = document.getElementById('pin-message'); | 298 var message = document.getElementById('pin-message'); |
286 l10n.localizeElement(message, host.hostName); | 299 l10n.localizeElement(message, host.hostName); |
287 remoting.setMode(remoting.AppMode.CLIENT_PIN_PROMPT); | 300 remoting.setMode(remoting.AppMode.CLIENT_PIN_PROMPT); |
288 }; | 301 }; |
289 remoting.connector.connectMe2Me(host, requestPin); | 302 remoting.connector.connectMe2Me(host, requestPin, fetchThirdPartyToken); |
290 }; | 303 }; |
291 | 304 |
292 /** @param {remoting.ClientSession} clientSession */ | 305 /** @param {remoting.ClientSession} clientSession */ |
293 remoting.onConnected = function(clientSession) { | 306 remoting.onConnected = function(clientSession) { |
294 remoting.clientSession = clientSession; | 307 remoting.clientSession = clientSession; |
295 remoting.clientSession.setOnStateChange(onClientStateChange_); | 308 remoting.clientSession.setOnStateChange(onClientStateChange_); |
296 setConnectionInterruptedButtonsText_(); | 309 setConnectionInterruptedButtonsText_(); |
297 var connectedTo = document.getElementById('connected-to'); | 310 var connectedTo = document.getElementById('connected-to'); |
298 connectedTo.innerText = clientSession.hostDisplayName; | 311 connectedTo.innerText = clientSession.hostDisplayName; |
299 remoting.setMode(remoting.AppMode.IN_SESSION); | 312 remoting.setMode(remoting.AppMode.IN_SESSION); |
300 remoting.toolbar.center(); | 313 remoting.toolbar.center(); |
301 remoting.toolbar.preview(); | 314 remoting.toolbar.preview(); |
302 remoting.clipboard.startSession(); | 315 remoting.clipboard.startSession(); |
303 updateStatistics_(); | 316 updateStatistics_(); |
304 }; | 317 }; |
OLD | NEW |