Index: extensions/renderer/resources/binding.js |
diff --git a/extensions/renderer/resources/binding.js b/extensions/renderer/resources/binding.js |
index b1a3efcaca5002bb03d2918acec145572dd74e81..22ccb7bdc212aa69000fa5d63b5a9d1462b66b56 100644 |
--- a/extensions/renderer/resources/binding.js |
+++ b/extensions/renderer/resources/binding.js |
@@ -275,13 +275,35 @@ Binding.prototype = { |
mod = mod[name]; |
} |
- // Add types to global schemaValidator, the types we depend on from other |
- // namespaces will be added as needed. |
if (schema.types) { |
$Array.forEach(schema.types, function(t) { |
if (!isSchemaNodeSupported(t, platform, manifestVersion)) |
return; |
+ |
+ // Add types to global schemaValidator; the types we depend on from |
+ // other namespaces will be added as needed. |
schemaUtils.schemaValidator.addTypes(t); |
+ |
+ // Generate symbols for enums. |
+ var enumValues = t['enum']; |
+ if (enumValues) { |
+ // Type IDs are qualified with the namespace during compilation, |
+ // unfortunately, so remove it here. |
+ logging.DCHECK( |
+ t.id.substr(0, schema.namespace.length) == schema.namespace); |
+ // Note: + 1 because it ends in a '.', e.g., 'fooApi.Type'. |
+ var id = t.id.substr(schema.namespace.length + 1); |
+ mod[id] = {}; |
+ $Array.forEach(enumValues, function(enumValue) { |
+ // Note: enums can be declared either as a list of strings |
+ // ['foo', 'bar'] or as a list of objects |
+ // [{'name': 'foo'}, {'name': 'bar'}]. |
+ enumValue = |
+ enumValue.hasOwnProperty('name') ? enumValue.name : enumValue; |
+ if (enumValue) // Avoid setting any empty enums. |
+ mod[id][enumValue] = enumValue; |
+ }); |
+ } |
}, this); |
} |