Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10876)

Unified Diff: chrome/renderer/resources/extensions/binding.js

Issue 305643011: Expose enums to extension bindings. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | extensions/common/api/runtime.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/extensions/binding.js
diff --git a/chrome/renderer/resources/extensions/binding.js b/chrome/renderer/resources/extensions/binding.js
index 4bb9b99bfbdece26a428b09c1b9b5ed391275adb..7e6996f7f2d138c671ae176c74929f6f7ac258f2 100644
--- a/chrome/renderer/resources/extensions/binding.js
+++ b/chrome/renderer/resources/extensions/binding.js
@@ -243,13 +243,29 @@ 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.
+ var namespaceAndId = $String.split(t.id, '.');
+ logging.DCHECK(namespaceAndId.length == 2, t.id);
+ logging.DCHECK(namespaceAndId[0] == schema.namespace, t.id);
+ var id = namespaceAndId[1];
+ mod[id] = {};
+ $Array.forEach(enumValues, function(enumValue) {
+ mod[id][enumValue] = enumValue;
+ });
+ }
}, this);
}
« no previous file with comments | « no previous file | extensions/common/api/runtime.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698