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

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

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments/TODOs Created 7 years, 11 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 webRequest API. 5 // Custom bindings for the webRequest API.
6 6
7 var bindings = new (require('schema_binding_generator').Bindings)('webRequest');
8
7 var webRequestNatives = requireNative('web_request'); 9 var webRequestNatives = requireNative('web_request');
8 var GetUniqueSubEventName = webRequestNatives.GetUniqueSubEventName; 10 var GetUniqueSubEventName = webRequestNatives.GetUniqueSubEventName;
9 11
10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 12 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
11 var sendRequest = require('sendRequest').sendRequest; 13 var sendRequest = require('sendRequest').sendRequest;
12 var validate = require('schemaUtils').validate; 14 var validate = require('schemaUtils').validate;
13 15
14 // WebRequestEvent object. This is used for special webRequest events with 16 // WebRequestEvent object. This is used for special webRequest events with
15 // extra parameters. Each invocation of addListener creates a new named 17 // extra parameters. Each invocation of addListener creates a new named
16 // sub-event. That sub-event is associated with the extra parameters in the 18 // sub-event. That sub-event is associated with the extra parameters in the
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 throw new Error('This event does not support rules.'); 141 throw new Error('This event does not support rules.');
140 this.eventForRules_.removeRules(ruleIdentifiers, opt_cb); 142 this.eventForRules_.removeRules(ruleIdentifiers, opt_cb);
141 } 143 }
142 144
143 WebRequestEvent.prototype.getRules = function(ruleIdentifiers, cb) { 145 WebRequestEvent.prototype.getRules = function(ruleIdentifiers, cb) {
144 if (!this.eventOptions_.supportsRules) 146 if (!this.eventOptions_.supportsRules)
145 throw new Error('This event does not support rules.'); 147 throw new Error('This event does not support rules.');
146 this.eventForRules_.getRules(ruleIdentifiers, cb); 148 this.eventForRules_.getRules(ruleIdentifiers, cb);
147 } 149 }
148 150
149 chromeHidden.registerCustomEvent('webRequest', WebRequestEvent); 151 bindings.registerCustomEvent(WebRequestEvent);
150 152
151 chromeHidden.registerCustomHook('webRequest', function(api) { 153 bindings.registerCustomHook(function(api) {
152 var apiFunctions = api.apiFunctions; 154 var apiFunctions = api.apiFunctions;
153 155
154 apiFunctions.setHandleRequest('handlerBehaviorChanged', function() { 156 apiFunctions.setHandleRequest('handlerBehaviorChanged', function() {
155 var args = Array.prototype.slice.call(arguments); 157 var args = Array.prototype.slice.call(arguments);
156 sendRequest(this.name, args, this.definition.parameters, 158 sendRequest(this.name, args, this.definition.parameters,
157 {forIOThread: true}); 159 {forIOThread: true});
158 }); 160 });
159 }); 161 });
162
163 // TODO(cduvall): Make sure this is right.
164 if (!('webRequestInternal' in chromeHidden.internalAPIs))
165 require('webRequestInternal');
166
167 exports.bindings = bindings.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698