| 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 'host screen' for Chromoting. | 7 * Functions related to the 'host screen' for Chromoting. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 * @private | 85 * @private |
| 86 */ | 86 */ |
| 87 remoting.tryShareWithToken_ = function(hostFacade, token) { | 87 remoting.tryShareWithToken_ = function(hostFacade, token) { |
| 88 lastShareWasCancelled_ = false; | 88 lastShareWasCancelled_ = false; |
| 89 onNatTraversalPolicyChanged_(true); // Hide warning by default. | 89 onNatTraversalPolicyChanged_(true); // Hide warning by default. |
| 90 remoting.setMode(remoting.AppMode.HOST_WAITING_FOR_CODE); | 90 remoting.setMode(remoting.AppMode.HOST_WAITING_FOR_CODE); |
| 91 document.getElementById('cancel-share-button').disabled = false; | 91 document.getElementById('cancel-share-button').disabled = false; |
| 92 disableTimeoutCountdown_(); | 92 disableTimeoutCountdown_(); |
| 93 | 93 |
| 94 remoting.hostSession = new remoting.HostSession(); | 94 remoting.hostSession = new remoting.HostSession(); |
| 95 var email = /** @type {string} */remoting.identity.getCachedEmail(); | 95 var email = /** @type {string} */ (remoting.identity.getCachedEmail()); |
| 96 remoting.hostSession.connect( | 96 remoting.hostSession.connect( |
| 97 hostFacade, email, token, onHostStateChanged_, | 97 hostFacade, email, token, onHostStateChanged_, |
| 98 onNatTraversalPolicyChanged_, logDebugInfo_, it2meConnectFailed_); | 98 onNatTraversalPolicyChanged_, logDebugInfo_, it2meConnectFailed_); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 /** | 101 /** |
| 102 * Callback for the host plugin to notify the web app of state changes. | 102 * Callback for the host plugin to notify the web app of state changes. |
| 103 * @param {remoting.HostSession.State} state The new state of the plugin. | 103 * @param {remoting.HostSession.State} state The new state of the plugin. |
| 104 * @return {void} Nothing. | 104 * @return {void} Nothing. |
| 105 * @private | 105 * @private |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 * Cancel an active or pending it2me share operation. | 216 * Cancel an active or pending it2me share operation. |
| 217 * | 217 * |
| 218 * @return {void} Nothing. | 218 * @return {void} Nothing. |
| 219 */ | 219 */ |
| 220 remoting.cancelShare = function() { | 220 remoting.cancelShare = function() { |
| 221 document.getElementById('cancel-share-button').disabled = true; | 221 document.getElementById('cancel-share-button').disabled = true; |
| 222 console.log('Canceling share...'); | 222 console.log('Canceling share...'); |
| 223 remoting.lastShareWasCancelled = true; | 223 remoting.lastShareWasCancelled = true; |
| 224 try { | 224 try { |
| 225 remoting.hostSession.disconnect(); | 225 remoting.hostSession.disconnect(); |
| 226 } catch (error) { | 226 } catch (/** @type {*} */ error) { |
| 227 // Hack to force JSCompiler type-safety. | 227 console.error('Error disconnecting: ' + error + |
| 228 var errorTyped = /** @type {{description: string}} */ error; | |
| 229 console.error('Error disconnecting: ' + errorTyped.description + | |
| 230 '. The host probably crashed.'); | 228 '. The host probably crashed.'); |
| 231 // TODO(jamiewalch): Clean this up. We should have a class representing | 229 // TODO(jamiewalch): Clean this up. We should have a class representing |
| 232 // the host plugin, like we do for the client, which should handle crash | 230 // the host plugin, like we do for the client, which should handle crash |
| 233 // reporting and it should use a more detailed error message than the | 231 // reporting and it should use a more detailed error message than the |
| 234 // default 'generic' one. See crbug.com/94624 | 232 // default 'generic' one. See crbug.com/94624 |
| 235 showShareError_(remoting.Error.UNEXPECTED); | 233 showShareError_(remoting.Error.UNEXPECTED); |
| 236 } | 234 } |
| 237 disableTimeoutCountdown_(); | 235 disableTimeoutCountdown_(); |
| 238 }; | 236 }; |
| 239 | 237 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 * @private | 332 * @private |
| 335 */ | 333 */ |
| 336 function onNatTraversalPolicyChanged_(enabled) { | 334 function onNatTraversalPolicyChanged_(enabled) { |
| 337 var natBox = document.getElementById('nat-box'); | 335 var natBox = document.getElementById('nat-box'); |
| 338 if (enabled) { | 336 if (enabled) { |
| 339 natBox.classList.add('traversal-enabled'); | 337 natBox.classList.add('traversal-enabled'); |
| 340 } else { | 338 } else { |
| 341 natBox.classList.remove('traversal-enabled'); | 339 natBox.classList.remove('traversal-enabled'); |
| 342 } | 340 } |
| 343 } | 341 } |
| OLD | NEW |