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

Side by Side 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: Addressed comment 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 * 'settings-user-list' shows a list of users whitelisted on this Chrome OS 7 * 'settings-user-list' shows a list of users whitelisted on this Chrome OS
8 * device. 8 * device.
9 * 9 *
10 * Example: 10 * Example:
11 * 11 *
12 * <settings-user-list prefs="{{prefs}}"> 12 * <settings-user-list prefs="{{prefs}}">
13 * </settings-user-list> 13 * </settings-user-list>
14 */ 14 */
15 Polymer({ 15 Polymer({
16 is: 'settings-user-list', 16 is: 'settings-user-list',
17 17
18 behaviors: [
19 settings.RouteObserverBehavior,
20 ],
21
18 properties: { 22 properties: {
19 /** 23 /**
20 * Current list of whitelisted users. 24 * Current list of whitelisted users.
21 * @type {!Array<!chrome.usersPrivate.User>} 25 * @private {!Array<!chrome.usersPrivate.User>}
22 */ 26 */
23 users: { 27 users_: {
24 type: Array, 28 type: Array,
25 value: function() { return []; }, 29 value: function() { return []; },
26 notify: true 30 notify: true
27 }, 31 },
28 32
29 /** 33 /**
30 * Whether the user list is disabled, i.e. that no modifications can be 34 * Whether the user list is disabled, i.e. that no modifications can be
31 * made. 35 * made.
32 * @type {boolean} 36 * @type {boolean}
33 */ 37 */
34 disabled: { 38 disabled: {
35 type: Boolean, 39 type: Boolean,
36 value: false 40 value: false
37 } 41 }
38 }, 42 },
39 43
40 /** @override */ 44 /** @override */
41 ready: function() { 45 ready: function() {
42 chrome.settingsPrivate.onPrefsChanged.addListener(function(prefs) { 46 chrome.settingsPrivate.onPrefsChanged.addListener(function(prefs) {
43 prefs.forEach(function(pref) { 47 prefs.forEach(function(pref) {
44 if (pref.key == 'cros.accounts.users') { 48 if (pref.key == 'cros.accounts.users') {
45 chrome.usersPrivate.getWhitelistedUsers(function(users) { 49 chrome.usersPrivate.getWhitelistedUsers(function(users) {
46 this.users = users; 50 this.setUsers_(users);
47 }.bind(this)); 51 }.bind(this));
48 } 52 }
49 }, this); 53 }, this);
50 }.bind(this)); 54 }.bind(this));
55 },
51 56
52 chrome.usersPrivate.getWhitelistedUsers(function(users) { 57 /** @protected */
53 this.users = users; 58 currentRouteChanged: function() {
54 }.bind(this)); 59 if (settings.getCurrentRoute() == settings.Route.ACCOUNTS) {
60 chrome.usersPrivate.getWhitelistedUsers(function(users) {
61 this.setUsers_(users);
62 }.bind(this));
63 }
55 }, 64 },
56 65
57 /** 66 /**
67 * Helper function that sorts and sets the given list of whitelisted users.
68 * @param {!Array<!chrome.usersPrivate.User>} users List of whitelisted users.
69 */
70 setUsers_: function(users) {
71 this.users_ = users;
72 this.users_.sort(function(a, b) {
73 if (a.isOwner != b.isOwner)
74 return b.isOwner ? 1 : -1;
75 else
76 return -1;
77 });
78 },
79
80 /**
58 * @private 81 * @private
59 * @param {!{model: !{item: !chrome.usersPrivate.User}}} e 82 * @param {!{model: !{item: !chrome.usersPrivate.User}}} e
60 */ 83 */
61 removeUser_: function(e) { 84 removeUser_: function(e) {
62 chrome.usersPrivate.removeWhitelistedUser( 85 chrome.usersPrivate.removeWhitelistedUser(
63 e.model.item.email, /* callback */ function() {}); 86 e.model.item.email, /* callback */ function() {});
64 }, 87 },
65 88
66 /** @private */ 89 /** @private */
67 shouldHideCloseButton_: function(disabled, isUserOwner) { 90 shouldHideCloseButton_: function(disabled, isUserOwner) {
68 return disabled || isUserOwner; 91 return disabled || isUserOwner;
92 },
93
94 /** @private */
95 getProfilePictureUrl_: function(username) {
96 return 'chrome://userimage/' + username + '?id=' + Date.now();
69 } 97 }
70 }); 98 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698