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

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

Issue 10535030: Allow updateArgumentsPostValidate to support callbacks and added / removed arguments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Proper syntax Created 8 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 bindings for the declarativeWebRequest API. 5 // Custom bindings for the declarativeWebRequest API.
6 6
7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
8 var utils = require('utils'); 8 var utils = require('utils');
9 var validate = require('schemaUtils').validate;
9 10
10 chromeHidden.registerCustomHook('declarativeWebRequest', function(api) { 11 chromeHidden.registerCustomHook('declarativeWebRequest', function(api) {
11 // Returns the schema definition of type |typeId| defined in |namespace|. 12 // Returns the schema definition of type |typeId| defined in |namespace|.
12 function getSchema(namespace, typeId) { 13 function getSchema(namespace, typeId) {
13 var apiSchema = utils.lookup(api.apiDefinitions, 'namespace', namespace); 14 var apiSchema = utils.lookup(api.apiDefinitions, 'namespace', namespace);
14 var resultSchema = utils.lookup( 15 var resultSchema = utils.lookup(
15 apiSchema.types, 'id', namespace + '.' + typeId); 16 apiSchema.types, 'id', namespace + '.' + typeId);
16 return resultSchema; 17 return resultSchema;
17 } 18 }
18 19
19 // Helper function for the constructor of concrete datatypes of the 20 // Helper function for the constructor of concrete datatypes of the
20 // declarative webRequest API. 21 // declarative webRequest API.
21 // Makes sure that |this| contains the union of parameters and 22 // Makes sure that |this| contains the union of parameters and
22 // {'instanceType': 'declarativeWebRequest.' + typeId} and validates the 23 // {'instanceType': 'declarativeWebRequest.' + typeId} and validates the
23 // generated union dictionary against the schema for |typeId|. 24 // generated union dictionary against the schema for |typeId|.
24 function setupInstance(instance, parameters, typeId) { 25 function setupInstance(instance, parameters, typeId) {
25 for (var key in parameters) { 26 for (var key in parameters) {
26 if (parameters.hasOwnProperty(key)) { 27 if (parameters.hasOwnProperty(key)) {
27 instance[key] = parameters[key]; 28 instance[key] = parameters[key];
28 } 29 }
29 } 30 }
30 instance.instanceType = 'declarativeWebRequest.' + typeId; 31 instance.instanceType = 'declarativeWebRequest.' + typeId;
31 var schema = getSchema('declarativeWebRequest', typeId); 32 var schema = getSchema('declarativeWebRequest', typeId);
32 chromeHidden.validate([instance], [schema]); 33 validate([instance], [schema]);
33 } 34 }
34 35
35 // Setup all data types for the declarative webRequest API. 36 // Setup all data types for the declarative webRequest API.
36 chrome.declarativeWebRequest.RequestMatcher = function(parameters) { 37 chrome.declarativeWebRequest.RequestMatcher = function(parameters) {
37 setupInstance(this, parameters, 'RequestMatcher'); 38 setupInstance(this, parameters, 'RequestMatcher');
38 }; 39 };
39 chrome.declarativeWebRequest.CancelRequest = function(parameters) { 40 chrome.declarativeWebRequest.CancelRequest = function(parameters) {
40 setupInstance(this, parameters, 'CancelRequest'); 41 setupInstance(this, parameters, 'CancelRequest');
41 }; 42 };
42 chrome.declarativeWebRequest.RedirectRequest = function(parameters) { 43 chrome.declarativeWebRequest.RedirectRequest = function(parameters) {
(...skipping 18 matching lines...) Expand all
61 chrome.declarativeWebRequest.RedirectToEmptyDocument = function(parameters) { 62 chrome.declarativeWebRequest.RedirectToEmptyDocument = function(parameters) {
62 setupInstance(this, parameters, 'RedirectToEmptyDocument'); 63 setupInstance(this, parameters, 'RedirectToEmptyDocument');
63 }; 64 };
64 chrome.declarativeWebRequest.RedirectToEmptyDocument = function(parameters) { 65 chrome.declarativeWebRequest.RedirectToEmptyDocument = function(parameters) {
65 setupInstance(this, parameters, 'RedirectToEmptyDocument'); 66 setupInstance(this, parameters, 'RedirectToEmptyDocument');
66 }; 67 };
67 chrome.declarativeWebRequest.IgnoreRules = function(parameters) { 68 chrome.declarativeWebRequest.IgnoreRules = function(parameters) {
68 setupInstance(this, parameters, 'IgnoreRules'); 69 setupInstance(this, parameters, 'IgnoreRules');
69 }; 70 };
70 }); 71 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698