OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var Event = require('event_bindings').Event; | 5 var Event = require('event_bindings').Event; |
6 var forEach = require('utils').forEach; | 6 var forEach = require('utils').forEach; |
7 var GetAvailability = requireNative('v8_context').GetAvailability; | 7 var GetAvailability = requireNative('v8_context').GetAvailability; |
8 var exceptionHandler = require('uncaught_exception_handler'); | 8 var exceptionHandler = require('uncaught_exception_handler'); |
9 var lastError = require('lastError'); | 9 var lastError = require('lastError'); |
10 var logActivity = requireNative('activityLogger'); | 10 var logActivity = requireNative('activityLogger'); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 } | 268 } |
269 | 269 |
270 var mod = {}; | 270 var mod = {}; |
271 | 271 |
272 var namespaces = $String.split(schema.namespace, '.'); | 272 var namespaces = $String.split(schema.namespace, '.'); |
273 for (var index = 0, name; name = namespaces[index]; index++) { | 273 for (var index = 0, name; name = namespaces[index]; index++) { |
274 mod[name] = mod[name] || {}; | 274 mod[name] = mod[name] || {}; |
275 mod = mod[name]; | 275 mod = mod[name]; |
276 } | 276 } |
277 | 277 |
278 // Add types to global schemaValidator, the types we depend on from other | |
279 // namespaces will be added as needed. | |
280 if (schema.types) { | 278 if (schema.types) { |
281 $Array.forEach(schema.types, function(t) { | 279 $Array.forEach(schema.types, function(t) { |
282 if (!isSchemaNodeSupported(t, platform, manifestVersion)) | 280 if (!isSchemaNodeSupported(t, platform, manifestVersion)) |
283 return; | 281 return; |
282 | |
283 // Add types to global schemaValidator; the types we depend on from | |
284 // other namespaces will be added as needed. | |
284 schemaUtils.schemaValidator.addTypes(t); | 285 schemaUtils.schemaValidator.addTypes(t); |
286 | |
287 // Generate symbols for enums. | |
288 var enumValues = t['enum']; | |
289 if (enumValues) { | |
290 // Type IDs are qualified with the namespace during compilation, | |
291 // unfortunately, so remove it here. | |
292 logging.DCHECK( | |
293 t.id.substr(0, schema.namespace.length) == schema.namespace); | |
294 // Note: + 1 because it ends in a '.', e.g., 'fooApi.Type'. | |
295 var id = t.id.substr(schema.namespace.length + 1); | |
296 mod[id] = {}; | |
297 $Array.forEach(enumValues, function(enumValue) { | |
298 enumValue = enumValue.name ? enumValue.name : enumValue; | |
not at google - send to devlin
2015/03/02 22:20:16
// Note: enums can be declared either as a list of
Devlin
2015/03/02 23:32:35
Done.
| |
299 mod[id][enumValue] = enumValue; | |
300 }); | |
301 } | |
285 }, this); | 302 }, this); |
286 } | 303 } |
287 | 304 |
288 // TODO(cduvall): Take out when all APIs have been converted to features. | 305 // TODO(cduvall): Take out when all APIs have been converted to features. |
289 // Returns whether access to the content of a schema should be denied, | 306 // Returns whether access to the content of a schema should be denied, |
290 // based on the presence of "unprivileged" and whether this is an | 307 // based on the presence of "unprivileged" and whether this is an |
291 // extension process (versus e.g. a content script). | 308 // extension process (versus e.g. a content script). |
292 function isSchemaAccessAllowed(itemSchema) { | 309 function isSchemaAccessAllowed(itemSchema) { |
293 return (contextType == 'BLESSED_EXTENSION') || | 310 return (contextType == 'BLESSED_EXTENSION') || |
294 schema.unprivileged || | 311 schema.unprivileged || |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 availability.message); | 500 availability.message); |
484 return; | 501 return; |
485 } | 502 } |
486 | 503 |
487 this.runHooks_(mod); | 504 this.runHooks_(mod); |
488 return mod; | 505 return mod; |
489 } | 506 } |
490 }; | 507 }; |
491 | 508 |
492 exports.Binding = Binding; | 509 exports.Binding = Binding; |
OLD | NEW |