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

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

Issue 1906593002: [Extensions] Finish freezing schema (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « extensions/renderer/resources/binding.js ('k') | 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 exceptionHandler = require('uncaught_exception_handler'); 5 var exceptionHandler = require('uncaught_exception_handler');
6 var eventNatives = requireNative('event_natives'); 6 var eventNatives = requireNative('event_natives');
7 var logging = requireNative('logging'); 7 var logging = requireNative('logging');
8 var schemaRegistry = requireNative('schema_registry'); 8 var schemaRegistry = requireNative('schema_registry');
9 var sendRequest = require('sendRequest').sendRequest; 9 var sendRequest = require('sendRequest').sendRequest;
10 var utils = require('utils'); 10 var utils = require('utils');
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 function parseEventOptions(opt_eventOptions) { 133 function parseEventOptions(opt_eventOptions) {
134 function merge(dest, src) { 134 function merge(dest, src) {
135 for (var k in src) { 135 for (var k in src) {
136 if (!$Object.hasOwnProperty(dest, k)) { 136 if (!$Object.hasOwnProperty(dest, k)) {
137 dest[k] = src[k]; 137 dest[k] = src[k];
138 } 138 }
139 } 139 }
140 } 140 }
141 141
142 var options = opt_eventOptions || {}; 142 var options = $Object.assign({}, opt_eventOptions || {});
143 merge(options, { 143 merge(options, {
144 // Event supports adding listeners with filters ("filtered events"), for 144 // Event supports adding listeners with filters ("filtered events"), for
145 // example as used in the webNavigation API. 145 // example as used in the webNavigation API.
146 // 146 //
147 // event.addListener(listener, [filter1, filter2]); 147 // event.addListener(listener, [filter1, filter2]);
148 supportsFilters: false, 148 supportsFilters: false,
149 149
150 // Events supports vanilla events. Most APIs use these. 150 // Events supports vanilla events. Most APIs use these.
151 // 151 //
152 // event.addListener(listener); 152 // event.addListener(listener);
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 if (!this.eventOptions.supportsRules) 408 if (!this.eventOptions.supportsRules)
409 throw new Error("This event does not support rules."); 409 throw new Error("This event does not support rules.");
410 410
411 // Takes a list of JSON datatype identifiers and returns a schema fragment 411 // Takes a list of JSON datatype identifiers and returns a schema fragment
412 // that verifies that a JSON object corresponds to an array of only these 412 // that verifies that a JSON object corresponds to an array of only these
413 // data types. 413 // data types.
414 function buildArrayOfChoicesSchema(typesList) { 414 function buildArrayOfChoicesSchema(typesList) {
415 return { 415 return {
416 'type': 'array', 416 'type': 'array',
417 'items': { 417 'items': {
418 'choices': typesList.map(function(el) {return {'$ref': el};}) 418 'choices': $Array.map(typesList, function(el) {return {'$ref': el};})
419 } 419 }
420 }; 420 };
421 }; 421 };
422 422
423 // Validate conditions and actions against specific schemas of this 423 // Validate conditions and actions against specific schemas of this
424 // event object type. 424 // event object type.
425 // |rules| is an array of JSON objects that follow the Rule type of the 425 // |rules| is an array of JSON objects that follow the Rule type of the
426 // declarative extension APIs. |conditions| is an array of JSON type 426 // declarative extension APIs. |conditions| is an array of JSON type
427 // identifiers that are allowed to occur in the conditions attribute of each 427 // identifiers that are allowed to occur in the conditions attribute of each
428 // rule. Likewise, |actions| is an array of JSON type identifiers that are 428 // rule. Likewise, |actions| is an array of JSON type identifiers that are
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 'removeRules', 501 'removeRules',
502 'getRules' 502 'getRules'
503 ] }); 503 ] });
504 504
505 // NOTE: Event is (lazily) exposed as chrome.Event from dispatcher.cc. 505 // NOTE: Event is (lazily) exposed as chrome.Event from dispatcher.cc.
506 exports.$set('Event', Event); 506 exports.$set('Event', Event);
507 507
508 exports.$set('dispatchEvent', dispatchEvent); 508 exports.$set('dispatchEvent', dispatchEvent);
509 exports.$set('parseEventOptions', parseEventOptions); 509 exports.$set('parseEventOptions', parseEventOptions);
510 exports.$set('registerArgumentMassager', registerArgumentMassager); 510 exports.$set('registerArgumentMassager', registerArgumentMassager);
OLDNEW
« no previous file with comments | « extensions/renderer/resources/binding.js ('k') | extensions/renderer/resources/json_schema.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698