Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 toolbar.style['left'] = toolbarX + 'px'; | 385 toolbar.style['left'] = toolbarX + 'px'; |
| 386 } | 386 } |
| 387 | 387 |
| 388 /** | 388 /** |
| 389 * Start a connection to the specified host, using the stored details. | 389 * Start a connection to the specified host, using the stored details. |
| 390 * | 390 * |
| 391 * @param {string} hostId The Id of the host to connect to. | 391 * @param {string} hostId The Id of the host to connect to. |
| 392 * @return {void} Nothing. | 392 * @return {void} Nothing. |
| 393 */ | 393 */ |
| 394 remoting.connectHost = function(hostId) { | 394 remoting.connectHost = function(hostId) { |
| 395 for (var i = 0; i < remoting.hostList.hosts.length; ++i) { | 395 var hostTableEntry = remoting.hostList.getHostForId(hostId); |
| 396 /** @type {remoting.Host} */ | 396 if (hostTableEntry) { |
|
simonmorris
2011/11/17 23:59:48
"if (!hostTableEntry) { return; }" is simpler.
Jamie
2011/11/18 22:54:57
Done.
| |
| 397 var host = remoting.hostList.hosts[i]; | 397 remoting.hostJid = hostTableEntry.host.jabberId; |
| 398 if (host.hostId != hostId) | 398 remoting.hostPublicKey = hostTableEntry.host.publicKey; |
| 399 continue; | 399 document.getElementById('connected-to').innerText = |
| 400 | 400 hostTableEntry.host.hostName; |
| 401 remoting.hostJid = host.jabberId; | |
| 402 remoting.hostPublicKey = host.publicKey; | |
| 403 document.getElementById('connected-to').innerText = host.hostName; | |
| 404 | 401 |
| 405 remoting.debug.log('Connecting to host...'); | 402 remoting.debug.log('Connecting to host...'); |
| 406 | 403 |
| 407 if (!remoting.wcsLoader) { | 404 if (!remoting.wcsLoader) { |
| 408 remoting.wcsLoader = new remoting.WcsLoader(); | 405 remoting.wcsLoader = new remoting.WcsLoader(); |
| 409 } | 406 } |
| 410 /** @param {function(string):void} setToken The callback function. */ | 407 /** @param {function(string):void} setToken The callback function. */ |
| 411 var callWithToken = function(setToken) { | 408 var callWithToken = function(setToken) { |
| 412 remoting.oauth2.callWithToken(setToken); | 409 remoting.oauth2.callWithToken(setToken); |
| 413 }; | 410 }; |
| 414 remoting.wcsLoader.start( | 411 remoting.wcsLoader.start( |
| 415 remoting.oauth2.getAccessToken(), | 412 remoting.oauth2.getAccessToken(), |
| 416 callWithToken, | 413 callWithToken, |
| 417 remoting.connectHostWithWcs); | 414 remoting.connectHostWithWcs); |
| 418 break; | |
| 419 } | 415 } |
| 420 } | 416 } |
| 421 | 417 |
| 422 /** | 418 /** |
| 423 * Continue making the connection to a host, once WCS has initialized. | 419 * Continue making the connection to a host, once WCS has initialized. |
| 424 * | 420 * |
| 425 * @return {void} Nothing. | 421 * @return {void} Nothing. |
| 426 */ | 422 */ |
| 427 remoting.connectHostWithWcs = function() { | 423 remoting.connectHostWithWcs = function() { |
| 428 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); | 424 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); |
| 429 | 425 |
| 430 remoting.clientSession = | 426 remoting.clientSession = |
| 431 new remoting.ClientSession( | 427 new remoting.ClientSession( |
| 432 remoting.hostJid, remoting.hostPublicKey, | 428 remoting.hostJid, remoting.hostPublicKey, |
| 433 '', /** @type {string} */ (remoting.oauth2.getCachedEmail()), | 429 '', /** @type {string} */ (remoting.oauth2.getCachedEmail()), |
| 434 onClientStateChange_); | 430 onClientStateChange_); |
| 435 /** @param {string} token The auth token. */ | 431 /** @param {string} token The auth token. */ |
| 436 var createPluginAndConnect = function(token) { | 432 var createPluginAndConnect = function(token) { |
| 437 remoting.clientSession.createPluginAndConnect( | 433 remoting.clientSession.createPluginAndConnect( |
| 438 document.getElementById('session-mode'), | 434 document.getElementById('session-mode'), |
| 439 token); | 435 token); |
| 440 }; | 436 }; |
| 441 | 437 |
| 442 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); | 438 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); |
| 443 remoting.oauth2.callWithToken(createPluginAndConnect); | 439 remoting.oauth2.callWithToken(createPluginAndConnect); |
| 444 } | 440 } |
| 445 | 441 |
| 446 }()); | 442 }()); |
| OLD | NEW |