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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview
7 * The current v1 web-app allows users to sign in as any user. Some users may
8 * be signed in using a different account than their chrome profile. When these
9 * users upgrade to the v2 app, their host list will be empty and it is not
10 * obvious why. remoting.AppsV2Migration shows a migration tip to the user to
11 * sign in to their previous accounts if necessary.
12 */
13
14 'use strict';
15
16 /** @suppress {duplicate} */
17 var remoting = remoting || {};
18
19 (function() {
20
21 // Storage key used for the migration settings.
22 var MIGRATION_KEY_ = 'remoting-v2-migration';
23
24 /**
25 * @constructor
26 * @param {string} email
27 * @param {string} fullName
28 */
29 remoting.MigrationSettings = function(email, fullName) {
30 this.email = email;
31 this.fullName = fullName;
32 };
33
34 remoting.AppsV2Migration = function() {};
35
36 /**
37 * @return {Promise} A Promise object that would resolve to
38 * {remoting.MigrationSettings} if the user has previously signed-in to
39 * the v1 app with a different account that has hosts registered to it.
40 * Otherwise, the promise will be rejected.
41 */
42 remoting.AppsV2Migration.hasHostsInV1App = function() {
43 if (!base.isAppsV2()) {
44 return Promise.reject(false);
45 }
46
47 var getV1UserInfo = base.Promise.as(chrome.storage.local.get,
48 [MIGRATION_KEY_],
49 chrome.storage.local);
50 var getEmail = base.Promise.as(remoting.identity.getUserInfo, [],
51 remoting.identity, true);
52
53 return Promise.all([getV1UserInfo, getEmail]).then(
54 /** @param {Object} results */
55 function(results){
56 var v1User =
57 /**@type {remoting.MigrationSettings} */ (results[0][MIGRATION_KEY_]);
58 var currentEmail = /** @type {string}*/ (results[1]);
59
60 if (v1User && v1User.email && v1User.email !== currentEmail) {
61 return Promise.resolve(v1User);
62 }
63 return Promise.reject(false);
64 }
65 );
66 };
67
68 /**
69 * @param {string} email
70 * @param {string} fullName
71 * @return {string}
72 */
73 remoting.AppsV2Migration.buildMigrationTips = function(email, fullName) {
74 var params = [
75 fullName,
76 email,
77 '<a href="https://support.google.com/chrome/answer/2364824?hl=en" ' +
78 'target="_blank">',
79 '</a>'];
80 return l10n.getTranslationOrError(
81 /*i18n-content*/'HOST_LIST_EMPTY_V2_MIGRATION', params);
82 };
83
84 /**
85 * Saves the email and full name of the current user as the migration settings
86 * in the v1 app. Clears the migration settings in the v2 app.
87 */
88 remoting.AppsV2Migration.saveUserInfo = function() {
89 if (base.isAppsV2()) {
90 chrome.storage.local.remove(MIGRATION_KEY_);
91 } else {
92 /**
93 * @param {string} email
94 * @param {string} fullName
95 */
96 remoting.identity.getUserInfo(function(email, fullName) {
97 var preference = {};
98 preference[MIGRATION_KEY_] =
99 new remoting.MigrationSettings(email, fullName);
100 chrome.storage.local.set(preference);
101 }, base.doNothing);
102 }
103 };
104
105 }());
106
OLDNEW
« 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