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

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

Issue 848993002: Improve apps v2 upgrade UX (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address outstanding feedbacks Created 5 years, 11 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/html/ui_me2me.html ('k') | remoting/webapp/crd/js/host_list.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/crd/js/apps_v2_migration.js
diff --git a/remoting/webapp/crd/js/apps_v2_migration.js b/remoting/webapp/crd/js/apps_v2_migration.js
new file mode 100644
index 0000000000000000000000000000000000000000..61c174ed8f11e0a86e6710715c8273f31731a6b9
--- /dev/null
+++ b/remoting/webapp/crd/js/apps_v2_migration.js
@@ -0,0 +1,106 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+* @fileoverview
+* The current v1 web-app allows users to sign in as any user. Some users may
+* be signed in using a different account than their chrome profile. When these
+* users upgrade to the v2 app, their host list will be empty and it is not
+* obvious why. remoting.AppsV2Migration shows a migration tip to the user to
+* sign in to their previous accounts if necessary.
+*/
+
+'use strict';
+
+/** @suppress {duplicate} */
+var remoting = remoting || {};
+
+(function() {
+
+// Storage key used for the migration settings.
+var MIGRATION_KEY_ = 'remoting-v2-migration';
+
+/**
+ * @constructor
+ * @param {string} email
+ * @param {string} fullName
+ */
+remoting.MigrationSettings = function(email, fullName) {
+ this.email = email;
+ this.fullName = fullName;
+};
+
+remoting.AppsV2Migration = function() {};
+
+/**
+ * @return {Promise} A Promise object that would resolve to
+ * {remoting.MigrationSettings} if the user has previously signed-in to
+ * the v1 app with a different account that has hosts registered to it.
+ * Otherwise, the promise will be rejected.
+ */
+remoting.AppsV2Migration.hasHostsInV1App = function() {
+ if (!base.isAppsV2()) {
+ return Promise.reject(false);
+ }
+
+ var getV1UserInfo = base.Promise.as(chrome.storage.local.get,
+ [MIGRATION_KEY_],
+ chrome.storage.local);
+ var getEmail = base.Promise.as(remoting.identity.getUserInfo, [],
+ remoting.identity, true);
+
+ return Promise.all([getV1UserInfo, getEmail]).then(
+ /** @param {Object} results */
+ function(results){
+ var v1User =
+ /**@type {remoting.MigrationSettings} */ (results[0][MIGRATION_KEY_]);
+ var currentEmail = /** @type {string}*/ (results[1]);
+
+ if (v1User && v1User.email && v1User.email !== currentEmail) {
+ return Promise.resolve(v1User);
+ }
+ return Promise.reject(false);
+ }
+ );
+};
+
+/**
+ * @param {string} email
+ * @param {string} fullName
+ * @return {string}
+ */
+remoting.AppsV2Migration.buildMigrationTips = function(email, fullName) {
+ var params = [
+ fullName,
+ email,
+ '<a href="https://support.google.com/chrome/answer/2364824?hl=en" ' +
+ 'target="_blank">',
+ '</a>'];
+ return l10n.getTranslationOrError(
+ /*i18n-content*/'HOST_LIST_EMPTY_V2_MIGRATION', params);
+};
+
+/**
+ * Saves the email and full name of the current user as the migration settings
+ * in the v1 app. Clears the migration settings in the v2 app.
+ */
+remoting.AppsV2Migration.saveUserInfo = function() {
+ if (base.isAppsV2()) {
+ chrome.storage.local.remove(MIGRATION_KEY_);
+ } else {
+ /**
+ * @param {string} email
+ * @param {string} fullName
+ */
+ remoting.identity.getUserInfo(function(email, fullName) {
+ var preference = {};
+ preference[MIGRATION_KEY_] =
+ new remoting.MigrationSettings(email, fullName);
+ chrome.storage.local.set(preference);
+ }, base.doNothing);
+ }
+};
+
+}());
+
« no previous file with comments | « remoting/webapp/crd/html/ui_me2me.html ('k') | remoting/webapp/crd/js/host_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698