| Index: remoting/webapp/crd/js/session_connector_impl.js
|
| diff --git a/remoting/webapp/crd/js/session_connector_impl.js b/remoting/webapp/crd/js/session_connector_impl.js
|
| index ca2bf747000af4d6a5edee22be2fbc15c5f5907c..58942d5a7e59bdc9110979decd04c3b0f7f95141 100644
|
| --- a/remoting/webapp/crd/js/session_connector_impl.js
|
| +++ b/remoting/webapp/crd/js/session_connector_impl.js
|
| @@ -14,17 +14,11 @@ var remoting = remoting || {};
|
|
|
| /**
|
| * @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.
|
| + * @param {remoting.Application} app The main remoting application.
|
| * @constructor
|
| * @implements {remoting.SessionConnector}
|
| */
|
| -remoting.SessionConnectorImpl = function(clientContainer, onConnected, onError,
|
| - onExtensionMessage) {
|
| +remoting.SessionConnectorImpl = function(clientContainer, app) {
|
| /**
|
| * @type {HTMLElement}
|
| * @private
|
| @@ -32,22 +26,10 @@ remoting.SessionConnectorImpl = function(clientContainer, onConnected, onError,
|
| this.clientContainer_ = clientContainer;
|
|
|
| /**
|
| - * @type {function(remoting.ClientSession):void}
|
| + * @type {remoting.Application}
|
| * @private
|
| */
|
| - this.onConnected_ = onConnected;
|
| -
|
| - /**
|
| - * @type {function(remoting.Error):void}
|
| - * @private
|
| - */
|
| - this.onError_ = onError;
|
| -
|
| - /**
|
| - * @type {function(string, string):boolean}
|
| - * @private
|
| - */
|
| - this.onExtensionMessage_ = onExtensionMessage;
|
| + this.app_ = app;
|
|
|
| /**
|
| * @type {string}
|
| @@ -276,7 +258,7 @@ remoting.SessionConnectorImpl.prototype.connectIT2Me = function(accessCode) {
|
|
|
| var normalizedAccessCode = this.normalizeAccessCode_(accessCode);
|
| if (normalizedAccessCode.length != kAccessCodeLen) {
|
| - this.onError_(remoting.Error.INVALID_ACCESS_CODE);
|
| + this.app_.onError(remoting.Error.INVALID_ACCESS_CODE);
|
| return;
|
| }
|
|
|
| @@ -284,7 +266,7 @@ remoting.SessionConnectorImpl.prototype.connectIT2Me = function(accessCode) {
|
| this.passPhrase_ = normalizedAccessCode;
|
| this.connectionMode_ = remoting.ClientSession.Mode.IT2ME;
|
| remoting.identity.callWithToken(this.connectIT2MeWithToken_.bind(this),
|
| - this.onError_);
|
| + this.app_.onError);
|
| };
|
|
|
| /**
|
| @@ -349,7 +331,7 @@ remoting.SessionConnectorImpl.prototype.connectSignaling_ = function() {
|
| /** @param {string} token */
|
| function connectSignalingWithToken(token) {
|
| remoting.identity.getEmail(
|
| - connectSignalingWithTokenAndEmail.bind(null, token), that.onError_);
|
| + connectSignalingWithTokenAndEmail.bind(null, token), that.app_.onError);
|
| }
|
|
|
| /**
|
| @@ -364,7 +346,7 @@ remoting.SessionConnectorImpl.prototype.connectSignaling_ = function() {
|
| this.signalStrategy_ =
|
| remoting.SignalStrategy.create(this.onSignalingState_.bind(this));
|
|
|
| - remoting.identity.callWithToken(connectSignalingWithToken, this.onError_);
|
| + remoting.identity.callWithToken(connectSignalingWithToken, this.app_.onError);
|
| };
|
|
|
| /**
|
| @@ -381,7 +363,7 @@ remoting.SessionConnectorImpl.prototype.onSignalingState_ = function(state) {
|
| break;
|
|
|
| case remoting.SignalStrategy.State.FAILED:
|
| - this.onError_(this.signalStrategy_.getError());
|
| + this.app_.onError(this.signalStrategy_.getError());
|
| break;
|
| }
|
| };
|
| @@ -426,7 +408,7 @@ remoting.SessionConnectorImpl.prototype.onIT2MeHostInfo_ = function(xhr) {
|
| console.error('Invalid "support-hosts" response from server.');
|
| }
|
| } else {
|
| - this.onError_(this.translateSupportHostsError_(xhr.status));
|
| + this.app_.onError(this.translateSupportHostsError_(xhr.status));
|
| }
|
| };
|
|
|
| @@ -453,7 +435,7 @@ remoting.SessionConnectorImpl.prototype.createSession_ = function() {
|
| this.clientSession_.addEventListener(
|
| remoting.ClientSession.Events.stateChanged,
|
| this.bound_.onStateChange);
|
| - this.clientSession_.createPluginAndConnect(this.onExtensionMessage_);
|
| + this.clientSession_.createPluginAndConnect(this.app_.onExtensionMessage);
|
| };
|
|
|
| /**
|
| @@ -482,7 +464,7 @@ remoting.SessionConnectorImpl.prototype.onStateChange_ = function(event) {
|
| this.reconnector_ =
|
| new remoting.SmartReconnector(this, this.clientSession_);
|
| }
|
| - this.onConnected_(this.clientSession_);
|
| + this.app_.onConnected(this.clientSession_);
|
| break;
|
|
|
| case remoting.ClientSession.State.CREATED:
|
| @@ -505,7 +487,7 @@ remoting.SessionConnectorImpl.prototype.onStateChange_ = function(event) {
|
| // accepting it. Since there's no way of knowing exactly what went wrong,
|
| // we rely on server-side logs in this case and report a generic error
|
| // message.
|
| - this.onError_(remoting.Error.UNEXPECTED);
|
| + this.app_.onError(remoting.Error.UNEXPECTED);
|
| break;
|
|
|
| case remoting.ClientSession.State.FAILED:
|
| @@ -519,7 +501,7 @@ remoting.SessionConnectorImpl.prototype.onStateChange_ = function(event) {
|
| // The plugin will be re-created when the host finished refreshing
|
| remoting.hostList.refresh(this.onHostListRefresh_.bind(this));
|
| } else {
|
| - this.onError_(error);
|
| + this.app_.onError(error);
|
| }
|
| break;
|
|
|
| @@ -527,7 +509,7 @@ remoting.SessionConnectorImpl.prototype.onStateChange_ = function(event) {
|
| console.error('Unexpected client plugin state: ' + event.current);
|
| // This should only happen if the web-app and client plugin get out of
|
| // sync, and even then the version check should ensure compatibility.
|
| - this.onError_(remoting.Error.MISSING_PLUGIN);
|
| + this.app_.onError(remoting.Error.MISSING_PLUGIN);
|
| }
|
| };
|
|
|
| @@ -547,7 +529,7 @@ remoting.SessionConnectorImpl.prototype.onHostListRefresh_ = function(success) {
|
| return;
|
| }
|
| }
|
| - this.onError_(remoting.Error.HOST_IS_OFFLINE);
|
| + this.app_.onError(remoting.Error.HOST_IS_OFFLINE);
|
| };
|
|
|
| /**
|
| @@ -590,15 +572,9 @@ 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.
|
| + * @param {remoting.Application} app The main application.
|
| */
|
| remoting.DefaultSessionConnectorFactory.prototype.createConnector =
|
| - function(clientContainer, onConnected, onError, onExtensionMessage) {
|
| - return new remoting.SessionConnectorImpl(
|
| - clientContainer, onConnected, onError, onExtensionMessage);
|
| + function(clientContainer, app) {
|
| + return new remoting.SessionConnectorImpl(clientContainer, app);
|
| };
|
|
|