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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 // Add types to global schemaValidator; the types we depend on from | 283 // Add types to global schemaValidator; the types we depend on from |
284 // other namespaces will be added as needed. | 284 // other namespaces will be added as needed. |
285 schemaUtils.schemaValidator.addTypes(t); | 285 schemaUtils.schemaValidator.addTypes(t); |
286 | 286 |
287 // Generate symbols for enums. | 287 // Generate symbols for enums. |
288 var enumValues = t['enum']; | 288 var enumValues = t['enum']; |
289 if (enumValues) { | 289 if (enumValues) { |
290 // Type IDs are qualified with the namespace during compilation, | 290 // Type IDs are qualified with the namespace during compilation, |
291 // unfortunately, so remove it here. | 291 // unfortunately, so remove it here. |
292 logging.DCHECK( | 292 logging.DCHECK($String.substr(t.id, 0, schema.namespace.length) == |
293 t.id.substr(0, schema.namespace.length) == schema.namespace); | 293 schema.namespace); |
294 // Note: + 1 because it ends in a '.', e.g., 'fooApi.Type'. | 294 // Note: + 1 because it ends in a '.', e.g., 'fooApi.Type'. |
295 var id = t.id.substr(schema.namespace.length + 1); | 295 var id = $String.substr(t.id, schema.namespace.length + 1); |
296 mod[id] = {}; | 296 mod[id] = {}; |
297 $Array.forEach(enumValues, function(enumValue) { | 297 $Array.forEach(enumValues, function(enumValue) { |
298 // Note: enums can be declared either as a list of strings | 298 // Note: enums can be declared either as a list of strings |
299 // ['foo', 'bar'] or as a list of objects | 299 // ['foo', 'bar'] or as a list of objects |
300 // [{'name': 'foo'}, {'name': 'bar'}]. | 300 // [{'name': 'foo'}, {'name': 'bar'}]. |
301 enumValue = | 301 enumValue = $Object.hasOwnProperty(enumValue, 'name') ? |
302 enumValue.hasOwnProperty('name') ? enumValue.name : enumValue; | 302 enumValue.name : enumValue; |
303 if (enumValue) // Avoid setting any empty enums. | 303 if (enumValue) // Avoid setting any empty enums. |
304 mod[id][enumValue] = enumValue; | 304 mod[id][enumValue] = enumValue; |
305 }); | 305 }); |
306 } | 306 } |
307 }, this); | 307 }, this); |
308 } | 308 } |
309 | 309 |
310 // TODO(cduvall): Take out when all APIs have been converted to features. | 310 // TODO(cduvall): Take out when all APIs have been converted to features. |
311 // Returns whether access to the content of a schema should be denied, | 311 // Returns whether access to the content of a schema should be denied, |
312 // based on the presence of "unprivileged" and whether this is an | 312 // based on the presence of "unprivileged" and whether this is an |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 availability.message); | 505 availability.message); |
506 return; | 506 return; |
507 } | 507 } |
508 | 508 |
509 this.runHooks_(mod); | 509 this.runHooks_(mod); |
510 return mod; | 510 return mod; |
511 } | 511 } |
512 }; | 512 }; |
513 | 513 |
514 exports.Binding = Binding; | 514 exports.Binding = Binding; |
OLD | NEW |