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 /** @suppress {duplicate} */ | 10 /** @suppress {duplicate} */ |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 remoting.ChromotingEvent.SessionState.CONNECTING); | 118 remoting.ChromotingEvent.SessionState.CONNECTING); |
119 document.getElementById('cancel-share-button').disabled = false; | 119 document.getElementById('cancel-share-button').disabled = false; |
120 disableTimeoutCountdown_(); | 120 disableTimeoutCountdown_(); |
121 | 121 |
122 console.assert(hostSession_ === null, '|hostSession_| already exists.'); | 122 console.assert(hostSession_ === null, '|hostSession_| already exists.'); |
123 hostSession_ = new remoting.HostSession(); | 123 hostSession_ = new remoting.HostSession(); |
124 remoting.identity.getEmail().then( | 124 remoting.identity.getEmail().then( |
125 function(/** string */ email) { | 125 function(/** string */ email) { |
126 hostSession_.connect( | 126 hostSession_.connect( |
127 hostFacade, email, token, onHostStateChanged_, | 127 hostFacade, email, token, onHostStateChanged_, |
128 onNatTraversalPolicyChanged_, logDebugInfo_, it2meConnectFailed_); | 128 onNatTraversalPolicyChanged_, logDebugInfo_, showShareError_); |
129 }); | 129 }); |
130 }; | 130 }; |
131 | 131 |
132 /** | 132 /** |
133 * Callback for the host plugin to notify the web app of state changes. | 133 * Callback for the host plugin to notify the web app of state changes. |
134 * @param {remoting.HostSession.State} state The new state of the plugin. | 134 * @param {remoting.HostSession.State} state The new state of the plugin. |
135 * @return {void} Nothing. | 135 * @return {void} Nothing. |
136 */ | 136 */ |
137 function onHostStateChanged_(state) { | 137 function onHostStateChanged_(state) { |
138 if (state == remoting.HostSession.State.STARTING) { | 138 if (state == remoting.HostSession.State.STARTING) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 l10n.localizeElementFromTag(errorDiv, error.getTag()); | 240 l10n.localizeElementFromTag(errorDiv, error.getTag()); |
241 console.error('Sharing error: ' + error.toString()); | 241 console.error('Sharing error: ' + error.toString()); |
242 remoting.setMode(remoting.AppMode.HOST_SHARE_FAILED); | 242 remoting.setMode(remoting.AppMode.HOST_SHARE_FAILED); |
243 it2meLogger.logSessionStateChange( | 243 it2meLogger.logSessionStateChange( |
244 remoting.ChromotingEvent.SessionState.CONNECTION_FAILED, error); | 244 remoting.ChromotingEvent.SessionState.CONNECTION_FAILED, error); |
245 } | 245 } |
246 | 246 |
247 cleanUp(); | 247 cleanUp(); |
248 } | 248 } |
249 | 249 |
250 /** | |
251 * Show a sharing error with error code UNEXPECTED . | |
252 * | |
253 * @return {void} Nothing. | |
254 */ | |
255 function it2meConnectFailed_() { | |
256 showShareError_(remoting.Error.unexpected()); | |
257 } | |
258 | |
259 function cleanUp() { | 250 function cleanUp() { |
260 base.dispose(hostSession_); | 251 base.dispose(hostSession_); |
261 hostSession_ = null; | 252 hostSession_ = null; |
262 } | 253 } |
263 | 254 |
264 /** | 255 /** |
265 * Cancel an active or pending it2me share operation. | 256 * Cancel an active or pending it2me share operation. |
266 * | 257 * |
267 * @return {void} Nothing. | 258 * @return {void} Nothing. |
268 */ | 259 */ |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 function createLogger_() { | 381 function createLogger_() { |
391 // Create a new logger for each session to refresh the session id. | 382 // Create a new logger for each session to refresh the session id. |
392 var logger = new remoting.SessionLogger( | 383 var logger = new remoting.SessionLogger( |
393 remoting.ChromotingEvent.Role.HOST, | 384 remoting.ChromotingEvent.Role.HOST, |
394 remoting.TelemetryEventWriter.Client.write); | 385 remoting.TelemetryEventWriter.Client.write); |
395 logger.setLogEntryMode(remoting.ChromotingEvent.Mode.IT2ME); | 386 logger.setLogEntryMode(remoting.ChromotingEvent.Mode.IT2ME); |
396 return logger; | 387 return logger; |
397 } | 388 } |
398 | 389 |
399 })(); | 390 })(); |
OLD | NEW |