Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: remoting/webapp/session_connector.js

Issue 552403004: Interfaceify ClientPlugin in preparation for mocking it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Interfaceify more classes. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/session_connector.js
diff --git a/remoting/webapp/session_connector.js b/remoting/webapp/session_connector.js
index 6d6e92b05d3545cc8450c624d2c43037467b1fa0..9d3fc019ee9d6ff8d7af120a5906d5dee2ad7546 100644
--- a/remoting/webapp/session_connector.js
+++ b/remoting/webapp/session_connector.js
@@ -21,6 +21,7 @@ var remoting = remoting || {};
* protocol extension messages. Returns true if a message is recognized;
* false otherwise.
* @constructor
+ * @implements {remoting.SessionConnectorInterface}
*/
remoting.SessionConnector = function(clientContainer, onConnected, onError,
onExtensionMessage) {
@@ -89,14 +90,6 @@ remoting.SessionConnector = function(clientContainer, onConnected, onError,
*/
remoting.SessionConnector.prototype.reset = function() {
/**
- * Set to true to indicate that the user requested pairing when entering
- * their PIN for a Me2Me connection.
- *
- * @type {boolean}
- */
- this.pairingRequested = false;
-
- /**
* String used to identify the host to which to connect. For IT2Me, this is
* the first 7 digits of the access code; for Me2Me it is the host identifier.
*
@@ -440,7 +433,7 @@ remoting.SessionConnector.prototype.onIT2MeHostInfo_ = function(xhr) {
console.error('Invalid "support-hosts" response from server.');
}
} else {
- this.onError_(this.translateSupportHostsError(xhr.status));
+ this.onError_(this.translateSupportHostsError_(xhr.status));
}
};
@@ -570,7 +563,7 @@ remoting.SessionConnector.prototype.onHostListRefresh_ = function(success) {
* @return {remoting.Error} The equivalent remoting.Error code.
* @private
*/
-remoting.SessionConnector.prototype.translateSupportHostsError =
+remoting.SessionConnector.prototype.translateSupportHostsError_ =
function(error) {
switch (error) {
case 0: return remoting.Error.NETWORK_FAILURE;
@@ -586,9 +579,39 @@ remoting.SessionConnector.prototype.translateSupportHostsError =
*
* @param {string} accessCode The access code, as entered by the user.
* @return {string} The normalized form of the code (whitespace removed).
+ * @private
*/
remoting.SessionConnector.prototype.normalizeAccessCode_ =
function(accessCode) {
// Trim whitespace.
return accessCode.replace(/\s/g, '');
};
+
+
+/**
+ * @constructor
+ * @implements {remoting.SessionConnectorFactory}
+ */
+remoting.DefaultSessionConnectorFactory = function() {
+};
+
+/**
+ * @param {HTMLElement} clientContainer Container element for the client view.
+ * @param {function(remoting.ClientSession):void} onConnected Callback on
+ * success.
+ * @param {function(remoting.Error):void} onError Callback on error.
+ * @param {function(string, string):boolean} onExtensionMessage The handler for
+ * protocol extension messages. Returns true if a message is recognized;
+ * false otherwise.
+ */
+remoting.DefaultSessionConnectorFactory.prototype.createConnector =
+ function(clientContainer, onConnected, onError, onExtensionMessage) {
+ return new remoting.SessionConnector(
+ clientContainer, onConnected, onError, onExtensionMessage);
+};
+
+/**
+ * @type {remoting.SessionConnectorFactory}
+ */
+remoting.SessionConnector.factory =
+ new remoting.DefaultSessionConnectorFactory();

Powered by Google App Engine
This is Rietveld 408576698