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 <include src="extension_error.js"></include> |
| 6 |
5 cr.define('options', function() { | 7 cr.define('options', function() { |
6 'use strict'; | 8 'use strict'; |
7 | 9 |
8 /** | 10 /** |
9 * A lookup helper function to find the first node that has an id (starting | |
10 * at |node| and going up the parent chain). | |
11 * @param {Element} node The node to start looking at. | |
12 */ | |
13 function findIdNode(node) { | |
14 while (node && !node.id) { | |
15 node = node.parentNode; | |
16 } | |
17 return node; | |
18 } | |
19 | |
20 /** | |
21 * Creates a new list of extensions. | 11 * Creates a new list of extensions. |
22 * @param {Object=} opt_propertyBag Optional properties. | 12 * @param {Object=} opt_propertyBag Optional properties. |
23 * @constructor | 13 * @constructor |
24 * @extends {cr.ui.div} | 14 * @extends {cr.ui.div} |
25 */ | 15 */ |
26 var ExtensionsList = cr.ui.define('div'); | 16 var ExtensionsList = cr.ui.define('div'); |
27 | 17 |
28 /** | 18 /** |
29 * @type {Object.<string, boolean>} A map from extension id to a boolean | 19 * @type {Object.<string, boolean>} A map from extension id to a boolean |
30 * indicating whether the incognito warning is showing. This persists | 20 * indicating whether the incognito warning is showing. This persists |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 // The extension warnings (describing runtime issues). | 305 // The extension warnings (describing runtime issues). |
316 if (extension.warnings) { | 306 if (extension.warnings) { |
317 var panel = node.querySelector('.extension-warnings'); | 307 var panel = node.querySelector('.extension-warnings'); |
318 panel.hidden = false; | 308 panel.hidden = false; |
319 var list = panel.querySelector('ul'); | 309 var list = panel.querySelector('ul'); |
320 extension.warnings.forEach(function(warning) { | 310 extension.warnings.forEach(function(warning) { |
321 list.appendChild(document.createElement('li')).innerText = warning; | 311 list.appendChild(document.createElement('li')).innerText = warning; |
322 }); | 312 }); |
323 } | 313 } |
324 | 314 |
325 // The install warnings. | 315 // The manifest errors and warnings. |
326 if (extension.installWarnings) { | 316 if (extension.manifestErrors) { |
327 var panel = node.querySelector('.install-warnings'); | 317 node.querySelector('.manifest-errors').hidden = false; |
328 panel.hidden = false; | 318 node.querySelector('.manifest-errors').appendChild( |
329 var list = panel.querySelector('ul'); | 319 new extensions.ExtensionErrorList(extension.manifestErrors)); |
330 extension.installWarnings.forEach(function(warning) { | |
331 var li = document.createElement('li'); | |
332 li.innerText = warning.message; | |
333 list.appendChild(li); | |
334 }); | |
335 } | 320 } |
336 | 321 |
337 this.appendChild(node); | 322 this.appendChild(node); |
338 if (location.hash.substr(1) == extension.id) { | 323 if (location.hash.substr(1) == extension.id) { |
339 // Scroll beneath the fixed header so that the extension is not | 324 // Scroll beneath the fixed header so that the extension is not |
340 // obscured. | 325 // obscured. |
341 var topScroll = node.offsetTop - $('page-header').offsetHeight; | 326 var topScroll = node.offsetTop - $('page-header').offsetHeight; |
342 var pad = parseInt(getComputedStyle(node, null).marginTop, 10); | 327 var pad = parseInt(getComputedStyle(node, null).marginTop, 10); |
343 if (!isNaN(pad)) | 328 if (!isNaN(pad)) |
344 topScroll -= pad / 2; | 329 topScroll -= pad / 2; |
345 document.body.scrollTop = topScroll; | 330 document.body.scrollTop = topScroll; |
346 } | 331 } |
347 } | 332 }, |
348 }; | 333 }; |
349 | 334 |
350 return { | 335 return { |
351 ExtensionsList: ExtensionsList | 336 ExtensionsList: ExtensionsList |
352 }; | 337 }; |
353 }); | 338 }); |
OLD | NEW |