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

Unified Diff: chrome/browser/resources/settings/people_page/user_list.js

Issue 2495933002: [MD settings][cros accounts] Updates the accounts page according to the specs (Closed)
Patch Set: Created 4 years, 1 month 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
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();
}
});

Powered by Google App Engine
This is Rietveld 408576698