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

Unified Diff: remoting/webapp/app_remoting/js/app_remoting_activity.js

Issue 1100763002: Inject CanAddURLToHistory into TopSitesImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs
Patch Set: Fix error introduced during rebase 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/app_remoting/js/app_remoting_activity.js
diff --git a/remoting/webapp/app_remoting/js/app_remoting_activity.js b/remoting/webapp/app_remoting/js/app_remoting_activity.js
index fecd55d55bf37f7d98addd5fabc9d3f0172e745a..8afef921a5693532695ef3227d12b4cd467c8dba 100644
--- a/remoting/webapp/app_remoting/js/app_remoting_activity.js
+++ b/remoting/webapp/app_remoting/js/app_remoting_activity.js
@@ -140,12 +140,18 @@ remoting.AppRemotingActivity.prototype.onAppHostResponse_ =
session.connect(host, credentialsProvider);
});
} else if (response && response.status == 'pending') {
- this.onError(new remoting.Error(
+ this.onConnectionFailed(new remoting.Error(
remoting.Error.Tag.SERVICE_UNAVAILABLE));
}
} else {
console.error('Invalid "runApplication" response from server.');
- this.onError(remoting.Error.fromHttpStatus(xhrResponse.status));
+ // The orchestrator returns 403 if the user is not whitelisted to run the
+ // app, which gets translated to a generic error message, so pick something
+ // a bit more user-friendly.
+ var error = xhrResponse.status == 403 ?
+ new remoting.Error(remoting.Error.Tag.APP_NOT_AUTHORIZED) :
+ remoting.Error.fromHttpStatus(xhrResponse.status);
+ this.onConnectionFailed(error);
}
};
@@ -166,28 +172,36 @@ remoting.AppRemotingActivity.prototype.onConnected = function(connectionInfo) {
}
};
-remoting.AppRemotingActivity.prototype.onDisconnected = function() {
+/**
+ * @param {remoting.Error} error
+ */
+remoting.AppRemotingActivity.prototype.onDisconnected = function(error) {
+ if (error.isNone()) {
+ chrome.app.window.current().close();
+ } else {
+ this.showErrorMessage_(error);
+ }
this.cleanup_();
- chrome.app.window.current().close();
};
/**
* @param {!remoting.Error} error
*/
remoting.AppRemotingActivity.prototype.onConnectionFailed = function(error) {
- this.onError(error);
+ remoting.LoadingWindow.close();
+ this.showErrorMessage_(error);
+ this.cleanup_();
};
/**
* @param {!remoting.Error} error The error to be localized and displayed.
+ * @private
*/
-remoting.AppRemotingActivity.prototype.onError = function(error) {
+remoting.AppRemotingActivity.prototype.showErrorMessage_ = function(error) {
console.error('Connection failed: ' + error.toString());
- remoting.LoadingWindow.close();
remoting.MessageWindow.showErrorMessage(
- chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'),
+ remoting.app.getApplicationName(),
chrome.i18n.getMessage(error.getTag()));
- this.cleanup_();
};
})();
« no previous file with comments | « remoting/webapp/app_remoting/js/app_remoting.js ('k') | remoting/webapp/app_remoting/manifest_common.json.jinja2 » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698