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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 354 |
355 /** | 355 /** |
356 * @param {string} token | 356 * @param {string} token |
357 * @param {string} email | 357 * @param {string} email |
358 */ | 358 */ |
359 function connectSignalingWithTokenAndEmail(token, email) { | 359 function connectSignalingWithTokenAndEmail(token, email) { |
360 that.signalStrategy_.connect( | 360 that.signalStrategy_.connect( |
361 remoting.settings.XMPP_SERVER_ADDRESS, email, token); | 361 remoting.settings.XMPP_SERVER_ADDRESS, email, token); |
362 } | 362 } |
363 | 363 |
364 // Only use XMPP when TCP API is available and TLS support is enabled. That's | 364 this.signalStrategy_ = |
365 // not the case for V1 app (socket API is available only to platform apps) | 365 remoting.SignalStrategy.create(this.onSignalingState_.bind(this)); |
366 // and for Chrome releases before 38. | |
367 if (chrome.socket && chrome.socket.secure) { | |
368 this.signalStrategy_ = /** @type {remoting.SignalStrategy} */ | |
369 (new remoting.XmppConnection(this.onSignalingState_.bind(this))); | |
370 } else { | |
371 this.signalStrategy_ = /** @type {remoting.SignalStrategy} */ | |
372 (new remoting.WcsAdapter(this.onSignalingState_.bind(this))); | |
373 } | |
374 | 366 |
375 remoting.identity.callWithToken(connectSignalingWithToken, this.onError_); | 367 remoting.identity.callWithToken(connectSignalingWithToken, this.onError_); |
376 }; | 368 }; |
377 | 369 |
378 /** | 370 /** |
379 * @private | 371 * @private |
380 * @param {remoting.SignalStrategy.State} state | 372 * @param {remoting.SignalStrategy.State} state |
381 */ | 373 */ |
382 remoting.SessionConnectorImpl.prototype.onSignalingState_ = function(state) { | 374 remoting.SessionConnectorImpl.prototype.onSignalingState_ = function(state) { |
383 switch (state) { | 375 switch (state) { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 * @param {function(remoting.Error):void} onError Callback on error. | 595 * @param {function(remoting.Error):void} onError Callback on error. |
604 * @param {function(string, string):boolean} onExtensionMessage The handler for | 596 * @param {function(string, string):boolean} onExtensionMessage The handler for |
605 * protocol extension messages. Returns true if a message is recognized; | 597 * protocol extension messages. Returns true if a message is recognized; |
606 * false otherwise. | 598 * false otherwise. |
607 */ | 599 */ |
608 remoting.DefaultSessionConnectorFactory.prototype.createConnector = | 600 remoting.DefaultSessionConnectorFactory.prototype.createConnector = |
609 function(clientContainer, onConnected, onError, onExtensionMessage) { | 601 function(clientContainer, onConnected, onError, onExtensionMessage) { |
610 return new remoting.SessionConnectorImpl( | 602 return new remoting.SessionConnectorImpl( |
611 clientContainer, onConnected, onError, onExtensionMessage); | 603 clientContainer, onConnected, onError, onExtensionMessage); |
612 }; | 604 }; |
OLD | NEW |