Chromium Code Reviews| 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..0303dd53e08a6a25cee30c9e90927cf12b40e3c6 100644 |
| --- a/chrome/renderer/resources/extensions/utils.js |
| +++ b/chrome/renderer/resources/extensions/utils.js |
| @@ -3,6 +3,7 @@ |
| // found in the LICENSE file. |
| var chrome = requireNative('chrome').GetChrome(); |
| +var schemaRegistry = requireNative('schema_registry'); |
| function forEach(obj, f, self) { |
| // For arrays, make sure the indices are numbers not strings - and in that |
| @@ -37,16 +38,22 @@ 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 loadRefType(ref, defaultSchema) { |
|
not at google - send to devlin
2013/03/21 00:01:13
loadTypeSchema?
ref -> typeName?
(the fact that
cduvall
2013/03/21 00:59:51
Done.
|
| + var parts = ref.split('.'); |
| + if (parts.length == 1) { |
| + if (!defaultSchema) |
| + return undefined; |
|
not at google - send to devlin
2013/03/21 00:01:13
CHECK
cduvall
2013/03/21 00:59:51
Done.
|
| + 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'] == ref) |
|
not at google - send to devlin
2013/03/21 00:01:13
.id
cduvall
2013/03/21 00:59:51
Done.
|
| + return types[i]; |
| + } |
|
not at google - send to devlin
2013/03/21 00:01:13
return null (nice to be explicit)
cduvall
2013/03/21 00:59:51
returned undefined to be consistent. Is null bette
not at google - send to devlin
2013/03/21 01:36:55
that is always a question with JS.
my rule at lea
cduvall
2013/03/21 17:16:07
Done.
|
| } |
| exports.forEach = forEach; |
| -exports.loadRefDependency = loadRefDependency; |
| +exports.loadRefType = loadRefType; |
| exports.lookup = lookup; |