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

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

Issue 2953073004: [Extensions Bindings] Move loadTypeSchema from utils to json_schema (Closed)
Patch Set: . 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 utils = require('utils');
lazyboy 2017/06/27 17:51:38 This seems to be unused now?
Devlin 2017/06/28 18:01:08 Good catch; removed.
18 var sendRequestHandler = require('sendRequest'); 19 var sendRequestHandler = require('sendRequest');
19 20
20 var contextType = process.GetContextType(); 21 var contextType = process.GetContextType();
21 var extensionId = process.GetExtensionId(); 22 var extensionId = process.GetExtensionId();
22 var manifestVersion = process.GetManifestVersion(); 23 var manifestVersion = process.GetManifestVersion();
23 var sendRequest = sendRequestHandler.sendRequest; 24 var sendRequest = sendRequestHandler.sendRequest;
24 25
25 // Stores the name and definition of each API function, with methods to 26 // 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 27 // modify their behaviour (such as a custom way to handle requests to the
27 // API, a custom callback, etc). 28 // 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. 504 // as "WINDOW_ID_NONE": { "value": -1 }. We handle this here.
504 // TODO(kalman): enforce that things with a "value" property can't 505 // TODO(kalman): enforce that things with a "value" property can't
505 // define their own types. 506 // define their own types.
506 var type = propertyDef.type || typeof(value); 507 var type = propertyDef.type || typeof(value);
507 if (type === 'integer' || type === 'number') { 508 if (type === 'integer' || type === 'number') {
508 value = parseInt(value); 509 value = parseInt(value);
509 } else if (type === 'boolean') { 510 } else if (type === 'boolean') {
510 value = value === 'true'; 511 value = value === 'true';
511 } else if (propertyDef['$ref']) { 512 } else if (propertyDef['$ref']) {
512 var ref = propertyDef['$ref']; 513 var ref = propertyDef['$ref'];
513 var type = utils.loadTypeSchema(propertyDef['$ref'], schema); 514 var type = loadTypeSchema(propertyDef['$ref'], schema);
514 logging.CHECK(type, 'Schema for $ref type ' + ref + ' not found'); 515 logging.CHECK(type, 'Schema for $ref type ' + ref + ' not found');
515 var constructor = createCustomType(type); 516 var constructor = createCustomType(type);
516 var args = value; 517 var args = value;
517 logging.DCHECK($Array.isArray(args)); 518 logging.DCHECK($Array.isArray(args));
518 $Array.push(args, type); 519 $Array.push(args, type);
519 // For an object propertyDef, |value| is an array of constructor 520 // For an object propertyDef, |value| is an array of constructor
520 // arguments, but we want to pass the arguments directly (i.e. 521 // 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 522 // not as an array), so we have to fake calling |new| on the
522 // constructor. 523 // constructor.
523 value = { __proto__: constructor.prototype }; 524 value = { __proto__: constructor.prototype };
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 availability.message); 571 availability.message);
571 return; 572 return;
572 } 573 }
573 574
574 this.runHooks_(mod, schema); 575 this.runHooks_(mod, schema);
575 return mod; 576 return mod;
576 } 577 }
577 }; 578 };
578 579
579 exports.$set('Binding', Binding); 580 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