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

Side by Side Diff: extensions/renderer/resources/binding.js

Issue 2953073004: [Extensions Bindings] Move loadTypeSchema from utils to json_schema (Closed)
Patch Set: remove unnecessary require Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | extensions/renderer/resources/json_schema.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Note: Beware sneaky getters/setters when using GetAvailbility(). Use safe/raw 7 // Note: Beware sneaky getters/setters when using GetAvailbility(). Use safe/raw
8 // variables as arguments. 8 // variables as arguments.
9 var GetAvailability = requireNative('v8_context').GetAvailability; 9 var GetAvailability = requireNative('v8_context').GetAvailability;
10 var exceptionHandler = require('uncaught_exception_handler'); 10 var exceptionHandler = require('uncaught_exception_handler');
11 var lastError = require('lastError'); 11 var lastError = require('lastError');
12 var loadTypeSchema = require('json_schema').loadTypeSchema;
12 var logActivity = requireNative('activityLogger'); 13 var logActivity = requireNative('activityLogger');
13 var logging = requireNative('logging'); 14 var logging = requireNative('logging');
14 var process = requireNative('process'); 15 var process = requireNative('process');
15 var schemaRegistry = requireNative('schema_registry'); 16 var schemaRegistry = requireNative('schema_registry');
16 var schemaUtils = require('schemaUtils'); 17 var schemaUtils = require('schemaUtils');
17 var utils = require('utils');
18 var sendRequestHandler = require('sendRequest'); 18 var sendRequestHandler = require('sendRequest');
19 19
20 var contextType = process.GetContextType(); 20 var contextType = process.GetContextType();
21 var extensionId = process.GetExtensionId(); 21 var extensionId = process.GetExtensionId();
22 var manifestVersion = process.GetManifestVersion(); 22 var manifestVersion = process.GetManifestVersion();
23 var sendRequest = sendRequestHandler.sendRequest; 23 var sendRequest = sendRequestHandler.sendRequest;
24 24
25 // Stores the name and definition of each API function, with methods to 25 // Stores the name and definition of each API function, with methods to
26 // modify their behaviour (such as a custom way to handle requests to the 26 // modify their behaviour (such as a custom way to handle requests to the
27 // API, a custom callback, etc). 27 // API, a custom callback, etc).
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 // as "WINDOW_ID_NONE": { "value": -1 }. We handle this here. 503 // as "WINDOW_ID_NONE": { "value": -1 }. We handle this here.
504 // TODO(kalman): enforce that things with a "value" property can't 504 // TODO(kalman): enforce that things with a "value" property can't
505 // define their own types. 505 // define their own types.
506 var type = propertyDef.type || typeof(value); 506 var type = propertyDef.type || typeof(value);
507 if (type === 'integer' || type === 'number') { 507 if (type === 'integer' || type === 'number') {
508 value = parseInt(value); 508 value = parseInt(value);
509 } else if (type === 'boolean') { 509 } else if (type === 'boolean') {
510 value = value === 'true'; 510 value = value === 'true';
511 } else if (propertyDef['$ref']) { 511 } else if (propertyDef['$ref']) {
512 var ref = propertyDef['$ref']; 512 var ref = propertyDef['$ref'];
513 var type = utils.loadTypeSchema(propertyDef['$ref'], schema); 513 var type = loadTypeSchema(propertyDef['$ref'], schema);
514 logging.CHECK(type, 'Schema for $ref type ' + ref + ' not found'); 514 logging.CHECK(type, 'Schema for $ref type ' + ref + ' not found');
515 var constructor = createCustomType(type); 515 var constructor = createCustomType(type);
516 var args = value; 516 var args = value;
517 logging.DCHECK($Array.isArray(args)); 517 logging.DCHECK($Array.isArray(args));
518 $Array.push(args, type); 518 $Array.push(args, type);
519 // For an object propertyDef, |value| is an array of constructor 519 // For an object propertyDef, |value| is an array of constructor
520 // arguments, but we want to pass the arguments directly (i.e. 520 // arguments, but we want to pass the arguments directly (i.e.
521 // not as an array), so we have to fake calling |new| on the 521 // not as an array), so we have to fake calling |new| on the
522 // constructor. 522 // constructor.
523 value = { __proto__: constructor.prototype }; 523 value = { __proto__: constructor.prototype };
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 availability.message); 570 availability.message);
571 return; 571 return;
572 } 572 }
573 573
574 this.runHooks_(mod, schema); 574 this.runHooks_(mod, schema);
575 return mod; 575 return mod;
576 } 576 }
577 }; 577 };
578 578
579 exports.$set('Binding', Binding); 579 exports.$set('Binding', Binding);
OLDNEW
« no previous file with comments | « no previous file | extensions/renderer/resources/json_schema.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698