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

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

Issue 10389168: Revert 137388 - Move declarative API into events API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 webRequest API. 5 // Custom bindings for the webRequest API.
6 6
7 var webRequestNatives = requireNative('web_request'); 7 var webRequestNatives = requireNative('web_request');
8 var GetUniqueSubEventName = webRequestNatives.GetUniqueSubEventName; 8 var GetUniqueSubEventName = webRequestNatives.GetUniqueSubEventName;
9 9
10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
(...skipping 14 matching lines...) Expand all
25 if (typeof eventName != 'string') 25 if (typeof eventName != 'string')
26 throw new Error('chrome.WebRequestEvent requires an event name.'); 26 throw new Error('chrome.WebRequestEvent requires an event name.');
27 27
28 this.eventName_ = eventName; 28 this.eventName_ = eventName;
29 this.argSchemas_ = opt_argSchemas; 29 this.argSchemas_ = opt_argSchemas;
30 this.extraArgSchemas_ = opt_extraArgSchemas; 30 this.extraArgSchemas_ = opt_extraArgSchemas;
31 this.subEvents_ = []; 31 this.subEvents_ = [];
32 this.eventOptions_ = opt_eventOptions || 32 this.eventOptions_ = opt_eventOptions ||
33 {'supportsListeners': true, 'supportsRules': false}; 33 {'supportsListeners': true, 'supportsRules': false};
34 34
35 if (this.eventOptions_.supportsRules) { 35 if (this.eventOptions_.supportsRules)
36 this.eventForRules_ = 36 this.eventForRules_ =
37 new chrome.Event(eventName, opt_argSchemas, opt_eventOptions); 37 new chrome.Event(eventName, opt_argSchemas, opt_eventOptions);
38 }
39 }; 38 };
40 39
41 // Test if the given callback is registered for this event. 40 // Test if the given callback is registered for this event.
42 WebRequestEvent.prototype.hasListener = function(cb) { 41 WebRequestEvent.prototype.hasListener = function(cb) {
43 if (!this.eventOptions_.supportsListeners) 42 if (!this.eventOptions_.supportsListeners)
44 throw new Error('This event does not support listeners.'); 43 throw new Error('This event does not support listeners.');
45 return this.findListener_(cb) > -1; 44 return this.findListener_(cb) > -1;
46 }; 45 };
47 46
48 // Test if any callbacks are registered fur thus event. 47 // Test if any callbacks are registered fur thus event.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 sendRequest(this.name, args, this.definition.parameters, 163 sendRequest(this.name, args, this.definition.parameters,
165 {forIOThread: true}); 164 {forIOThread: true});
166 }); 165 });
167 166
168 apiFunctions.setHandleRequest('handlerBehaviorChanged', function() { 167 apiFunctions.setHandleRequest('handlerBehaviorChanged', function() {
169 var args = Array.prototype.slice.call(arguments); 168 var args = Array.prototype.slice.call(arguments);
170 sendRequest(this.name, args, this.definition.parameters, 169 sendRequest(this.name, args, this.definition.parameters,
171 {forIOThread: true}); 170 {forIOThread: true});
172 }); 171 });
173 }); 172 });
OLDNEW
« no previous file with comments | « chrome/renderer/resources/extensions/utils.js ('k') | chrome/test/data/extensions/api_test/declarative/api/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698