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 var remoting = remoting || {}; | 5 var remoting = remoting || {}; |
| 6 | 6 |
| 7 (function() { | 7 (function() { |
| 8 'use strict'; | 8 'use strict'; |
| 9 | 9 |
| 10 window.addEventListener('blur', pluginLostFocus_, false); | 10 window.addEventListener('blur', pluginLostFocus_, false); |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 setClientStateMessage('Connecting as ' + remoting.username); | 451 setClientStateMessage('Connecting as ' + remoting.username); |
| 452 } else if (state == remoting.ClientSession.State.INITIALIZING) { | 452 } else if (state == remoting.ClientSession.State.INITIALIZING) { |
| 453 setClientStateMessage('Initializing connection'); | 453 setClientStateMessage('Initializing connection'); |
| 454 } else if (state == remoting.ClientSession.State.CONNECTED) { | 454 } else if (state == remoting.ClientSession.State.CONNECTED) { |
| 455 var split = remoting.hostJid.split('/'); | 455 var split = remoting.hostJid.split('/'); |
| 456 var host = null; | 456 var host = null; |
| 457 if (split.length == 2) { | 457 if (split.length == 2) { |
| 458 host = split[0]; | 458 host = split[0]; |
| 459 } | 459 } |
| 460 setClientStateMessage('Connected to', host); | 460 setClientStateMessage('Connected to', host); |
| 461 setGlobalMode(remoting.AppMode.IN_SESSION); | |
| 461 updateStatistics(); | 462 updateStatistics(); |
| 462 } else if (state == remoting.ClientSession.State.CLOSED) { | 463 } else if (state == remoting.ClientSession.State.CLOSED) { |
| 463 setClientStateMessage('Closed'); | 464 setClientStateMessage('Closed'); |
| 465 if (remoting.session.state != remoting.ClientSession.State.CONNECTED) { | |
| 466 showConnectError_(404); | |
|
Jamie
2011/07/25 23:09:50
This is not quite correct, as it will report "Inva
awong
2011/07/26 18:51:27
Add TODO?
Jamie
2011/07/26 19:02:35
Done.
| |
| 467 } | |
| 464 } else if (state == remoting.ClientSession.State.CONNECTION_FAILED) { | 468 } else if (state == remoting.ClientSession.State.CONNECTION_FAILED) { |
| 465 setClientStateMessage('Failed'); | 469 setClientStateMessage('Failed'); |
| 466 } else { | 470 } else { |
| 467 setClientStateMessage('Bad State: ' + state); | 471 setClientStateMessage('Bad State: ' + state); |
| 468 } | 472 } |
| 469 } | 473 } |
| 470 | 474 |
| 471 function startSession_() { | 475 function startSession_() { |
| 472 remoting.debug.log('Starting session...'); | 476 remoting.debug.log('Starting session...'); |
| 473 remoting.username = getEmail(); | 477 remoting.username = getEmail(); |
| 474 setGlobalMode(remoting.AppMode.IN_SESSION); | |
| 475 remoting.session = | 478 remoting.session = |
| 476 new remoting.ClientSession(remoting.hostJid, remoting.hostPublicKey, | 479 new remoting.ClientSession(remoting.hostJid, remoting.hostPublicKey, |
| 477 remoting.accessCode, getEmail(), | 480 remoting.accessCode, getEmail(), |
| 478 onClientStateChange_); | 481 onClientStateChange_); |
| 479 remoting.oauth2.callWithToken(function(token) { | 482 remoting.oauth2.callWithToken(function(token) { |
| 480 remoting.session.createPluginAndConnect( | 483 remoting.session.createPluginAndConnect( |
| 481 document.getElementById('session-mode'), | 484 document.getElementById('session-mode'), |
| 482 token); | 485 token); |
| 483 }); | 486 }); |
| 484 } | 487 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 remoting.session = null; | 635 remoting.session = null; |
| 633 remoting.debug.log('Disconnected.'); | 636 remoting.debug.log('Disconnected.'); |
| 634 remoting.setClientMode('unconnected'); | 637 remoting.setClientMode('unconnected'); |
| 635 var accessCode = document.getElementById('access-code-entry'); | 638 var accessCode = document.getElementById('access-code-entry'); |
| 636 accessCode.value = ''; | 639 accessCode.value = ''; |
| 637 setGlobalMode(remoting.AppMode.CLIENT); | 640 setGlobalMode(remoting.AppMode.CLIENT); |
| 638 } | 641 } |
| 639 } | 642 } |
| 640 | 643 |
| 641 }()); | 644 }()); |
| OLD | NEW |