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

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

Issue 10392127: Move declarative API into events API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix change schema type reference from 'Event' to 'events.Event' Created 8 years, 7 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 9
9 chromeHidden.registerCustomHook('declarativeWebRequest', function(api) { 10 chromeHidden.registerCustomHook('declarativeWebRequest', function(api) {
10 // Returns the schema definition of type |typeId| defined in |namespace|. 11 // Returns the schema definition of type |typeId| defined in |namespace|.
11 function getSchema(namespace, typeId) { 12 function getSchema(namespace, typeId) {
12 var filterNamespace = function(val) {return val.namespace === namespace;}; 13 var apiSchema = utils.lookup(api.apiDefinitions, 'namespace', namespace);
13 var apiSchema = api.apiDefinitions.filter(filterNamespace)[0]; 14 var resultSchema = utils.lookup(
14 var filterTypeId = function (val) { 15 apiSchema.types, 'id', namespace + '.' + typeId);
15 return val.id === namespace + "." + typeId;
16 };
17 var resultSchema = apiSchema.types.filter(filterTypeId)[0];
18 return resultSchema; 16 return resultSchema;
19 } 17 }
20 18
21 // Helper function for the constructor of concrete datatypes of the 19 // Helper function for the constructor of concrete datatypes of the
22 // declarative webRequest API. 20 // declarative webRequest API.
23 // Makes sure that |this| contains the union of parameters and 21 // Makes sure that |this| contains the union of parameters and
24 // {'instanceType': 'declarativeWebRequest.' + typeId} and validates the 22 // {'instanceType': 'declarativeWebRequest.' + typeId} and validates the
25 // generated union dictionary against the schema for |typeId|. 23 // generated union dictionary against the schema for |typeId|.
26 function setupInstance(instance, parameters, typeId) { 24 function setupInstance(instance, parameters, typeId) {
27 for (var key in parameters) { 25 for (var key in parameters) {
(...skipping 10 matching lines...) Expand all
38 chrome.declarativeWebRequest.RequestMatcher = function(parameters) { 36 chrome.declarativeWebRequest.RequestMatcher = function(parameters) {
39 setupInstance(this, parameters, 'RequestMatcher'); 37 setupInstance(this, parameters, 'RequestMatcher');
40 }; 38 };
41 chrome.declarativeWebRequest.CancelRequest = function(parameters) { 39 chrome.declarativeWebRequest.CancelRequest = function(parameters) {
42 setupInstance(this, parameters, 'CancelRequest'); 40 setupInstance(this, parameters, 'CancelRequest');
43 }; 41 };
44 chrome.declarativeWebRequest.RedirectRequest = function(parameters) { 42 chrome.declarativeWebRequest.RedirectRequest = function(parameters) {
45 setupInstance(this, parameters, 'RedirectRequest'); 43 setupInstance(this, parameters, 'RedirectRequest');
46 }; 44 };
47 }); 45 });
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/declarative_custom_bindings.js ('k') | chrome/renderer/resources/extensions/event.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698