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

Side by Side Diff: chrome/renderer/resources/extensions/content_settings_custom_bindings.js

Issue 12647017: Lazily require types when validating Extensions API calls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Custom binding for the contentSettings API.
6
7 var binding = require('binding').Binding.create('contentSettings');
8
9 var sendRequest = require('sendRequest').sendRequest;
10 var validate = require('schemaUtils').validate;
11
12 binding.registerCustomType('contentSettings.ContentSetting', function() {
13 function extendSchema(schema) {
14 var extendedSchema = schema.slice();
15 extendedSchema.unshift({'type': 'string'});
16 return extendedSchema;
17 }
18
19 function ContentSetting(contentType, settingSchema) {
20 this.get = function(details, callback) {
21 var getSchema = this.functionSchemas.get.definition.parameters;
22 validate([details, callback], getSchema);
23 return sendRequest('contentSettings.get',
24 [contentType, details, callback],
25 extendSchema(getSchema));
26 };
27 this.set = function(details, callback) {
28 var setSchema = this.functionSchemas.set.definition.parameters.slice();
29 setSchema[0].properties.setting = settingSchema;
30 validate([details, callback], setSchema);
31 return sendRequest('contentSettings.set',
32 [contentType, details, callback],
33 extendSchema(setSchema));
34 };
35 this.clear = function(details, callback) {
36 var clearSchema = this.functionSchemas.clear.definition.parameters;
37 validate([details, callback], clearSchema);
38 return sendRequest('contentSettings.clear',
39 [contentType, details, callback],
40 extendSchema(clearSchema));
41 };
42 this.getResourceIdentifiers = function(callback) {
43 var schema =
44 this.functionSchemas.getResourceIdentifiers.definition.parameters;
45 validate([callback], schema);
46 return sendRequest(
47 'contentSettings.getResourceIdentifiers',
48 [contentType, callback],
49 extendSchema(schema));
50 };
51 }
52
53 return ContentSetting;
54 });
55
56 exports.binding = binding.generate();
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/content_setting.js ('k') | chrome/renderer/resources/extensions/json_schema.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698