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

Unified Diff: remoting/webapp/crd/js/it2me_activity.js

Issue 1101613003: [Webapp Refactor] Reliably cancels a connection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ImproveUnittest
Patch Set: Created 5 years, 8 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/crd/js/it2me_activity.js
diff --git a/remoting/webapp/crd/js/it2me_activity.js b/remoting/webapp/crd/js/it2me_activity.js
index e5dc2db7054fd81abae923b92e42c8235e69db7c..8140c9f5bca8ff7e5b2286916a02a70d15ec9e30 100644
--- a/remoting/webapp/crd/js/it2me_activity.js
+++ b/remoting/webapp/crd/js/it2me_activity.js
@@ -44,8 +44,11 @@ remoting.It2MeActivity.prototype.dispose = function() {
remoting.It2MeActivity.prototype.start = function() {
var that = this;
+ this.desktopActivity_ = new remoting.DesktopRemotingActivity(this);
+ remoting.app.setConnectionMode(remoting.Application.Mode.IT2ME);
+
this.accessCodeDialog_.show().then(function(/** string */ accessCode) {
- remoting.setMode(remoting.AppMode.CLIENT_CONNECTING);
+ that.desktopActivity_.getConnectingDialog().show();
return that.verifyAccessCode_(accessCode);
}).then(function() {
return remoting.identity.getToken();
@@ -55,7 +58,7 @@ remoting.It2MeActivity.prototype.start = function() {
return that.onHostInfo_(response);
}).then(function(/** remoting.Host */ host) {
that.connect_(host);
- }).catch(function(/** remoting.Error */ error) {
+ }).catch(remoting.Error.handler(function(/** remoting.Error */ error) {
if (error.hasTag(remoting.Error.Tag.CANCELLED)) {
remoting.setMode(remoting.AppMode.HOME);
} else {
@@ -63,7 +66,7 @@ remoting.It2MeActivity.prototype.start = function() {
l10n.localizeElementFromTag(errorDiv, error.getTag());
remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME);
}
- });
+ }));
};
remoting.It2MeActivity.prototype.stop = function() {
@@ -74,7 +77,9 @@ remoting.It2MeActivity.prototype.stop = function() {
* @param {!remoting.Error} error
*/
remoting.It2MeActivity.prototype.onConnectionFailed = function(error) {
- this.onError(error);
+ this.showErrorMessage_(error);
+ base.dispose(this.desktopActivity_);
+ this.desktopActivity_ = null;
};
/**
@@ -84,14 +89,22 @@ remoting.It2MeActivity.prototype.onConnected = function(connectionInfo) {
this.accessCodeDialog_.inputField().value = '';
};
-remoting.It2MeActivity.prototype.onDisconnected = function() {
- this.showFinishDialog_(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME);
+remoting.It2MeActivity.prototype.onDisconnected = function(error) {
+ if (error.isNone()) {
+ this.showFinishDialog_(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME);
+ } else {
+ this.showErrorMessage_(error);
+ }
+
+ base.dispose(this.desktopActivity_);
+ this.desktopActivity_ = null;
};
/**
* @param {!remoting.Error} error
+ * @private
*/
-remoting.It2MeActivity.prototype.onError = function(error) {
+remoting.It2MeActivity.prototype.showErrorMessage_ = function(error) {
var errorDiv = document.getElementById('connect-error-message');
l10n.localizeElementFromTag(errorDiv, error.getTag());
this.showFinishDialog_(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME);
@@ -183,9 +196,6 @@ remoting.It2MeActivity.prototype.onHostInfo_ = function(xhrResponse) {
* @private
*/
remoting.It2MeActivity.prototype.connect_ = function(host) {
- base.dispose(this.desktopActivity_);
- this.desktopActivity_ = new remoting.DesktopRemotingActivity(this);
- remoting.app.setConnectionMode(remoting.Application.Mode.IT2ME);
this.desktopActivity_.start(
host, new remoting.CredentialsProvider({ accessCode: this.passCode_ }));
};

Powered by Google App Engine
This is Rietveld 408576698