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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 * Parse the response from the server to a request to resolve a support id. | 368 * Parse the response from the server to a request to resolve a support id. |
369 * | 369 * |
370 * @param {XMLHttpRequest} xhr The XMLHttpRequest object. | 370 * @param {XMLHttpRequest} xhr The XMLHttpRequest object. |
371 * @return {void} Nothing. | 371 * @return {void} Nothing. |
372 */ | 372 */ |
373 function parseServerResponse_(xhr) { | 373 function parseServerResponse_(xhr) { |
374 remoting.supportHostsXhr_ = null; | 374 remoting.supportHostsXhr_ = null; |
375 console.log('parseServerResponse: xhr = ' + xhr); | 375 console.log('parseServerResponse: xhr = ' + xhr); |
376 if (xhr.status == 200) { | 376 if (xhr.status == 200) { |
377 var host = /** @type {{data: {jabberId: string, publicKey: string}}} */ | 377 var host = /** @type {{data: {jabberId: string, publicKey: string}}} */ |
378 JSON.parse(xhr.responseText); | 378 jsonParseSafe(xhr.responseText); |
379 if (host.data && host.data.jabberId && host.data.publicKey) { | 379 if (host && host.data && host.data.jabberId && host.data.publicKey) { |
380 remoting.hostJid = host.data.jabberId; | 380 remoting.hostJid = host.data.jabberId; |
381 remoting.hostPublicKey = host.data.publicKey; | 381 remoting.hostPublicKey = host.data.publicKey; |
382 var split = remoting.hostJid.split('/'); | 382 var split = remoting.hostJid.split('/'); |
383 document.getElementById('connected-to').innerText = split[0]; | 383 document.getElementById('connected-to').innerText = split[0]; |
384 startSession_(); | 384 startSession_(); |
385 return; | 385 return; |
| 386 } else { |
| 387 console.error('Invalid "support-hosts" response from server.'); |
386 } | 388 } |
387 } | 389 } |
388 var errorMsg = remoting.Error.GENERIC; | 390 var errorMsg = remoting.Error.GENERIC; |
389 if (xhr.status == 404) { | 391 if (xhr.status == 404) { |
390 errorMsg = remoting.Error.INVALID_ACCESS_CODE; | 392 errorMsg = remoting.Error.INVALID_ACCESS_CODE; |
391 } else if (xhr.status == 0) { | 393 } else if (xhr.status == 0) { |
392 errorMsg = remoting.Error.NO_RESPONSE; | 394 errorMsg = remoting.Error.NO_RESPONSE; |
393 } else if (xhr.status == 503) { | 395 } else if (xhr.status == 503) { |
394 errorMsg = remoting.Error.SERVICE_UNAVAILABLE; | 396 errorMsg = remoting.Error.SERVICE_UNAVAILABLE; |
395 } else { | 397 } else { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 pin, 'spake2_hmac,spake2_plain', remoting.hostId, | 538 pin, 'spake2_hmac,spake2_plain', remoting.hostId, |
537 /** @type {string} */ (remoting.oauth2.getCachedEmail()), | 539 /** @type {string} */ (remoting.oauth2.getCachedEmail()), |
538 remoting.ClientSession.Mode.ME2ME, onClientStateChange_); | 540 remoting.ClientSession.Mode.ME2ME, onClientStateChange_); |
539 remoting.clientSession.createPluginAndConnect( | 541 remoting.clientSession.createPluginAndConnect( |
540 document.getElementById('session-mode'), | 542 document.getElementById('session-mode'), |
541 token); | 543 token); |
542 } else { | 544 } else { |
543 showConnectError_(remoting.Error.AUTHENTICATION_FAILED); | 545 showConnectError_(remoting.Error.AUTHENTICATION_FAILED); |
544 } | 546 } |
545 } | 547 } |
OLD | NEW |