OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options.browser_options', function() { | 5 cr.define('options.browser_options', function() { |
6 /** @const */ var DeletableItem = options.DeletableItem; | 6 /** @const */ var DeletableItem = options.DeletableItem; |
7 /** @const */ var DeletableItemList = options.DeletableItemList; | 7 /** @const */ var DeletableItemList = options.DeletableItemList; |
8 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 8 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
9 | 9 |
10 /** | 10 /** |
(...skipping 21 matching lines...) Expand all Loading... |
32 ProfileListItem.prototype = { | 32 ProfileListItem.prototype = { |
33 __proto__: DeletableItem.prototype, | 33 __proto__: DeletableItem.prototype, |
34 | 34 |
35 /** | 35 /** |
36 * @type {string} the file path of this profile list item. | 36 * @type {string} the file path of this profile list item. |
37 */ | 37 */ |
38 get profilePath() { | 38 get profilePath() { |
39 return this.profileInfo_.filePath; | 39 return this.profileInfo_.filePath; |
40 }, | 40 }, |
41 | 41 |
42 /** | |
43 * @type {boolean} whether this profile is managed. | |
44 */ | |
45 get isManaged() { | |
46 return this.profileInfo_.isManaged; | |
47 }, | |
48 | |
49 /** @override */ | 42 /** @override */ |
50 decorate: function() { | 43 decorate: function() { |
51 DeletableItem.prototype.decorate.call(this); | 44 DeletableItem.prototype.decorate.call(this); |
52 | 45 |
53 var profileInfo = this.profileInfo_; | 46 var profileInfo = this.profileInfo_; |
54 | 47 |
55 var containerEl = this.ownerDocument.createElement('div'); | 48 var containerEl = this.ownerDocument.createElement('div'); |
56 containerEl.className = 'profile-container'; | 49 containerEl.className = 'profile-container'; |
57 | 50 |
58 var iconEl = this.ownerDocument.createElement('img'); | 51 var iconEl = this.ownerDocument.createElement('img'); |
59 iconEl.className = 'profile-img'; | 52 iconEl.className = 'profile-img'; |
60 iconEl.style.content = getProfileAvatarIcon(profileInfo.iconURL); | 53 iconEl.style.content = getProfileAvatarIcon(profileInfo.iconURL); |
61 containerEl.appendChild(iconEl); | 54 containerEl.appendChild(iconEl); |
62 | 55 |
63 var nameEl = this.ownerDocument.createElement('div'); | 56 var nameEl = this.ownerDocument.createElement('div'); |
64 nameEl.className = 'profile-name'; | 57 nameEl.className = 'profile-name'; |
65 if (profileInfo.isCurrentProfile) | 58 if (profileInfo.isCurrentProfile) |
66 nameEl.classList.add('profile-item-current'); | 59 nameEl.classList.add('profile-item-current'); |
67 containerEl.appendChild(nameEl); | 60 containerEl.appendChild(nameEl); |
68 | 61 |
69 var displayName = profileInfo.name; | 62 var displayName = profileInfo.name; |
70 if (profileInfo.isCurrentProfile) { | 63 if (profileInfo.isCurrentProfile) { |
71 displayName = loadTimeData.getStringF('profilesListItemCurrent', | 64 displayName = loadTimeData.getStringF('profilesListItemCurrent', |
72 profileInfo.name); | 65 profileInfo.name); |
73 } | 66 } |
74 nameEl.textContent = displayName; | 67 nameEl.textContent = displayName; |
75 | 68 |
76 if (profileInfo.isManaged) { | 69 if (profileInfo.isSupervised) { |
77 var supervisedEl = this.ownerDocument.createElement('div'); | 70 var supervisedEl = this.ownerDocument.createElement('div'); |
78 supervisedEl.className = 'profile-supervised'; | 71 supervisedEl.className = 'profile-supervised'; |
79 supervisedEl.textContent = | 72 supervisedEl.textContent = |
80 '(' + loadTimeData.getStringF('managedUserLabel') + ')'; | 73 '(' + loadTimeData.getStringF('supervisedUserLabel') + ')'; |
81 containerEl.appendChild(supervisedEl); | 74 containerEl.appendChild(supervisedEl); |
82 } | 75 } |
83 | 76 |
84 this.contentElement.appendChild(containerEl); | 77 this.contentElement.appendChild(containerEl); |
85 | 78 |
86 // Ensure that the button cannot be tabbed to for accessibility reasons. | 79 // Ensure that the button cannot be tabbed to for accessibility reasons. |
87 this.closeButtonElement.tabIndex = -1; | 80 this.closeButtonElement.tabIndex = -1; |
88 }, | 81 }, |
89 }; | 82 }; |
90 | 83 |
(...skipping 10 matching lines...) Expand all Loading... |
101 | 94 |
102 /** @override */ | 95 /** @override */ |
103 createItem: function(pageInfo) { | 96 createItem: function(pageInfo) { |
104 var item = new ProfileListItem(pageInfo); | 97 var item = new ProfileListItem(pageInfo); |
105 item.deletable = this.canDeleteItems_; | 98 item.deletable = this.canDeleteItems_; |
106 return item; | 99 return item; |
107 }, | 100 }, |
108 | 101 |
109 /** @override */ | 102 /** @override */ |
110 deleteItemAtIndex: function(index) { | 103 deleteItemAtIndex: function(index) { |
111 if (loadTimeData.getBoolean('profileIsManaged')) | 104 if (loadTimeData.getBoolean('profileIsSupervised')) |
112 return; | 105 return; |
113 ManageProfileOverlay.showDeleteDialog(this.dataModel.item(index)); | 106 ManageProfileOverlay.showDeleteDialog(this.dataModel.item(index)); |
114 }, | 107 }, |
115 | 108 |
116 /** @override */ | 109 /** @override */ |
117 activateItemAtIndex: function(index) { | 110 activateItemAtIndex: function(index) { |
118 // Don't allow the user to edit a profile that is not current. | 111 // Don't allow the user to edit a profile that is not current. |
119 var profileInfo = this.dataModel.item(index); | 112 var profileInfo = this.dataModel.item(index); |
120 if (profileInfo.isCurrentProfile) | 113 if (profileInfo.isCurrentProfile) |
121 ManageProfileOverlay.showManageDialog(profileInfo); | 114 ManageProfileOverlay.showManageDialog(profileInfo); |
(...skipping 10 matching lines...) Expand all Loading... |
132 * If false, items in this list will not be deletable. | 125 * If false, items in this list will not be deletable. |
133 * @private | 126 * @private |
134 */ | 127 */ |
135 canDeleteItems_: true, | 128 canDeleteItems_: true, |
136 }; | 129 }; |
137 | 130 |
138 return { | 131 return { |
139 ProfileList: ProfileList | 132 ProfileList: ProfileList |
140 }; | 133 }; |
141 }); | 134 }); |
OLD | NEW |