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

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

Issue 17451011: Make the externally connectable browser test clobber all of the builtins, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 // Custom binding for the contentSettings API. 5 // Custom binding for the contentSettings API.
6 6
7 var sendRequest = require('sendRequest').sendRequest; 7 var sendRequest = require('sendRequest').sendRequest;
8 var validate = require('schemaUtils').validate; 8 var validate = require('schemaUtils').validate;
9 9
10 function extendSchema(schema) { 10 function extendSchema(schema) {
11 var extendedSchema = schema.slice(); 11 var extendedSchema = $Array.slice(schema);
12 extendedSchema.unshift({'type': 'string'}); 12 extendedSchema.unshift({'type': 'string'});
13 return extendedSchema; 13 return extendedSchema;
14 } 14 }
15 15
16 function ContentSetting(contentType, settingSchema) { 16 function ContentSetting(contentType, settingSchema) {
17 this.get = function(details, callback) { 17 this.get = function(details, callback) {
18 var getSchema = this.functionSchemas.get.definition.parameters; 18 var getSchema = this.functionSchemas.get.definition.parameters;
19 validate([details, callback], getSchema); 19 validate([details, callback], getSchema);
20 return sendRequest('contentSettings.get', 20 return sendRequest('contentSettings.get',
21 [contentType, details, callback], 21 [contentType, details, callback],
22 extendSchema(getSchema)); 22 extendSchema(getSchema));
23 }; 23 };
24 this.set = function(details, callback) { 24 this.set = function(details, callback) {
25 var setSchema = this.functionSchemas.set.definition.parameters.slice(); 25 var setSchema = $Array.slice(
26 this.functionSchemas.set.definition.parameters);
26 setSchema[0].properties.setting = settingSchema; 27 setSchema[0].properties.setting = settingSchema;
27 validate([details, callback], setSchema); 28 validate([details, callback], setSchema);
28 return sendRequest('contentSettings.set', 29 return sendRequest('contentSettings.set',
29 [contentType, details, callback], 30 [contentType, details, callback],
30 extendSchema(setSchema)); 31 extendSchema(setSchema));
31 }; 32 };
32 this.clear = function(details, callback) { 33 this.clear = function(details, callback) {
33 var clearSchema = this.functionSchemas.clear.definition.parameters; 34 var clearSchema = this.functionSchemas.clear.definition.parameters;
34 validate([details, callback], clearSchema); 35 validate([details, callback], clearSchema);
35 return sendRequest('contentSettings.clear', 36 return sendRequest('contentSettings.clear',
36 [contentType, details, callback], 37 [contentType, details, callback],
37 extendSchema(clearSchema)); 38 extendSchema(clearSchema));
38 }; 39 };
39 this.getResourceIdentifiers = function(callback) { 40 this.getResourceIdentifiers = function(callback) {
40 var schema = 41 var schema =
41 this.functionSchemas.getResourceIdentifiers.definition.parameters; 42 this.functionSchemas.getResourceIdentifiers.definition.parameters;
42 validate([callback], schema); 43 validate([callback], schema);
43 return sendRequest( 44 return sendRequest(
44 'contentSettings.getResourceIdentifiers', 45 'contentSettings.getResourceIdentifiers',
45 [contentType, callback], 46 [contentType, callback],
46 extendSchema(schema)); 47 extendSchema(schema));
47 }; 48 };
48 } 49 }
49 50
50 exports.ContentSetting = ContentSetting; 51 exports.ContentSetting = ContentSetting;
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/chrome_setting.js ('k') | chrome/renderer/resources/extensions/content_watcher.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698