Chromium Code Reviews| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 if (!remoting.clientSession) { | 66 if (!remoting.clientSession) { |
| 67 return; | 67 return; |
| 68 } | 68 } |
| 69 if (remoting.clientSession.getMode() == remoting.ClientSession.Mode.IT2ME) { | 69 if (remoting.clientSession.getMode() == remoting.ClientSession.Mode.IT2ME) { |
| 70 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); | 70 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); |
| 71 } else { | 71 } else { |
| 72 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); | 72 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); |
| 73 } | 73 } |
| 74 remoting.clientSession.disconnect(remoting.Error.NONE); | 74 remoting.clientSession.disconnect(remoting.Error.NONE); |
| 75 remoting.clientSession = null; | 75 remoting.clientSession = null; |
| 76 remoting.app.onDisconnected(); | |
| 76 console.log('Disconnected.'); | 77 console.log('Disconnected.'); |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 /** | 80 /** |
| 80 * Callback function called when the state of the client plugin changes. The | 81 * Callback function called when the state of the client plugin changes. The |
| 81 * current and previous states are available via the |state| member variable. | 82 * current and previous states are available via the |state| member variable. |
| 82 * | 83 * |
| 83 * @param {remoting.ClientSession.StateEvent} state | 84 * @param {remoting.ClientSession.StateEvent} state |
| 84 */ | 85 */ |
| 85 function onClientStateChange_(state) { | 86 function onClientStateChange_(state) { |
| 86 switch (state.current) { | 87 switch (state.current) { |
| 87 case remoting.ClientSession.State.CLOSED: | 88 case remoting.ClientSession.State.CLOSED: |
| 88 console.log('Connection closed by host'); | 89 console.log('Connection closed by host'); |
| 89 if (remoting.clientSession.getMode() == | 90 if (remoting.clientSession.getMode() == |
| 90 remoting.ClientSession.Mode.IT2ME) { | 91 remoting.ClientSession.Mode.IT2ME) { |
| 91 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); | 92 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); |
| 92 remoting.hangoutSessionEvents.raiseEvent( | 93 remoting.hangoutSessionEvents.raiseEvent( |
| 93 remoting.hangoutSessionEvents.sessionStateChanged, | 94 remoting.hangoutSessionEvents.sessionStateChanged, |
| 94 remoting.ClientSession.State.CLOSED); | 95 remoting.ClientSession.State.CLOSED); |
| 95 } else { | 96 } else { |
| 96 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); | 97 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); |
| 97 } | 98 } |
| 99 remoting.app.onDisconnected(); | |
|
Jamie
2014/12/04 22:56:57
It shouldn't be necessary to call this twice. I th
garykac
2014/12/05 19:55:40
Done.
| |
| 98 break; | 100 break; |
| 99 | 101 |
| 100 case remoting.ClientSession.State.FAILED: | 102 case remoting.ClientSession.State.FAILED: |
| 101 var error = remoting.clientSession.getError(); | 103 var error = remoting.clientSession.getError(); |
| 102 console.error('Client plugin reported connection failed: ' + error); | 104 console.error('Client plugin reported connection failed: ' + error); |
| 103 if (error == null) { | 105 if (error == null) { |
| 104 error = remoting.Error.UNEXPECTED; | 106 error = remoting.Error.UNEXPECTED; |
| 105 } | 107 } |
| 106 showConnectError_(error); | 108 showConnectError_(error); |
| 107 break; | 109 break; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 122 | 124 |
| 123 /** | 125 /** |
| 124 * Show a client-side error message. | 126 * Show a client-side error message. |
| 125 * | 127 * |
| 126 * @param {remoting.Error} errorTag The error to be localized and | 128 * @param {remoting.Error} errorTag The error to be localized and |
| 127 * displayed. | 129 * displayed. |
| 128 * @return {void} Nothing. | 130 * @return {void} Nothing. |
| 129 */ | 131 */ |
| 130 function showConnectError_(errorTag) { | 132 function showConnectError_(errorTag) { |
| 131 console.error('Connection failed: ' + errorTag); | 133 console.error('Connection failed: ' + errorTag); |
| 132 var errorDiv = document.getElementById('connect-error-message'); | 134 remoting.app.onError(errorTag); |
|
Jamie
2014/12/04 22:56:57
It might take a bit more untangling, but I would p
garykac
2014/12/05 19:55:40
I originally had that change in a follow-up cl, bu
| |
| 133 l10n.localizeElementFromTag(errorDiv, /** @type {string} */ (errorTag)); | |
| 134 remoting.accessCode = ''; | 135 remoting.accessCode = ''; |
| 135 var mode = remoting.clientSession ? remoting.clientSession.getMode() | |
| 136 : remoting.connector.getConnectionMode(); | |
| 137 if (mode == remoting.ClientSession.Mode.IT2ME) { | |
| 138 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); | |
| 139 remoting.hangoutSessionEvents.raiseEvent( | |
| 140 remoting.hangoutSessionEvents.sessionStateChanged, | |
| 141 remoting.ClientSession.State.FAILED | |
| 142 ); | |
| 143 } else { | |
| 144 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); | |
| 145 } | |
| 146 } | 136 } |
| 147 | 137 |
| 148 /** | 138 /** |
| 149 * Set the text on the buttons shown under the error message so that they are | |
| 150 * easy to understand in the case where a successful connection failed, as | |
| 151 * opposed to the case where a connection never succeeded. | |
| 152 */ | |
| 153 function setConnectionInterruptedButtonsText_() { | |
| 154 var button1 = document.getElementById('client-reconnect-button'); | |
| 155 l10n.localizeElementFromTag(button1, /*i18n-content*/'RECONNECT'); | |
| 156 button1.removeAttribute('autofocus'); | |
| 157 var button2 = document.getElementById('client-finished-me2me-button'); | |
| 158 l10n.localizeElementFromTag(button2, /*i18n-content*/'OK'); | |
| 159 button2.setAttribute('autofocus', 'autofocus'); | |
| 160 } | |
| 161 | |
| 162 /** | |
| 163 * Timer callback to update the statistics panel. | 139 * Timer callback to update the statistics panel. |
| 164 */ | 140 */ |
| 165 function updateStatistics_() { | 141 function updateStatistics_() { |
| 166 if (!remoting.clientSession || | 142 if (!remoting.clientSession || |
| 167 remoting.clientSession.getState() != | 143 remoting.clientSession.getState() != |
| 168 remoting.ClientSession.State.CONNECTED) { | 144 remoting.ClientSession.State.CONNECTED) { |
| 169 return; | 145 return; |
| 170 } | 146 } |
| 171 var perfstats = remoting.clientSession.getPerfStats(); | 147 var perfstats = remoting.clientSession.getPerfStats(); |
| 172 remoting.stats.update(perfstats); | 148 remoting.stats.update(perfstats); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 clientId, sharedSecret); | 287 clientId, sharedSecret); |
| 312 } | 288 } |
| 313 | 289 |
| 314 remoting.HostSettings.load(host.hostId, connectMe2MeHostSettingsRetrieved); | 290 remoting.HostSettings.load(host.hostId, connectMe2MeHostSettingsRetrieved); |
| 315 }; | 291 }; |
| 316 | 292 |
| 317 /** @param {remoting.ClientSession} clientSession */ | 293 /** @param {remoting.ClientSession} clientSession */ |
| 318 remoting.onConnected = function(clientSession) { | 294 remoting.onConnected = function(clientSession) { |
| 319 remoting.clientSession = clientSession; | 295 remoting.clientSession = clientSession; |
| 320 remoting.clientSession.addEventListener('stateChanged', onClientStateChange_); | 296 remoting.clientSession.addEventListener('stateChanged', onClientStateChange_); |
| 321 setConnectionInterruptedButtonsText_(); | 297 |
| 322 document.getElementById('access-code-entry').value = ''; | 298 remoting.app.onConnected(); |
|
Jamie
2014/12/04 22:56:57
What's the rationale for moving some, but not all
garykac
2014/12/05 19:55:40
I'm separating out the shared code from the CRD-sp
| |
| 323 remoting.setMode(remoting.AppMode.IN_SESSION); | 299 |
| 324 if (!base.isAppsV2()) { | |
| 325 remoting.toolbar.center(); | |
| 326 remoting.toolbar.preview(); | |
| 327 } | |
| 328 remoting.clipboard.startSession(); | 300 remoting.clipboard.startSession(); |
| 329 updateStatistics_(); | 301 updateStatistics_(); |
| 330 remoting.hangoutSessionEvents.raiseEvent( | 302 remoting.hangoutSessionEvents.raiseEvent( |
| 331 remoting.hangoutSessionEvents.sessionStateChanged, | 303 remoting.hangoutSessionEvents.sessionStateChanged, |
| 332 remoting.ClientSession.State.CONNECTED | 304 remoting.ClientSession.State.CONNECTED |
| 333 ); | 305 ); |
| 306 | |
| 334 if (remoting.pairingRequested) { | 307 if (remoting.pairingRequested) { |
| 335 /** | 308 /** |
| 336 * @param {string} clientId | 309 * @param {string} clientId |
| 337 * @param {string} sharedSecret | 310 * @param {string} sharedSecret |
| 338 */ | 311 */ |
| 339 var onPairingComplete = function(clientId, sharedSecret) { | 312 var onPairingComplete = function(clientId, sharedSecret) { |
| 340 var pairingInfo = { | 313 var pairingInfo = { |
| 341 pairingInfo: { | 314 pairingInfo: { |
| 342 clientId: clientId, | 315 clientId: clientId, |
| 343 sharedSecret: sharedSecret | 316 sharedSecret: sharedSecret |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 * Create a session connector if one doesn't already exist. | 357 * Create a session connector if one doesn't already exist. |
| 385 */ | 358 */ |
| 386 remoting.ensureSessionConnector_ = function() { | 359 remoting.ensureSessionConnector_ = function() { |
| 387 if (!remoting.connector) { | 360 if (!remoting.connector) { |
| 388 remoting.connector = remoting.SessionConnector.factory.createConnector( | 361 remoting.connector = remoting.SessionConnector.factory.createConnector( |
| 389 document.getElementById('video-container'), | 362 document.getElementById('video-container'), |
| 390 remoting.onConnected, | 363 remoting.onConnected, |
| 391 showConnectError_, remoting.onExtensionMessage); | 364 showConnectError_, remoting.onExtensionMessage); |
| 392 } | 365 } |
| 393 }; | 366 }; |
| OLD | NEW |