Chromium Code Reviews| Index: chrome/browser/resources/settings/people_page/user_list.js |
| diff --git a/chrome/browser/resources/settings/people_page/user_list.js b/chrome/browser/resources/settings/people_page/user_list.js |
| index 3fd8ce1c7a956374fc7b3d27ef12c90f277dcef0..8c4cc65cb347299bac2db67fd8c115828b7bb16e 100644 |
| --- a/chrome/browser/resources/settings/people_page/user_list.js |
| +++ b/chrome/browser/resources/settings/people_page/user_list.js |
| @@ -15,12 +15,16 @@ |
| Polymer({ |
| is: 'settings-user-list', |
| + behaviors: [ |
| + settings.RouteObserverBehavior, |
| + ], |
| + |
| properties: { |
| /** |
| * Current list of whitelisted users. |
| - * @type {!Array<!chrome.usersPrivate.User>} |
| + * @private {!Array<!chrome.usersPrivate.User>} |
| */ |
| - users: { |
| + users_: { |
| type: Array, |
| value: function() { return []; }, |
| notify: true |
| @@ -37,21 +41,28 @@ Polymer({ |
| } |
| }, |
| - /** @override */ |
| - ready: function() { |
| - chrome.settingsPrivate.onPrefsChanged.addListener(function(prefs) { |
|
tommycli
2016/11/14 20:11:57
What happened so that we no longer need the pref c
Moe
2016/11/15 16:46:48
I was under the impression that, in order to add a
|
| - prefs.forEach(function(pref) { |
| - if (pref.key == 'cros.accounts.users') { |
| - chrome.usersPrivate.getWhitelistedUsers(function(users) { |
| - this.users = users; |
| - }.bind(this)); |
| - } |
| - }, this); |
| - }.bind(this)); |
| + /** @protected */ |
| + currentRouteChanged: function() { |
| + if (this.isAttached && |
|
tommycli
2016/11/14 20:11:58
Can this ever fail? i.e., can this callback be cal
Moe
2016/11/15 16:46:48
From what I see in route.js no. But I saw this htt
tommycli
2016/11/15 17:50:35
Honestly I'm not sure why it's in sync_page either
|
| + (settings.getCurrentRoute() == settings.Route.ACCOUNTS)) { |
| + chrome.usersPrivate.getWhitelistedUsers(function(users) { |
| + this.setUsers_(users); |
| + }.bind(this)); |
| + } |
| + }, |
| - chrome.usersPrivate.getWhitelistedUsers(function(users) { |
| - this.users = users; |
| - }.bind(this)); |
| + /** |
| + * Helper function that sorts and sets the given list of whitelisted users. |
| + * @param {!Array<!chrome.usersPrivate.User>} users List of whitelisted users. |
| + */ |
| + setUsers_: function(users) { |
| + this.users_ = users; |
| + this.users_.sort(function(a, b) { |
| + if (a.isOwner != b.isOwner) |
| + return b.isOwner ? 1 : -1; |
| + else |
| + return -1; |
| + }); |
| }, |
| /** |
| @@ -66,5 +77,10 @@ Polymer({ |
| /** @private */ |
| shouldHideCloseButton_: function(disabled, isUserOwner) { |
| return disabled || isUserOwner; |
| + }, |
| + |
| + /** @private */ |
| + getProfilePictureUrl_: function(username) { |
| + return 'chrome://userimage/' + username + '?id=' + Date.now(); |
| } |
| }); |