OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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', function() { | 5 cr.define('options', function() { |
6 /** | 6 /** |
7 * Creates a new list of extensions. | 7 * Creates a new list of extensions. |
8 * @param {Object=} opt_propertyBag Optional properties. | 8 * @param {Object=} opt_propertyBag Optional properties. |
9 * @constructor | 9 * @constructor |
10 * @extends {cr.ui.div} | 10 * @extends {cr.ui.div} |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 title.classList.add('extension-title'); | 177 title.classList.add('extension-title'); |
178 title.textContent = extension.name; | 178 title.textContent = extension.name; |
179 vbox.appendChild(title); | 179 vbox.appendChild(title); |
180 | 180 |
181 // Followed by version. | 181 // Followed by version. |
182 var version = this.ownerDocument.createElement('span'); | 182 var version = this.ownerDocument.createElement('span'); |
183 version.classList.add('extension-version'); | 183 version.classList.add('extension-version'); |
184 version.textContent = extension.version; | 184 version.textContent = extension.version; |
185 vbox.appendChild(version); | 185 vbox.appendChild(version); |
186 | 186 |
| 187 // And the additional info label (unpacked/crashed). |
| 188 if (extension.terminated || extension.isUnpacked) { |
| 189 var version = this.ownerDocument.createElement('span'); |
| 190 version.classList.add('extension-version'); |
| 191 version.textContent = extension.terminated ? |
| 192 localStrings.getString('extensionSettingsCrashMessage') : |
| 193 localStrings.getString('extensionSettingsInDevelopment'); |
| 194 vbox.appendChild(version); |
| 195 } |
| 196 |
187 div = this.ownerDocument.createElement('div'); | 197 div = this.ownerDocument.createElement('div'); |
188 vbox.appendChild(div); | 198 vbox.appendChild(div); |
189 | 199 |
190 // And below that we have description (if provided). | 200 // And below that we have description (if provided). |
191 if (extension.description.length > 0) { | 201 if (extension.description.length > 0) { |
192 var description = this.ownerDocument.createElement('span'); | 202 var description = this.ownerDocument.createElement('span'); |
193 description.classList.add('extension-description'); | 203 description.classList.add('extension-description'); |
194 description.textContent = extension.description; | 204 description.textContent = extension.description; |
195 vbox.appendChild(description); | 205 vbox.appendChild(description); |
196 } | 206 } |
(...skipping 27 matching lines...) Expand all Loading... |
224 this.decorateDetailsSection_(details, extension, expanded, butterbar); | 234 this.decorateDetailsSection_(details, extension, expanded, butterbar); |
225 | 235 |
226 // And on the right of the details we have the Enable/Enabled checkbox. | 236 // And on the right of the details we have the Enable/Enabled checkbox. |
227 div = this.ownerDocument.createElement('div'); | 237 div = this.ownerDocument.createElement('div'); |
228 hbox.appendChild(div); | 238 hbox.appendChild(div); |
229 | 239 |
230 var section = this.ownerDocument.createElement('section'); | 240 var section = this.ownerDocument.createElement('section'); |
231 section.classList.add('extension-enabling'); | 241 section.classList.add('extension-enabling'); |
232 div.appendChild(section); | 242 div.appendChild(section); |
233 | 243 |
234 // The Enable checkbox. | 244 if (!extension.terminated) { |
235 var input = this.ownerDocument.createElement('input'); | 245 // The Enable checkbox. |
236 input.addEventListener('click', this.handleEnable_.bind(this)); | 246 var input = this.ownerDocument.createElement('input'); |
237 input.type = 'checkbox'; | 247 input.addEventListener('click', this.handleEnable_.bind(this)); |
238 input.name = 'toggle-' + id; | 248 input.type = 'checkbox'; |
239 if (!extension.mayDisable) | 249 input.name = 'toggle-' + id; |
240 input.disabled = true; | 250 if (!extension.mayDisable) |
241 if (extension.enabled) | 251 input.disabled = true; |
242 input.checked = true; | 252 if (extension.enabled) |
243 input.id = 'toggle-' + id; | 253 input.checked = true; |
244 section.appendChild(input); | 254 input.id = 'toggle-' + id; |
245 var label = this.ownerDocument.createElement('label'); | 255 section.appendChild(input); |
246 label.classList.add('extension-enabling-label'); | 256 var label = this.ownerDocument.createElement('label'); |
247 if (extension.enabled) | 257 label.classList.add('extension-enabling-label'); |
248 label.classList.add('extension-enabling-label-bold'); | 258 if (extension.enabled) |
249 label.setAttribute('for', 'toggle-' + id); | 259 label.classList.add('extension-enabling-label-bold'); |
250 label.id = 'toggle-' + id + '-label'; | 260 label.setAttribute('for', 'toggle-' + id); |
251 if (extension.enabled) { | 261 label.id = 'toggle-' + id + '-label'; |
252 // Enabled (with a d). | 262 if (extension.enabled) { |
253 label.textContent = | 263 // Enabled (with a d). |
254 localStrings.getString('extensionSettingsEnabled'); | 264 label.textContent = |
| 265 localStrings.getString('extensionSettingsEnabled'); |
| 266 } else { |
| 267 // Enable (no d). |
| 268 label.textContent = |
| 269 localStrings.getString('extensionSettingsEnable'); |
| 270 } |
| 271 section.appendChild(label); |
| 272 |
| 273 if (label.offsetWidth > maxCheckboxWidth) |
| 274 maxCheckboxWidth = label.offsetWidth; |
| 275 if (label.offsetWidth < minCheckboxWidth) |
| 276 minCheckboxWidth = label.offsetWidth; |
255 } else { | 277 } else { |
256 // Enable (no d). | 278 // Extension has been terminated, show a Reload link. |
257 label.textContent = localStrings.getString('extensionSettingsEnable'); | 279 var link = this.ownerDocument.createElement('a'); |
| 280 link.classList.add('extension-links-trailing'); |
| 281 link.id = extension.id; |
| 282 link.textContent = |
| 283 localStrings.getString('extensionSettingsReload'); |
| 284 link.href = '#'; |
| 285 link.addEventListener('click', this.handleReload_.bind(this)); |
| 286 section.appendChild(link); |
258 } | 287 } |
259 section.appendChild(label); | |
260 | |
261 if (label.offsetWidth > maxCheckboxWidth) | |
262 maxCheckboxWidth = label.offsetWidth; | |
263 if (label.offsetWidth < minCheckboxWidth) | |
264 minCheckboxWidth = label.offsetWidth; | |
265 | 288 |
266 // And, on the far right we have the uninstall button. | 289 // And, on the far right we have the uninstall button. |
267 var button = this.ownerDocument.createElement('button'); | 290 var button = this.ownerDocument.createElement('button'); |
268 button.classList.add('extension-delete'); | 291 button.classList.add('extension-delete'); |
269 button.id = id; | 292 button.id = id; |
270 if (!extension.mayDisable) | 293 if (!extension.mayDisable) |
271 button.disabled = true; | 294 button.disabled = true; |
272 button.textContent = localStrings.getString('extensionSettingsRemove'); | 295 button.textContent = localStrings.getString('extensionSettingsRemove'); |
273 button.addEventListener('click', this.handleUninstall_.bind(this)); | 296 button.addEventListener('click', this.handleUninstall_.bind(this)); |
274 hbox.appendChild(button); | 297 hbox.appendChild(button); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 ]); | 688 ]); |
666 } | 689 } |
667 } | 690 } |
668 }, | 691 }, |
669 }; | 692 }; |
670 | 693 |
671 return { | 694 return { |
672 ExtensionsList: ExtensionsList | 695 ExtensionsList: ExtensionsList |
673 }; | 696 }; |
674 }); | 697 }); |
OLD | NEW |