OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 * Connect set-up state machine for Me2Me and IT2Me | 7 * Connect set-up state machine for Me2Me and IT2Me |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // Initialize/declare per-connection state. | 110 // Initialize/declare per-connection state. |
111 this.reset(); | 111 this.reset(); |
112 }; | 112 }; |
113 | 113 |
114 /** | 114 /** |
115 * Reset the per-connection state so that the object can be re-used for a | 115 * Reset the per-connection state so that the object can be re-used for a |
116 * second connection. Note the none of the shared WCS state is reset. | 116 * second connection. Note the none of the shared WCS state is reset. |
117 */ | 117 */ |
118 remoting.SessionConnectorImpl.prototype.reset = function() { | 118 remoting.SessionConnectorImpl.prototype.reset = function() { |
119 /** | 119 /** |
120 * String used to identify the host to which to connect. For IT2Me, this is | |
121 * the first 7 digits of the access code; for Me2Me it is the host identifier. | |
122 * | |
123 * @type {string} | |
124 * @private | |
125 */ | |
126 this.hostId_ = ''; | |
127 | |
128 /** | |
129 * For paired connections, the client id of this device, issued by the host. | 120 * For paired connections, the client id of this device, issued by the host. |
130 * | 121 * |
131 * @type {string} | 122 * @type {string} |
132 * @private | 123 * @private |
133 */ | 124 */ |
134 this.clientPairingId_ = ''; | 125 this.clientPairingId_ = ''; |
135 | 126 |
136 /** | 127 /** |
137 * For paired connections, the paired secret for this device, issued by the | 128 * For paired connections, the paired secret for this device, issued by the |
138 * host. | 129 * host. |
139 * | 130 * |
140 * @type {string} | 131 * @type {string} |
141 * @private | 132 * @private |
142 */ | 133 */ |
143 this.clientPairedSecret_ = ''; | 134 this.clientPairedSecret_ = ''; |
144 | 135 |
145 /** | 136 /** |
146 * String used to authenticate to the host on connection. For IT2Me, this is | 137 * String used to authenticate to the host on connection. For IT2Me, this is |
147 * the access code; for Me2Me it is the PIN. | 138 * the access code; for Me2Me it is the PIN. |
148 * | 139 * |
149 * @type {string} | 140 * @type {string} |
150 * @private | 141 * @private |
151 */ | 142 */ |
152 this.passPhrase_ = ''; | 143 this.passPhrase_ = ''; |
153 | 144 |
154 /** | 145 /** |
155 * @type {string} | 146 * @type {remoting.Host} |
156 * @private | 147 * @private |
157 */ | 148 */ |
158 this.hostJid_ = ''; | 149 this.host_ = null; |
159 | |
160 /** | |
161 * @type {string} | |
162 * @private | |
163 */ | |
164 this.hostPublicKey_ = ''; | |
165 | 150 |
166 /** | 151 /** |
167 * @type {boolean} | 152 * @type {boolean} |
168 * @private | 153 * @private |
169 */ | 154 */ |
170 this.logHostOfflineErrors_ = false; | 155 this.logHostOfflineErrors_ = false; |
171 | 156 |
172 /** | 157 /** |
173 * @type {remoting.ClientSession} | 158 * @type {remoting.ClientSession} |
174 * @private | 159 * @private |
(...skipping 13 matching lines...) Expand all Loading... |
188 */ | 173 */ |
189 this.fetchPin_ = function(onPinFetched) {}; | 174 this.fetchPin_ = function(onPinFetched) {}; |
190 | 175 |
191 /** | 176 /** |
192 * @type {function(string, string, string, | 177 * @type {function(string, string, string, |
193 * function(string, string):void): void} | 178 * function(string, string):void): void} |
194 * @private | 179 * @private |
195 */ | 180 */ |
196 this.fetchThirdPartyToken_ = function( | 181 this.fetchThirdPartyToken_ = function( |
197 tokenUrl, scope, onThirdPartyTokenFetched) {}; | 182 tokenUrl, scope, onThirdPartyTokenFetched) {}; |
198 | |
199 /** | |
200 * Host 'name', as displayed in the client tool-bar. For a Me2Me connection, | |
201 * this is the name of the host; for an IT2Me connection, it is the email | |
202 * address of the person sharing their computer. | |
203 * | |
204 * @type {string} | |
205 * @private | |
206 */ | |
207 this.hostDisplayName_ = ''; | |
208 }; | 183 }; |
209 | 184 |
210 /** | 185 /** |
211 * Initiate a Me2Me connection. | 186 * Initiate a Me2Me connection. |
212 * | 187 * |
213 * This doesn't report host-offline errors because the connection will | 188 * This doesn't report host-offline errors because the connection will |
214 * be retried and retryConnectMe2Me is responsible for reporting these errors. | 189 * be retried and retryConnectMe2Me is responsible for reporting these errors. |
215 * | 190 * |
216 * @param {remoting.Host} host The Me2Me host to which to connect. | 191 * @param {remoting.Host} host The Me2Me host to which to connect. |
217 * @param {function(boolean, function(string):void):void} fetchPin Function to | 192 * @param {function(boolean, function(string):void):void} fetchPin Function to |
218 * interactively obtain the PIN from the user. | 193 * interactively obtain the PIN from the user. |
219 * @param {function(string, string, string, | 194 * @param {function(string, string, string, |
220 * function(string, string): void): void} | 195 * function(string, string): void): void} |
221 * fetchThirdPartyToken Function to obtain a token from a third party | 196 * fetchThirdPartyToken Function to obtain a token from a third party |
222 * authenticaiton server. | 197 * authenticaiton server. |
223 * @param {string} clientPairingId The client id issued by the host when | 198 * @param {string} clientPairingId The client id issued by the host when |
224 * this device was paired, if it is already paired. | 199 * this device was paired, if it is already paired. |
225 * @param {string} clientPairedSecret The shared secret issued by the host when | 200 * @param {string} clientPairedSecret The shared secret issued by the host when |
226 * this device was paired, if it is already paired. | 201 * this device was paired, if it is already paired. |
227 * @return {void} Nothing. | 202 * @return {void} Nothing. |
228 */ | 203 */ |
229 remoting.SessionConnectorImpl.prototype.connectMe2Me = | 204 remoting.SessionConnectorImpl.prototype.connectMe2Me = |
230 function(host, fetchPin, fetchThirdPartyToken, | 205 function(host, fetchPin, fetchThirdPartyToken, |
231 clientPairingId, clientPairedSecret) { | 206 clientPairingId, clientPairedSecret) { |
232 this.connectionMode_ = remoting.DesktopConnectedView.Mode.ME2ME; | 207 this.connectionMode_ = remoting.DesktopConnectedView.Mode.ME2ME; |
233 this.logHostOfflineErrors_ = false; | 208 this.logHostOfflineErrors_ = false; |
234 this.connectMe2MeInternal_( | 209 this.connectMe2MeInternal_(host, fetchPin, fetchThirdPartyToken, |
235 host.hostId, host.jabberId, host.publicKey, host.hostName, | 210 clientPairingId, clientPairedSecret); |
236 fetchPin, fetchThirdPartyToken, | |
237 clientPairingId, clientPairedSecret); | |
238 }; | 211 }; |
239 | 212 |
240 /** | 213 /** |
241 * Retry connecting to a Me2Me host after a connection failure. | 214 * Retry connecting to a Me2Me host after a connection failure. |
242 * | 215 * |
243 * This is the same as connectMe2Me except that is will log errors if the | 216 * This is the same as connectMe2Me except that is will log errors if the |
244 * host is offline. | 217 * host is offline. |
245 * | 218 * |
246 * @param {remoting.Host} host The Me2Me host to refresh. | 219 * @param {remoting.Host} host The Me2Me host to refresh. |
247 * @return {void} Nothing. | 220 * @return {void} Nothing. |
248 */ | 221 */ |
249 remoting.SessionConnectorImpl.prototype.retryConnectMe2Me = function(host) { | 222 remoting.SessionConnectorImpl.prototype.retryConnectMe2Me = function(host) { |
250 this.connectionMode_ = remoting.DesktopConnectedView.Mode.ME2ME; | 223 this.connectionMode_ = remoting.DesktopConnectedView.Mode.ME2ME; |
251 this.logHostOfflineErrors_ = true; | 224 this.logHostOfflineErrors_ = true; |
252 this.connectMe2MeInternal_( | 225 this.connectMe2MeInternal_(host, this.fetchPin_, this.fetchThirdPartyToken_, |
253 host.hostId, host.jabberId, host.publicKey, host.hostName, | 226 this.clientPairingId_, this.clientPairedSecret_); |
254 this.fetchPin_, this.fetchThirdPartyToken_, | |
255 this.clientPairingId_, this.clientPairedSecret_); | |
256 }; | 227 }; |
257 | 228 |
258 /** | 229 /** |
259 * Initiate a Me2App connection. | 230 * Initiate a Me2App connection. |
260 * | 231 * |
261 * @param {remoting.Host} host The Me2Me host to which to connect. | 232 * @param {remoting.Host} host The Me2Me host to which to connect. |
262 * @param {function(string, string, string, | 233 * @param {function(string, string, string, |
263 * function(string, string): void): void} | 234 * function(string, string): void): void} |
264 * fetchThirdPartyToken Function to obtain a token from a third party | 235 * fetchThirdPartyToken Function to obtain a token from a third party |
265 * authenticaiton server. | 236 * authenticaiton server. |
266 * @return {void} Nothing. | 237 * @return {void} Nothing. |
267 */ | 238 */ |
268 remoting.SessionConnectorImpl.prototype.connectMe2App = | 239 remoting.SessionConnectorImpl.prototype.connectMe2App = |
269 function(host, fetchThirdPartyToken) { | 240 function(host, fetchThirdPartyToken) { |
270 this.connectionMode_ = remoting.DesktopConnectedView.Mode.APP_REMOTING; | 241 this.connectionMode_ = remoting.DesktopConnectedView.Mode.APP_REMOTING; |
271 this.logHostOfflineErrors_ = true; | 242 this.logHostOfflineErrors_ = true; |
272 this.connectMe2MeInternal_( | 243 this.connectMe2MeInternal_(host, function() {}, fetchThirdPartyToken, '', ''); |
273 host.hostId, host.jabberId, host.publicKey, host.hostName, | |
274 function() {}, fetchThirdPartyToken, '', ''); | |
275 }; | 244 }; |
276 | 245 |
277 /** | 246 /** |
278 * Update the pairing info so that the reconnect function will work correctly. | 247 * Update the pairing info so that the reconnect function will work correctly. |
279 * | 248 * |
280 * @param {string} clientId The paired client id. | 249 * @param {string} clientId The paired client id. |
281 * @param {string} sharedSecret The shared secret. | 250 * @param {string} sharedSecret The shared secret. |
282 */ | 251 */ |
283 remoting.SessionConnectorImpl.prototype.updatePairingInfo = | 252 remoting.SessionConnectorImpl.prototype.updatePairingInfo = |
284 function(clientId, sharedSecret) { | 253 function(clientId, sharedSecret) { |
285 this.clientPairingId_ = clientId; | 254 this.clientPairingId_ = clientId; |
286 this.clientPairedSecret_ = sharedSecret; | 255 this.clientPairedSecret_ = sharedSecret; |
287 }; | 256 }; |
288 | 257 |
289 /** | 258 /** |
290 * Initiate a Me2Me connection. | 259 * Initiate a Me2Me connection. |
291 * | 260 * |
292 * @param {string} hostId ID of the Me2Me host. | 261 * @param {remoting.Host} host the Host to connect to. |
293 * @param {string} hostJid XMPP JID of the host. | |
294 * @param {string} hostPublicKey Public Key of the host. | |
295 * @param {string} hostDisplayName Display name (friendly name) of the host. | |
296 * @param {function(boolean, function(string):void):void} fetchPin Function to | 262 * @param {function(boolean, function(string):void):void} fetchPin Function to |
297 * interactively obtain the PIN from the user. | 263 * interactively obtain the PIN from the user. |
298 * @param {function(string, string, string, | 264 * @param {function(string, string, string, |
299 * function(string, string): void): void} | 265 * function(string, string): void): void} |
300 * fetchThirdPartyToken Function to obtain a token from a third party | 266 * fetchThirdPartyToken Function to obtain a token from a third party |
301 * authenticaiton server. | 267 * authenticaiton server. |
302 * @param {string} clientPairingId The client id issued by the host when | 268 * @param {string} clientPairingId The client id issued by the host when |
303 * this device was paired, if it is already paired. | 269 * this device was paired, if it is already paired. |
304 * @param {string} clientPairedSecret The shared secret issued by the host when | 270 * @param {string} clientPairedSecret The shared secret issued by the host when |
305 * this device was paired, if it is already paired. | 271 * this device was paired, if it is already paired. |
306 * @return {void} Nothing. | 272 * @return {void} Nothing. |
307 * @private | 273 * @private |
308 */ | 274 */ |
309 remoting.SessionConnectorImpl.prototype.connectMe2MeInternal_ = | 275 remoting.SessionConnectorImpl.prototype.connectMe2MeInternal_ = |
310 function(hostId, hostJid, hostPublicKey, hostDisplayName, | 276 function(host, fetchPin, fetchThirdPartyToken, |
311 fetchPin, fetchThirdPartyToken, | |
312 clientPairingId, clientPairedSecret) { | 277 clientPairingId, clientPairedSecret) { |
313 // Cancel any existing connect operation. | 278 // Cancel any existing connect operation. |
314 this.cancel(); | 279 this.cancel(); |
315 | 280 |
316 this.hostId_ = hostId; | 281 this.host_ = host; |
317 this.hostJid_ = hostJid; | |
318 this.hostPublicKey_ = hostPublicKey; | |
319 this.fetchPin_ = fetchPin; | 282 this.fetchPin_ = fetchPin; |
320 this.fetchThirdPartyToken_ = fetchThirdPartyToken; | 283 this.fetchThirdPartyToken_ = fetchThirdPartyToken; |
321 this.hostDisplayName_ = hostDisplayName; | |
322 this.updatePairingInfo(clientPairingId, clientPairedSecret); | 284 this.updatePairingInfo(clientPairingId, clientPairedSecret); |
323 | 285 |
324 this.connectSignaling_(); | 286 this.connectSignaling_(); |
325 } | 287 }; |
326 | 288 |
327 /** | 289 /** |
328 * Initiate an IT2Me connection. | 290 * Initiate an IT2Me connection. |
329 * | 291 * |
330 * @param {string} accessCode The access code as entered by the user. | 292 * @param {string} accessCode The access code as entered by the user. |
331 * @return {void} Nothing. | 293 * @return {void} Nothing. |
332 */ | 294 */ |
333 remoting.SessionConnectorImpl.prototype.connectIT2Me = function(accessCode) { | 295 remoting.SessionConnectorImpl.prototype.connectIT2Me = function(accessCode) { |
334 var kSupportIdLen = 7; | 296 var kSupportIdLen = 7; |
335 var kHostSecretLen = 5; | 297 var kHostSecretLen = 5; |
336 var kAccessCodeLen = kSupportIdLen + kHostSecretLen; | 298 var kAccessCodeLen = kSupportIdLen + kHostSecretLen; |
337 | 299 |
338 // Cancel any existing connect operation. | 300 // Cancel any existing connect operation. |
339 this.cancel(); | 301 this.cancel(); |
340 | 302 |
341 var normalizedAccessCode = this.normalizeAccessCode_(accessCode); | 303 var normalizedAccessCode = this.normalizeAccessCode_(accessCode); |
342 if (normalizedAccessCode.length != kAccessCodeLen) { | 304 if (normalizedAccessCode.length != kAccessCodeLen) { |
343 this.onError_(remoting.Error.INVALID_ACCESS_CODE); | 305 this.onError_(remoting.Error.INVALID_ACCESS_CODE); |
344 return; | 306 return; |
345 } | 307 } |
346 | 308 |
347 this.hostId_ = normalizedAccessCode.substring(0, kSupportIdLen); | 309 var hostId = normalizedAccessCode.substring(0, kSupportIdLen); |
348 this.passPhrase_ = normalizedAccessCode; | 310 this.passPhrase_ = normalizedAccessCode; |
349 this.connectionMode_ = remoting.DesktopConnectedView.Mode.IT2ME; | 311 this.connectionMode_ = remoting.DesktopConnectedView.Mode.IT2ME; |
350 remoting.identity.callWithToken(this.connectIT2MeWithToken_.bind(this), | 312 remoting.identity.callWithToken( |
351 this.onError_); | 313 this.connectIT2MeWithToken_.bind(this, hostId), this.onError_); |
352 }; | 314 }; |
353 | 315 |
354 /** | 316 /** |
355 * Reconnect a closed connection. | 317 * Reconnect a closed connection. |
356 * | 318 * |
357 * @return {void} Nothing. | 319 * @return {void} Nothing. |
358 */ | 320 */ |
359 remoting.SessionConnectorImpl.prototype.reconnect = function() { | 321 remoting.SessionConnectorImpl.prototype.reconnect = function() { |
360 if (this.connectionMode_ == remoting.DesktopConnectedView.Mode.IT2ME) { | 322 if (this.connectionMode_ == remoting.DesktopConnectedView.Mode.IT2ME) { |
361 console.error('reconnect not supported for IT2Me.'); | 323 console.error('reconnect not supported for IT2Me.'); |
362 return; | 324 return; |
363 } | 325 } |
364 this.logHostOfflineErrors_ = false; | 326 this.logHostOfflineErrors_ = false; |
365 this.connectMe2MeInternal_( | 327 this.connectMe2MeInternal_(this.host_, this.fetchPin_, |
366 this.hostId_, this.hostJid_, this.hostPublicKey_, this.hostDisplayName_, | 328 this.fetchThirdPartyToken_, this.clientPairingId_, |
367 this.fetchPin_, this.fetchThirdPartyToken_, | 329 this.clientPairedSecret_); |
368 this.clientPairingId_, this.clientPairedSecret_); | |
369 }; | 330 }; |
370 | 331 |
371 /** | 332 /** |
372 * Cancel a connection-in-progress. | 333 * Cancel a connection-in-progress. |
373 */ | 334 */ |
374 remoting.SessionConnectorImpl.prototype.cancel = function() { | 335 remoting.SessionConnectorImpl.prototype.cancel = function() { |
375 if (this.clientSession_) { | 336 if (this.clientSession_) { |
376 this.clientSession_.removePlugin(); | 337 this.clientSession_.removePlugin(); |
377 this.clientSession_ = null; | 338 this.clientSession_ = null; |
378 } | 339 } |
(...skipping 12 matching lines...) Expand all Loading... |
391 remoting.SessionConnectorImpl.prototype.getConnectionMode = function() { | 352 remoting.SessionConnectorImpl.prototype.getConnectionMode = function() { |
392 return this.connectionMode_; | 353 return this.connectionMode_; |
393 }; | 354 }; |
394 | 355 |
395 /** | 356 /** |
396 * Get host ID. | 357 * Get host ID. |
397 * | 358 * |
398 * @return {string} | 359 * @return {string} |
399 */ | 360 */ |
400 remoting.SessionConnectorImpl.prototype.getHostId = function() { | 361 remoting.SessionConnectorImpl.prototype.getHostId = function() { |
401 return this.hostId_; | 362 return this.host_.hostId; |
402 }; | 363 }; |
403 | 364 |
404 /** | 365 /** |
405 * @private | 366 * @private |
406 */ | 367 */ |
407 remoting.SessionConnectorImpl.prototype.connectSignaling_ = function() { | 368 remoting.SessionConnectorImpl.prototype.connectSignaling_ = function() { |
408 base.dispose(this.signalStrategy_); | 369 base.dispose(this.signalStrategy_); |
409 this.signalStrategy_ = null; | 370 this.signalStrategy_ = null; |
410 | 371 |
411 /** @type {remoting.SessionConnectorImpl} */ | 372 /** @type {remoting.SessionConnectorImpl} */ |
(...skipping 28 matching lines...) Expand all Loading... |
440 }; | 401 }; |
441 | 402 |
442 /** | 403 /** |
443 * @private | 404 * @private |
444 * @param {remoting.SignalStrategy.State} state | 405 * @param {remoting.SignalStrategy.State} state |
445 */ | 406 */ |
446 remoting.SessionConnectorImpl.prototype.onSignalingState_ = function(state) { | 407 remoting.SessionConnectorImpl.prototype.onSignalingState_ = function(state) { |
447 switch (state) { | 408 switch (state) { |
448 case remoting.SignalStrategy.State.CONNECTED: | 409 case remoting.SignalStrategy.State.CONNECTED: |
449 // Proceed only if the connection hasn't been canceled. | 410 // Proceed only if the connection hasn't been canceled. |
450 if (this.hostJid_) { | 411 if (this.host_.jabberId) { |
451 this.createSession_(); | 412 this.createSession_(); |
452 } | 413 } |
453 break; | 414 break; |
454 | 415 |
455 case remoting.SignalStrategy.State.FAILED: | 416 case remoting.SignalStrategy.State.FAILED: |
456 this.onError_(this.signalStrategy_.getError()); | 417 this.onError_(this.signalStrategy_.getError()); |
457 break; | 418 break; |
458 } | 419 } |
459 }; | 420 }; |
460 | 421 |
461 /** | 422 /** |
462 * Continue an IT2Me connection once an access token has been obtained. | 423 * Continue an IT2Me connection once an access token has been obtained. |
463 * | 424 * |
| 425 * @param {string} hostId |
464 * @param {string} token An OAuth2 access token. | 426 * @param {string} token An OAuth2 access token. |
465 * @return {void} Nothing. | 427 * @return {void} Nothing. |
466 * @private | 428 * @private |
467 */ | 429 */ |
468 remoting.SessionConnectorImpl.prototype.connectIT2MeWithToken_ = | 430 remoting.SessionConnectorImpl.prototype.connectIT2MeWithToken_ = |
469 function(token) { | 431 function(hostId, token) { |
470 // Resolve the host id to get the host JID. | 432 // Resolve the host id to get the host JID. |
471 this.pendingXhr_ = remoting.xhr.get( | 433 this.pendingXhr_ = remoting.xhr.get( |
472 remoting.settings.DIRECTORY_API_BASE_URL + '/support-hosts/' + | 434 remoting.settings.DIRECTORY_API_BASE_URL + '/support-hosts/' + |
473 encodeURIComponent(this.hostId_), | 435 encodeURIComponent(hostId), |
474 this.onIT2MeHostInfo_.bind(this), | 436 this.onIT2MeHostInfo_.bind(this, hostId), |
475 '', | 437 '', |
476 { 'Authorization': 'OAuth ' + token }); | 438 { 'Authorization': 'OAuth ' + token }); |
477 }; | 439 }; |
478 | 440 |
479 /** | 441 /** |
480 * Continue an IT2Me connection once the host JID has been looked up. | 442 * Continue an IT2Me connection once the host JID has been looked up. |
481 * | 443 * |
| 444 * @param {string} hostId |
482 * @param {XMLHttpRequest} xhr The server response to the support-hosts query. | 445 * @param {XMLHttpRequest} xhr The server response to the support-hosts query. |
483 * @return {void} Nothing. | 446 * @return {void} Nothing. |
484 * @private | 447 * @private |
485 */ | 448 */ |
486 remoting.SessionConnectorImpl.prototype.onIT2MeHostInfo_ = function(xhr) { | 449 remoting.SessionConnectorImpl.prototype.onIT2MeHostInfo_ = function(hostId, |
| 450 xhr) { |
487 this.pendingXhr_ = null; | 451 this.pendingXhr_ = null; |
488 if (xhr.status == 200) { | 452 if (xhr.status == 200) { |
489 var host = /** @type {{data: {jabberId: string, publicKey: string}}} */ | 453 var host = /** @type {{data: {jabberId: string, publicKey: string}}} */ |
490 (base.jsonParseSafe(xhr.responseText)); | 454 (base.jsonParseSafe(xhr.responseText)); |
491 if (host && host.data && host.data.jabberId && host.data.publicKey) { | 455 if (host && host.data && host.data.jabberId && host.data.publicKey) { |
492 this.hostJid_ = host.data.jabberId; | 456 this.host_ = new remoting.Host(); |
493 this.hostPublicKey_ = host.data.publicKey; | 457 this.host_.hostId = hostId; |
494 this.hostDisplayName_ = this.hostJid_.split('/')[0]; | 458 this.host_.jabberId = host.data.jabberId; |
| 459 this.host_.publicKey = host.data.publicKey; |
| 460 this.host_.hostName = host.data.jabberId.split('/')[0]; |
495 this.connectSignaling_(); | 461 this.connectSignaling_(); |
496 return; | 462 return; |
497 } else { | 463 } else { |
498 console.error('Invalid "support-hosts" response from server.'); | 464 console.error('Invalid "support-hosts" response from server.'); |
499 } | 465 } |
500 } else { | 466 } else { |
501 this.onError_(this.translateSupportHostsError_(xhr.status)); | 467 this.onError_(this.translateSupportHostsError_(xhr.status)); |
502 } | 468 } |
503 }; | 469 }; |
504 | 470 |
505 /** | 471 /** |
506 * Creates ClientSession object. | 472 * Creates ClientSession object. |
507 */ | 473 */ |
508 remoting.SessionConnectorImpl.prototype.createSession_ = function() { | 474 remoting.SessionConnectorImpl.prototype.createSession_ = function() { |
509 // In some circumstances, the WCS <iframe> can get reloaded, which results | 475 // In some circumstances, the WCS <iframe> can get reloaded, which results |
510 // in a new clientJid and a new callback. In this case, remove the old | 476 // in a new clientJid and a new callback. In this case, remove the old |
511 // client plugin before instantiating a new one. | 477 // client plugin before instantiating a new one. |
512 if (this.clientSession_) { | 478 if (this.clientSession_) { |
513 this.clientSession_.removePlugin(); | 479 this.clientSession_.removePlugin(); |
514 this.clientSession_ = null; | 480 this.clientSession_ = null; |
515 } | 481 } |
516 | 482 |
517 var authenticationMethods = | 483 var authenticationMethods = |
518 'third_party,spake2_pair,spake2_hmac,spake2_plain'; | 484 'third_party,spake2_pair,spake2_hmac,spake2_plain'; |
519 this.clientSession_ = new remoting.ClientSession( | 485 this.clientSession_ = new remoting.ClientSession( |
520 this.signalStrategy_, this.clientContainer_, this.hostDisplayName_, | 486 this.host_, this.signalStrategy_, this.clientContainer_, this.passPhrase_, |
521 this.passPhrase_, this.fetchPin_, this.fetchThirdPartyToken_, | 487 this.fetchPin_, this.fetchThirdPartyToken_, authenticationMethods, |
522 authenticationMethods, this.hostId_, this.hostJid_, this.hostPublicKey_, | |
523 this.connectionMode_, this.clientPairingId_, this.clientPairedSecret_, | 488 this.connectionMode_, this.clientPairingId_, this.clientPairedSecret_, |
524 this.defaultRemapKeys_); | 489 this.defaultRemapKeys_); |
525 this.clientSession_.logHostOfflineErrors(this.logHostOfflineErrors_); | 490 this.clientSession_.logHostOfflineErrors(this.logHostOfflineErrors_); |
526 this.clientSession_.addEventListener( | 491 this.clientSession_.addEventListener( |
527 remoting.ClientSession.Events.stateChanged, | 492 remoting.ClientSession.Events.stateChanged, |
528 this.bound_.onStateChange); | 493 this.bound_.onStateChange); |
529 this.clientSession_.createPluginAndConnect(this.onExtensionMessage_, | 494 this.clientSession_.createPluginAndConnect(this.onExtensionMessage_, |
530 this.requiredCapabilities_); | 495 this.requiredCapabilities_); |
531 }; | 496 }; |
532 | 497 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 */ | 620 */ |
656 remoting.DefaultSessionConnectorFactory.prototype.createConnector = | 621 remoting.DefaultSessionConnectorFactory.prototype.createConnector = |
657 function(clientContainer, onConnected, onError, onExtensionMessage, | 622 function(clientContainer, onConnected, onError, onExtensionMessage, |
658 onConnectionFailed, requiredCapabilities, defaultRemapKeys) { | 623 onConnectionFailed, requiredCapabilities, defaultRemapKeys) { |
659 return new remoting.SessionConnectorImpl(clientContainer, onConnected, | 624 return new remoting.SessionConnectorImpl(clientContainer, onConnected, |
660 onError, onExtensionMessage, | 625 onError, onExtensionMessage, |
661 onConnectionFailed, | 626 onConnectionFailed, |
662 requiredCapabilities, | 627 requiredCapabilities, |
663 defaultRemapKeys); | 628 defaultRemapKeys); |
664 }; | 629 }; |
OLD | NEW |