OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * The current v1 web-app allows users to sign in as any user. Some users may | 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 | 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 | 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 | 10 * obvious why. remoting.AppsV2Migration shows a migration tip to the user to |
(...skipping 29 matching lines...) Expand all Loading... |
40 * Otherwise, the promise will be rejected. | 40 * Otherwise, the promise will be rejected. |
41 */ | 41 */ |
42 remoting.AppsV2Migration.hasHostsInV1App = function() { | 42 remoting.AppsV2Migration.hasHostsInV1App = function() { |
43 if (!base.isAppsV2()) { | 43 if (!base.isAppsV2()) { |
44 return Promise.reject(false); | 44 return Promise.reject(false); |
45 } | 45 } |
46 | 46 |
47 var getV1UserInfo = base.Promise.as(chrome.storage.local.get, | 47 var getV1UserInfo = base.Promise.as(chrome.storage.local.get, |
48 [MIGRATION_KEY_], | 48 [MIGRATION_KEY_], |
49 chrome.storage.local); | 49 chrome.storage.local); |
50 var getEmail = base.Promise.as(remoting.identity.getUserInfo, [], | 50 var getEmail = remoting.identity.getEmail(); |
51 remoting.identity, true); | |
52 | 51 |
53 return Promise.all([getV1UserInfo, getEmail]).then( | 52 return Promise.all([getV1UserInfo, getEmail]).then( |
54 /** @param {Object} results */ | 53 /** @param {Object} results */ |
55 function(results){ | 54 function(results){ |
56 var v1User = | 55 var v1User = |
57 /**@type {remoting.MigrationSettings} */ (results[0][MIGRATION_KEY_]); | 56 /**@type {remoting.MigrationSettings} */ (results[0][MIGRATION_KEY_]); |
58 var currentEmail = /** @type {string}*/ (results[1]); | 57 var currentEmail = /** @type {string}*/ (results[1]); |
59 | 58 |
60 if (v1User && v1User.email && v1User.email !== currentEmail) { | 59 if (v1User && v1User.email && v1User.email !== currentEmail) { |
61 return Promise.resolve(v1User); | 60 return Promise.resolve(v1User); |
(...skipping 24 matching lines...) Expand all Loading... |
86 * in the v1 app. Clears the migration settings in the v2 app. | 85 * in the v1 app. Clears the migration settings in the v2 app. |
87 */ | 86 */ |
88 remoting.AppsV2Migration.saveUserInfo = function() { | 87 remoting.AppsV2Migration.saveUserInfo = function() { |
89 if (base.isAppsV2()) { | 88 if (base.isAppsV2()) { |
90 chrome.storage.local.remove(MIGRATION_KEY_); | 89 chrome.storage.local.remove(MIGRATION_KEY_); |
91 } else { | 90 } else { |
92 /** | 91 /** |
93 * @param {string} email | 92 * @param {string} email |
94 * @param {string} fullName | 93 * @param {string} fullName |
95 */ | 94 */ |
96 remoting.identity.getUserInfo(function(email, fullName) { | 95 remoting.identity.getUserInfo().then(function(userInfo) { |
97 var preference = {}; | 96 var preference = {}; |
98 preference[MIGRATION_KEY_] = | 97 preference[MIGRATION_KEY_] = |
99 new remoting.MigrationSettings(email, fullName); | 98 new remoting.MigrationSettings(userInfo.email, userInfo.name); |
100 chrome.storage.local.set(preference); | 99 chrome.storage.local.set(preference); |
101 }, base.doNothing); | 100 }).catch(base.doNothing); |
102 } | 101 } |
103 }; | 102 }; |
104 | 103 |
105 }()); | 104 }()); |
106 | |
OLD | NEW |