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

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

Issue 12647017: Lazily require types when validating Extensions API calls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 7 years, 9 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
Index: chrome/renderer/resources/extensions/utils.js
diff --git a/chrome/renderer/resources/extensions/utils.js b/chrome/renderer/resources/extensions/utils.js
index 50134eadb569f2b40a5ebb3c6f033eae1b1efa28..efd99730f8222443f0da4eab63e04dce9047682b 100644
--- a/chrome/renderer/resources/extensions/utils.js
+++ b/chrome/renderer/resources/extensions/utils.js
@@ -3,6 +3,8 @@
// found in the LICENSE file.
var chrome = requireNative('chrome').GetChrome();
+var schemaRegistry = requireNative('schema_registry');
+var CHECK = requireNative('logging').CHECK;
function forEach(obj, f, self) {
// For arrays, make sure the indices are numbers not strings - and in that
@@ -37,16 +39,23 @@ function lookup(array_of_dictionaries, field, value) {
}
}
-// Specify |currentApi| if this should return an API for $refs in the current
-// namespace.
-function loadRefDependency(ref, currentApi) {
- var parts = ref.split(".");
- if (parts.length > 1)
- return chrome[parts.slice(0, parts.length - 1).join(".")];
- else
- return currentApi;
+function loadTypeSchema(typeName, defaultSchema) {
+ var parts = typeName.split('.');
+ if (parts.length == 1) {
+ CHECK(defaultSchema, 'Trying to reference "' + typeName +
+ '" with neither namespace nor default schema.');
+ var types = defaultSchema.types;
+ } else {
+ var schemaName = parts.slice(0, parts.length - 1).join('.')
+ var types = schemaRegistry.GetSchema(schemaName).types;
+ }
+ for (var i = 0; i < types.length; ++i) {
+ if (types[i].id == typeName)
+ return types[i];
+ }
+ return null;
}
exports.forEach = forEach;
-exports.loadRefDependency = loadRefDependency;
+exports.loadTypeSchema = loadTypeSchema;
exports.lookup = lookup;
« no previous file with comments | « chrome/renderer/resources/extensions/types_custom_bindings.js ('k') | chrome/renderer/resources/renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698