| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 // The extension warnings (describing runtime issues). | 298 // The extension warnings (describing runtime issues). |
| 309 if (extension.warnings) { | 299 if (extension.warnings) { |
| 310 var panel = node.querySelector('.extension-warnings'); | 300 var panel = node.querySelector('.extension-warnings'); |
| 311 panel.hidden = false; | 301 panel.hidden = false; |
| 312 var list = panel.querySelector('ul'); | 302 var list = panel.querySelector('ul'); |
| 313 extension.warnings.forEach(function(warning) { | 303 extension.warnings.forEach(function(warning) { |
| 314 list.appendChild(document.createElement('li')).innerText = warning; | 304 list.appendChild(document.createElement('li')).innerText = warning; |
| 315 }); | 305 }); |
| 316 } | 306 } |
| 317 | 307 |
| 318 // The install warnings. | 308 // The manifest errors and warnings, in one of two formats (depending on |
| 319 if (extension.installWarnings) { | 309 // if the ErrorConsole is enabled). |
| 310 if (extension.manifestErrors) { |
| 311 var manifestErrors = node.querySelector('.manifest-errors'); |
| 312 manifestErrors.hidden = false; |
| 313 manifestErrors.appendChild( |
| 314 new extensions.ExtensionErrorList(extension.manifestErrors)); |
| 315 } else if (extension.installWarnings) { |
| 320 var panel = node.querySelector('.install-warnings'); | 316 var panel = node.querySelector('.install-warnings'); |
| 321 panel.hidden = false; | 317 panel.hidden = false; |
| 322 var list = panel.querySelector('ul'); | 318 var list = panel.querySelector('ul'); |
| 323 extension.installWarnings.forEach(function(warning) { | 319 extension.installWarnings.forEach(function(warning) { |
| 324 var li = document.createElement('li'); | 320 var li = document.createElement('li'); |
| 325 li.innerText = warning.message; | 321 li.innerText = warning.message; |
| 326 list.appendChild(li); | 322 list.appendChild(li); |
| 327 }); | 323 }); |
| 328 } | 324 } |
| 329 | 325 |
| 330 this.appendChild(node); | 326 this.appendChild(node); |
| 331 if (location.hash.substr(1) == extension.id) { | 327 if (location.hash.substr(1) == extension.id) { |
| 332 // Scroll beneath the fixed header so that the extension is not | 328 // Scroll beneath the fixed header so that the extension is not |
| 333 // obscured. | 329 // obscured. |
| 334 var topScroll = node.offsetTop - $('page-header').offsetHeight; | 330 var topScroll = node.offsetTop - $('page-header').offsetHeight; |
| 335 var pad = parseInt(getComputedStyle(node, null).marginTop, 10); | 331 var pad = parseInt(getComputedStyle(node, null).marginTop, 10); |
| 336 if (!isNaN(pad)) | 332 if (!isNaN(pad)) |
| 337 topScroll -= pad / 2; | 333 topScroll -= pad / 2; |
| 338 document.body.scrollTop = topScroll; | 334 document.body.scrollTop = topScroll; |
| 339 } | 335 } |
| 340 } | 336 }, |
| 341 }; | 337 }; |
| 342 | 338 |
| 343 return { | 339 return { |
| 344 ExtensionsList: ExtensionsList | 340 ExtensionsList: ExtensionsList |
| 345 }; | 341 }; |
| 346 }); | 342 }); |
| OLD | NEW |