OLD | NEW |
(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 sendRequest = require('sendRequest').sendRequest; |
| 8 var validate = require('schemaUtils').validate; |
| 9 |
| 10 function extendSchema(schema) { |
| 11 var extendedSchema = schema.slice(); |
| 12 extendedSchema.unshift({'type': 'string'}); |
| 13 return extendedSchema; |
| 14 } |
| 15 |
| 16 function ContentSetting(contentType, settingSchema) { |
| 17 this.get = function(details, callback) { |
| 18 var getSchema = this.functionSchemas.get.definition.parameters; |
| 19 validate([details, callback], getSchema); |
| 20 return sendRequest('contentSettings.get', |
| 21 [contentType, details, callback], |
| 22 extendSchema(getSchema)); |
| 23 }; |
| 24 this.set = function(details, callback) { |
| 25 var setSchema = this.functionSchemas.set.definition.parameters.slice(); |
| 26 setSchema[0].properties.setting = settingSchema; |
| 27 validate([details, callback], setSchema); |
| 28 return sendRequest('contentSettings.set', |
| 29 [contentType, details, callback], |
| 30 extendSchema(setSchema)); |
| 31 }; |
| 32 this.clear = function(details, callback) { |
| 33 var clearSchema = this.functionSchemas.clear.definition.parameters; |
| 34 validate([details, callback], clearSchema); |
| 35 return sendRequest('contentSettings.clear', |
| 36 [contentType, details, callback], |
| 37 extendSchema(clearSchema)); |
| 38 }; |
| 39 this.getResourceIdentifiers = function(callback) { |
| 40 var schema = |
| 41 this.functionSchemas.getResourceIdentifiers.definition.parameters; |
| 42 validate([callback], schema); |
| 43 return sendRequest( |
| 44 'contentSettings.getResourceIdentifiers', |
| 45 [contentType, callback], |
| 46 extendSchema(schema)); |
| 47 }; |
| 48 } |
| 49 |
| 50 exports.ContentSetting = ContentSetting; |
OLD | NEW |