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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 /** | 48 /** |
| 49 * Handle changes in the visibility of the window, for example by pausing video. | 49 * Handle changes in the visibility of the window, for example by pausing video. |
| 50 * | 50 * |
| 51 * @return {void} Nothing. | 51 * @return {void} Nothing. |
| 52 */ | 52 */ |
| 53 remoting.onVisibilityChanged = function() { | 53 remoting.onVisibilityChanged = function() { |
| 54 if (remoting.clientSession) { | 54 if (remoting.clientSession) { |
| 55 remoting.clientSession.pauseVideo( | 55 remoting.clientSession.pauseVideo( |
| 56 ('hidden' in document) ? document.hidden : document.webkitHidden); | 56 ('hidden' in document) ? document.hidden : document.webkitHidden); |
| 57 } | 57 } |
| 58 } | 58 }; |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * Disconnect the remoting client. | 61 * Disconnect the remoting client. |
| 62 * | 62 * |
| 63 * @return {void} Nothing. | 63 * @return {void} Nothing. |
| 64 */ | 64 */ |
| 65 remoting.disconnect = function() { | 65 remoting.disconnect = function() { |
| 66 if (!remoting.clientSession) { | 66 if (!remoting.clientSession) { |
| 67 return; | 67 return; |
| 68 } | 68 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 82 * | 82 * |
| 83 * @param {remoting.ClientSession.StateEvent} state | 83 * @param {remoting.ClientSession.StateEvent} state |
| 84 */ | 84 */ |
| 85 function onClientStateChange_(state) { | 85 function onClientStateChange_(state) { |
| 86 switch (state.current) { | 86 switch (state.current) { |
| 87 case remoting.ClientSession.State.CLOSED: | 87 case remoting.ClientSession.State.CLOSED: |
| 88 console.log('Connection closed by host'); | 88 console.log('Connection closed by host'); |
| 89 if (remoting.clientSession.getMode() == | 89 if (remoting.clientSession.getMode() == |
| 90 remoting.ClientSession.Mode.IT2ME) { | 90 remoting.ClientSession.Mode.IT2ME) { |
| 91 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); | 91 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); |
| 92 remoting.hrdSessionEvents.raiseEvent( | |
| 93 'sessionStateChanged', | |
|
Jamie
2014/08/05 21:15:13
Can you declare the available session events as an
kelvinp
2014/08/07 18:03:24
I can make the event name into a constant.
We can'
| |
| 94 remoting.hrdSessionEvents.SessionStates.CLOSED); | |
| 92 } else { | 95 } else { |
| 93 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); | 96 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); |
| 94 } | 97 } |
| 95 break; | 98 break; |
| 96 | 99 |
| 97 case remoting.ClientSession.State.FAILED: | 100 case remoting.ClientSession.State.FAILED: |
| 98 var error = remoting.clientSession.getError(); | 101 var error = remoting.clientSession.getError(); |
| 99 console.error('Client plugin reported connection failed: ' + error); | 102 console.error('Client plugin reported connection failed: ' + error); |
| 100 if (error == null) { | 103 if (error == null) { |
| 101 error = remoting.Error.UNEXPECTED; | 104 error = remoting.Error.UNEXPECTED; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 126 */ | 129 */ |
| 127 function showConnectError_(errorTag) { | 130 function showConnectError_(errorTag) { |
| 128 console.error('Connection failed: ' + errorTag); | 131 console.error('Connection failed: ' + errorTag); |
| 129 var errorDiv = document.getElementById('connect-error-message'); | 132 var errorDiv = document.getElementById('connect-error-message'); |
| 130 l10n.localizeElementFromTag(errorDiv, /** @type {string} */ (errorTag)); | 133 l10n.localizeElementFromTag(errorDiv, /** @type {string} */ (errorTag)); |
| 131 remoting.accessCode = ''; | 134 remoting.accessCode = ''; |
| 132 var mode = remoting.clientSession ? remoting.clientSession.getMode() | 135 var mode = remoting.clientSession ? remoting.clientSession.getMode() |
| 133 : remoting.connector.getConnectionMode(); | 136 : remoting.connector.getConnectionMode(); |
| 134 if (mode == remoting.ClientSession.Mode.IT2ME) { | 137 if (mode == remoting.ClientSession.Mode.IT2ME) { |
| 135 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); | 138 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); |
| 139 remoting.hrdSessionEvents.raiseEvent( | |
| 140 'sessionStateChanged', | |
| 141 remoting.hrdSessionEvents.SessionStates.ERROR | |
| 142 ); | |
| 136 } else { | 143 } else { |
| 137 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); | 144 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); |
| 138 } | 145 } |
| 139 } | 146 } |
| 140 | 147 |
| 141 /** | 148 /** |
| 142 * Set the text on the buttons shown under the error message so that they are | 149 * Set the text on the buttons shown under the error message so that they are |
| 143 * easy to understand in the case where a successful connection failed, as | 150 * easy to understand in the case where a successful connection failed, as |
| 144 * opposed to the case where a connection never succeeded. | 151 * opposed to the case where a connection never succeeded. |
| 145 */ | 152 */ |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 remoting.onConnected = function(clientSession) { | 317 remoting.onConnected = function(clientSession) { |
| 311 remoting.clientSession = clientSession; | 318 remoting.clientSession = clientSession; |
| 312 remoting.clientSession.addEventListener('stateChanged', onClientStateChange_); | 319 remoting.clientSession.addEventListener('stateChanged', onClientStateChange_); |
| 313 setConnectionInterruptedButtonsText_(); | 320 setConnectionInterruptedButtonsText_(); |
| 314 document.getElementById('access-code-entry').value = ''; | 321 document.getElementById('access-code-entry').value = ''; |
| 315 remoting.setMode(remoting.AppMode.IN_SESSION); | 322 remoting.setMode(remoting.AppMode.IN_SESSION); |
| 316 remoting.toolbar.center(); | 323 remoting.toolbar.center(); |
| 317 remoting.toolbar.preview(); | 324 remoting.toolbar.preview(); |
| 318 remoting.clipboard.startSession(); | 325 remoting.clipboard.startSession(); |
| 319 updateStatistics_(); | 326 updateStatistics_(); |
| 327 remoting.hrdSessionEvents.raiseEvent( | |
| 328 'sessionStateChanged', | |
| 329 remoting.hrdSessionEvents.SessionStates.CONNECTED | |
| 330 ); | |
| 320 if (remoting.connector.pairingRequested) { | 331 if (remoting.connector.pairingRequested) { |
| 321 /** | 332 /** |
| 322 * @param {string} clientId | 333 * @param {string} clientId |
| 323 * @param {string} sharedSecret | 334 * @param {string} sharedSecret |
| 324 */ | 335 */ |
| 325 var onPairingComplete = function(clientId, sharedSecret) { | 336 var onPairingComplete = function(clientId, sharedSecret) { |
| 326 var pairingInfo = { | 337 var pairingInfo = { |
| 327 pairingInfo: { | 338 pairingInfo: { |
| 328 clientId: clientId, | 339 clientId: clientId, |
| 329 sharedSecret: sharedSecret | 340 sharedSecret: sharedSecret |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 * Create a session connector if one doesn't already exist. | 378 * Create a session connector if one doesn't already exist. |
| 368 */ | 379 */ |
| 369 remoting.ensureSessionConnector_ = function() { | 380 remoting.ensureSessionConnector_ = function() { |
| 370 if (!remoting.connector) { | 381 if (!remoting.connector) { |
| 371 remoting.connector = new remoting.SessionConnector( | 382 remoting.connector = new remoting.SessionConnector( |
| 372 document.getElementById('video-container'), | 383 document.getElementById('video-container'), |
| 373 remoting.onConnected, | 384 remoting.onConnected, |
| 374 showConnectError_, remoting.onExtensionMessage); | 385 showConnectError_, remoting.onExtensionMessage); |
| 375 } | 386 } |
| 376 }; | 387 }; |
| OLD | NEW |