|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +function convertToBase (manifestInfo, callback) { |
| 4 | + if (!manifestInfo || !manifestInfo.content) { |
| 5 | + return callback(new Error('Manifest content is empty or not initialized.')); |
| 6 | + } |
| 7 | + |
| 8 | + return callback(undefined, manifestInfo); |
| 9 | +} |
| 10 | + |
| 11 | +function convertFromBase (manifestInfo, callback) { |
| 12 | + if (!manifestInfo || !manifestInfo.content) { |
| 13 | + return callback(new Error('Manifest content is empty or not initialized.')); |
| 14 | + } |
| 15 | + |
| 16 | + return callback(undefined, manifestInfo); |
| 17 | +} |
| 18 | + |
| 19 | +var validRootProperties = ['name', 'author', 'version', 'default_locale', 'description', 'manifest_version', 'icons', 'content_security_policy', |
| 20 | + 'browser_action', 'page_action', 'background', 'commands', 'content_scripts', 'externally_connectable', 'homepage_url', |
| 21 | + 'addressbar', 'options_page', 'permissions', 'optional_permissions', 'web_accessible_resources', 'minimum_edge_version', |
| 22 | + 'key', '-ms-preload']; |
| 23 | + |
| 24 | +function matchFormat (manifestObj) { |
| 25 | + var lowercasePropName; |
| 26 | + |
| 27 | + for (var prop in manifestObj) { |
| 28 | + if (manifestObj.hasOwnProperty(prop)) { |
| 29 | + lowercasePropName = prop.toLowerCase(); |
| 30 | + if (validRootProperties.indexOf(lowercasePropName) === -1 && lowercasePropName.indexOf('_') <= 0) { |
| 31 | + return false; |
| 32 | + } |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + return true; |
| 37 | +} |
| 38 | + |
| 39 | +module.exports = { |
| 40 | + convertToBase: convertToBase, |
| 41 | + convertFromBase: convertFromBase, |
| 42 | + matchFormat: matchFormat |
| 43 | +}; |
0 commit comments