Index: remoting/webapp/signal_strategy.js |
diff --git a/remoting/webapp/signal_strategy.js b/remoting/webapp/signal_strategy.js |
index b94acc35e3708184abb6d46e7316512f9a4f89dc..02c8acbd5f0cc27829d59aa1b6dbd8a6f020b57b 100644 |
--- a/remoting/webapp/signal_strategy.js |
+++ b/remoting/webapp/signal_strategy.js |
@@ -65,3 +65,19 @@ remoting.SignalStrategy.prototype.getError = function() {}; |
/** @return {string} Current JID when in CONNECTED state. */ |
remoting.SignalStrategy.prototype.getJid = function() {}; |
+ |
+/** |
+ * Creates the appropriate signal strategy for the current environment. |
+ * @param {function(remoting.SignalStrategy.State): void} onStateChangedCallback |
+ * @return {remoting.SignalStrategy} New signal strategy object. |
+ */ |
+remoting.SignalStrategy.create = function(onStateChangedCallback) { |
+ // Only use XMPP when TCP API is available and TLS support is enabled. That's |
+ // not the case for V1 app (socket API is available only to platform apps) |
+ // and for Chrome releases before 38. |
+ if (chrome.socket && chrome.socket.secure) { |
+ return new remoting.XmppConnection(onStateChangedCallback); |
+ } else { |
+ return new remoting.WcsAdapter(onStateChangedCallback); |
+ } |
+}; |