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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 // won't find the hostId. If the user clicked on the entry for the local host | 519 // won't find the hostId. If the user clicked on the entry for the local host |
520 // immediately after having enabled it then we won't know it's JID or public | 520 // immediately after having enabled it then we won't know it's JID or public |
521 // key until the host heartbeats and we pull a fresh host list. | 521 // key until the host heartbeats and we pull a fresh host list. |
522 if (!host || !host.jabberId || !host.publicKey) { | 522 if (!host || !host.jabberId || !host.publicKey) { |
523 retryConnectOrReportOffline_(); | 523 retryConnectOrReportOffline_(); |
524 return; | 524 return; |
525 } | 525 } |
526 remoting.hostJid = host.jabberId; | 526 remoting.hostJid = host.jabberId; |
527 remoting.hostPublicKey = host.publicKey; | 527 remoting.hostPublicKey = host.publicKey; |
528 document.getElementById('connected-to').innerText = host.hostName; | 528 document.getElementById('connected-to').innerText = host.hostName; |
529 document.title = document.title + ': ' + host.hostName; | 529 document.title = chrome.i18n.getMessage('PRODUCT_NAME') + ': ' + |
| 530 host.hostName; |
530 | 531 |
531 remoting.WcsLoader.load(connectMe2MeWithAccessToken_); | 532 remoting.WcsLoader.load(connectMe2MeWithAccessToken_); |
532 }; | 533 }; |
533 | 534 |
534 /** | 535 /** |
535 * Continue making the connection to a host, once WCS has initialized. | 536 * Continue making the connection to a host, once WCS has initialized. |
536 * | 537 * |
537 * @param {string?} token The OAuth2 access token, or null if an error occurred. | 538 * @param {string?} token The OAuth2 access token, or null if an error occurred. |
538 * @return {void} Nothing. | 539 * @return {void} Nothing. |
539 */ | 540 */ |
540 function connectMe2MeWithAccessToken_(token) { | 541 function connectMe2MeWithAccessToken_(token) { |
541 if (token) { | 542 if (token) { |
542 /** @type {string} */ | 543 /** @type {string} */ |
543 var pin = document.getElementById('pin-entry').value; | 544 var pin = document.getElementById('pin-entry').value; |
544 | 545 |
545 remoting.clientSession = | 546 remoting.clientSession = |
546 new remoting.ClientSession( | 547 new remoting.ClientSession( |
547 remoting.hostJid, remoting.hostPublicKey, | 548 remoting.hostJid, remoting.hostPublicKey, |
548 pin, 'spake2_hmac,spake2_plain', remoting.hostId, | 549 pin, 'spake2_hmac,spake2_plain', remoting.hostId, |
549 /** @type {string} */ (remoting.oauth2.getCachedEmail()), | 550 /** @type {string} */ (remoting.oauth2.getCachedEmail()), |
550 remoting.ClientSession.Mode.ME2ME, onClientStateChange_); | 551 remoting.ClientSession.Mode.ME2ME, onClientStateChange_); |
551 remoting.clientSession.createPluginAndConnect( | 552 remoting.clientSession.createPluginAndConnect( |
552 document.getElementById('session-mode'), | 553 document.getElementById('session-mode'), |
553 token); | 554 token); |
554 } else { | 555 } else { |
555 showConnectError_(remoting.Error.AUTHENTICATION_FAILED); | 556 showConnectError_(remoting.Error.AUTHENTICATION_FAILED); |
556 } | 557 } |
557 } | 558 } |
OLD | NEW |