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

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

Issue 1054273002: [Webapp Refactor] Implements remoting.Activity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo 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
« no previous file with comments | « remoting/webapp/crd/js/desktop_remoting.js ('k') | remoting/webapp/crd/js/it2me_connect_flow.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/crd/js/it2me_activity.js
diff --git a/remoting/webapp/crd/js/it2me_connect_flow.js b/remoting/webapp/crd/js/it2me_activity.js
similarity index 79%
rename from remoting/webapp/crd/js/it2me_connect_flow.js
rename to remoting/webapp/crd/js/it2me_activity.js
index 57f39db394418fdbb662e1cc61b0157037879099..144253d5dc06447ea5b7bd94b11617e7952d75ab 100644
--- a/remoting/webapp/crd/js/it2me_connect_flow.js
+++ b/remoting/webapp/crd/js/it2me_activity.js
@@ -17,8 +17,9 @@ var ACCESS_CODE_LENGTH = SUPPORT_ID_LENGTH + HOST_SECRET_LENGTH;
/**
* @param {remoting.SessionConnector} sessionConnector
* @constructor
+ * @implements {remoting.Activity}
*/
-remoting.It2MeConnectFlow = function(sessionConnector) {
+remoting.It2MeActivity = function(sessionConnector) {
/** @private */
this.sessionConnector_ = sessionConnector;
/** @private */
@@ -35,8 +36,9 @@ remoting.It2MeConnectFlow = function(sessionConnector) {
form.querySelector('#cancel-access-code-button'));
};
+remoting.It2MeActivity.prototype.dispose = function() {};
-remoting.It2MeConnectFlow.prototype.start = function() {
+remoting.It2MeActivity.prototype.start = function() {
var that = this;
this.accessCodeDialog_.show().then(function(/** string */ accessCode) {
@@ -65,11 +67,39 @@ remoting.It2MeConnectFlow.prototype.start = function() {
};
/**
+ * @param {!remoting.Error} error
+ */
+remoting.It2MeActivity.prototype.onConnectionFailed = function(error) {
+ this.onError(error);
+};
+
+/**
+ * @param {!remoting.ConnectionInfo} connectionInfo
+ */
+remoting.It2MeActivity.prototype.onConnected = function(connectionInfo) {
+ this.accessCodeDialog_.inputField().value = '';
+};
+
+remoting.It2MeActivity.prototype.onDisconnected = function() {
+ remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME);
+};
+
+/**
+ * @param {!remoting.Error} error
+ */
+remoting.It2MeActivity.prototype.onError = function(error) {
+ var errorDiv = document.getElementById('connect-error-message');
+ l10n.localizeElementFromTag(errorDiv, error.getTag());
+ remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME);
+};
+
+
+/**
* @param {string} accessCode
* @return {Promise} Promise that resolves if the access code is valid.
* @private
*/
-remoting.It2MeConnectFlow.prototype.verifyAccessCode_ = function(accessCode) {
+remoting.It2MeActivity.prototype.verifyAccessCode_ = function(accessCode) {
var normalizedAccessCode = accessCode.replace(/\s/g, '');
if (normalizedAccessCode.length !== ACCESS_CODE_LENGTH) {
return Promise.reject(new remoting.Error(
@@ -89,7 +119,7 @@ remoting.It2MeConnectFlow.prototype.verifyAccessCode_ = function(accessCode) {
* @return {Promise<!remoting.Xhr.Response>}
* @private
*/
-remoting.It2MeConnectFlow.prototype.getHostInfo_ = function(token) {
+remoting.It2MeActivity.prototype.getHostInfo_ = function(token) {
var that = this;
return new remoting.Xhr({
method: 'GET',
@@ -107,7 +137,7 @@ remoting.It2MeConnectFlow.prototype.getHostInfo_ = function(token) {
* @return {!Promise<!remoting.Host>} Rejects on error.
* @private
*/
-remoting.It2MeConnectFlow.prototype.onHostInfo_ = function(xhrResponse) {
+remoting.It2MeActivity.prototype.onHostInfo_ = function(xhrResponse) {
if (xhrResponse.status == 200) {
var response = /** @type {{data: {jabberId: string, publicKey: string}}} */
(base.jsonParseSafe(xhrResponse.getText()));
« no previous file with comments | « remoting/webapp/crd/js/desktop_remoting.js ('k') | remoting/webapp/crd/js/it2me_connect_flow.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698