Chromium Code Reviews| Index: chrome/browser/resources/options/chromeos/accounts_user_list.js |
| diff --git a/chrome/browser/resources/options/chromeos/accounts_user_list.js b/chrome/browser/resources/options/chromeos/accounts_user_list.js |
| index ce5a072dd9781066bc59c1f3438e37205561e0c2..927b7c9a15b3acb56991f19070b5ced6419e3d63 100644 |
| --- a/chrome/browser/resources/options/chromeos/accounts_user_list.js |
| +++ b/chrome/browser/resources/options/chromeos/accounts_user_list.js |
| @@ -43,12 +43,12 @@ cr.define('options.accounts', function() { |
| }, |
| /** |
| - * Finds the index of user by given email. |
| + * Finds the index of user by given username (canonicalized email). |
| * @private |
| - * @param {string} email The email address to look for. |
| + * @param {string} username The username to look for. |
| * @return {number} The index of the found user or -1 if not found. |
| */ |
| - findUserByEmail_: function(email) { |
| + indexOf_: function(username) { |
| var dataModel = this.dataModel; |
| if (!dataModel) |
| return -1; |
| @@ -56,7 +56,7 @@ cr.define('options.accounts', function() { |
| var length = dataModel.length; |
| for (var i = 0; i < length; ++i) { |
| var user = dataModel.item(i); |
| - if (user.email == email) { |
| + if (user.username == username) { |
| return i; |
| } |
| } |
| @@ -65,36 +65,33 @@ cr.define('options.accounts', function() { |
| }, |
| /** |
| - * Adds given user to model and update backend. |
| - * @param {Object} user A user to be added to user list. |
| + * Adds given user to the model (this comes from the backend so there is no |
| + * need to update it). |
| + * @param {Object} user User info object to be added to user list. |
| */ |
| addUser: function(user) { |
| - var index = this.findUserByEmail_(user.email); |
| - if (index == -1) { |
| - this.dataModel.push(user); |
| - chrome.send('whitelistUser', [user.email]); |
| - } |
| + this.dataModel.push(user); |
| }, |
| /** |
| - * Removes given user from model and update backend. |
| + * Removes given user from the tmodel and updates backend. |
|
James Hawkins
2011/12/02 18:12:01
tmodel: is this a spelling mistake?
Ivan Korotkov
2011/12/02 18:30:30
Yep, fixed.
|
| + * @param {Object} user User info object to be removed from user list. |
| */ |
| removeUser: function(user) { |
| var dataModel = this.dataModel; |
| - |
| var index = dataModel.indexOf(user); |
| if (index >= 0) { |
| dataModel.splice(index, 1); |
| - chrome.send('unwhitelistUser', [user.email]); |
| + chrome.send('unwhitelistUser', [user.username]); |
| } |
| }, |
| /** |
| * Update given user's account picture. |
| - * @param {string} email Email of the user to update. |
| + * @param {string} username User for which to update the image. |
| */ |
| - updateAccountPicture: function(email) { |
| - var index = this.findUserByEmail_(email); |
| + updateAccountPicture: function(username) { |
| + var index = this.indexOf_(username); |
| if (index >= 0) { |
| var item = this.getListItemByIndex(index); |
| if (item) |
| @@ -201,7 +198,7 @@ cr.define('options.accounts', function() { |
| * Reloads user picture. |
| */ |
| updatePicture: function() { |
| - this.icon_.src = 'chrome://userimage/' + this.user.email + |
| + this.icon_.src = 'chrome://userimage/' + this.user.username + |
| '?id=' + (new Date()).getTime(); |
| } |
| }; |