Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 /** @protected */ |
| 41 ready: function() { | 45 currentRouteChanged: function() { |
| 42 chrome.settingsPrivate.onPrefsChanged.addListener(function(prefs) { | 46 if (this.isAttached && |
|
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
|
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
|
| 43 prefs.forEach(function(pref) { | 47 (settings.getCurrentRoute() == settings.Route.ACCOUNTS)) { |
| 44 if (pref.key == 'cros.accounts.users') { | 48 chrome.usersPrivate.getWhitelistedUsers(function(users) { |
| 45 chrome.usersPrivate.getWhitelistedUsers(function(users) { | 49 this.setUsers_(users); |
| 46 this.users = users; | 50 }.bind(this)); |
| 47 }.bind(this)); | 51 } |
| 48 } | |
| 49 }, this); | |
| 50 }.bind(this)); | |
| 51 | |
| 52 chrome.usersPrivate.getWhitelistedUsers(function(users) { | |
| 53 this.users = users; | |
| 54 }.bind(this)); | |
| 55 }, | 52 }, |
| 56 | 53 |
| 57 /** | 54 /** |
| 55 * Helper function that sorts and sets the given list of whitelisted users. | |
| 56 * @param {!Array<!chrome.usersPrivate.User>} users List of whitelisted users. | |
| 57 */ | |
| 58 setUsers_: function(users) { | |
| 59 this.users_ = users; | |
| 60 this.users_.sort(function(a, b) { | |
| 61 if (a.isOwner != b.isOwner) | |
| 62 return b.isOwner ? 1 : -1; | |
| 63 else | |
| 64 return -1; | |
| 65 }); | |
| 66 }, | |
| 67 | |
| 68 /** | |
| 58 * @private | 69 * @private |
| 59 * @param {!{model: !{item: !chrome.usersPrivate.User}}} e | 70 * @param {!{model: !{item: !chrome.usersPrivate.User}}} e |
| 60 */ | 71 */ |
| 61 removeUser_: function(e) { | 72 removeUser_: function(e) { |
| 62 chrome.usersPrivate.removeWhitelistedUser( | 73 chrome.usersPrivate.removeWhitelistedUser( |
| 63 e.model.item.email, /* callback */ function() {}); | 74 e.model.item.email, /* callback */ function() {}); |
| 64 }, | 75 }, |
| 65 | 76 |
| 66 /** @private */ | 77 /** @private */ |
| 67 shouldHideCloseButton_: function(disabled, isUserOwner) { | 78 shouldHideCloseButton_: function(disabled, isUserOwner) { |
| 68 return disabled || isUserOwner; | 79 return disabled || isUserOwner; |
| 80 }, | |
| 81 | |
| 82 /** @private */ | |
| 83 getProfilePictureUrl_: function(username) { | |
| 84 return 'chrome://userimage/' + username + '?id=' + Date.now(); | |
| 69 } | 85 } |
| 70 }); | 86 }); |
| OLD | NEW |