| Index: chrome/renderer/resources/extensions/web_request_custom_bindings.js
|
| diff --git a/chrome/renderer/resources/extensions/web_request_custom_bindings.js b/chrome/renderer/resources/extensions/web_request_custom_bindings.js
|
| index 316ac07a059f8e367274a0cf0908019b4daf74be..564251ea4fa70f7a37bb4f8639b8cdce65f31428 100644
|
| --- a/chrome/renderer/resources/extensions/web_request_custom_bindings.js
|
| +++ b/chrome/renderer/resources/extensions/web_request_custom_bindings.js
|
| @@ -19,19 +19,19 @@ var chromeHidden = GetChromeHidden();
|
| //
|
| // Example:
|
| // chrome.webRequest.onBeforeRequest.addListener(
|
| -// callback, {urls: "http://*.google.com/*"});
|
| +// callback, {urls: 'http://*.google.com/*'});
|
| // ^ callback will only be called for onBeforeRequests matching the filter.
|
| function WebRequestEvent(eventName, opt_argSchemas, opt_extraArgSchemas,
|
| opt_eventOptions) {
|
| - if (typeof eventName != "string")
|
| - throw new Error("chrome.WebRequestEvent requires an event name.");
|
| + if (typeof eventName != 'string')
|
| + throw new Error('chrome.WebRequestEvent requires an event name.');
|
|
|
| this.eventName_ = eventName;
|
| this.argSchemas_ = opt_argSchemas;
|
| this.extraArgSchemas_ = opt_extraArgSchemas;
|
| this.subEvents_ = [];
|
| this.eventOptions_ = opt_eventOptions ||
|
| - {"supportsListeners": true, "supportsRules": false};
|
| + {'supportsListeners': true, 'supportsRules': false};
|
|
|
| if (this.eventOptions_.supportsRules)
|
| this.eventForRules_ =
|
| @@ -41,14 +41,14 @@ function WebRequestEvent(eventName, opt_argSchemas, opt_extraArgSchemas,
|
| // Test if the given callback is registered for this event.
|
| WebRequestEvent.prototype.hasListener = function(cb) {
|
| if (!this.eventOptions_.supportsListeners)
|
| - throw new Error("This event does not support listeners.");
|
| + throw new Error('This event does not support listeners.');
|
| return this.findListener_(cb) > -1;
|
| };
|
|
|
| // Test if any callbacks are registered fur thus event.
|
| WebRequestEvent.prototype.hasListeners = function() {
|
| if (!this.eventOptions_.supportsListeners)
|
| - throw new Error("This event does not support listeners.");
|
| + throw new Error('This event does not support listeners.');
|
| return this.subEvents_.length > 0;
|
| };
|
|
|
| @@ -59,7 +59,7 @@ WebRequestEvent.prototype.hasListeners = function() {
|
| WebRequestEvent.prototype.addListener =
|
| function(cb, opt_filter, opt_extraInfo) {
|
| if (!this.eventOptions_.supportsListeners)
|
| - throw new Error("This event does not support listeners.");
|
| + throw new Error('This event does not support listeners.');
|
| var subEventName = GetUniqueSubEventName(this.eventName_);
|
| // Note: this could fail to validate, in which case we would not add the
|
| // subEvent listener.
|
| @@ -70,7 +70,7 @@ WebRequestEvent.prototype.addListener =
|
|
|
| var subEvent = new chrome.Event(subEventName, this.argSchemas_);
|
| var subEventCallback = cb;
|
| - if (opt_extraInfo && opt_extraInfo.indexOf("blocking") >= 0) {
|
| + if (opt_extraInfo && opt_extraInfo.indexOf('blocking') >= 0) {
|
| var eventName = this.eventName_;
|
| subEventCallback = function() {
|
| var requestId = arguments[0].requestId;
|
| @@ -84,7 +84,7 @@ WebRequestEvent.prototype.addListener =
|
| throw e;
|
| }
|
| };
|
| - } else if (opt_extraInfo && opt_extraInfo.indexOf("asyncBlocking") >= 0) {
|
| + } else if (opt_extraInfo && opt_extraInfo.indexOf('asyncBlocking') >= 0) {
|
| var eventName = this.eventName_;
|
| subEventCallback = function() {
|
| var details = arguments[0];
|
| @@ -104,14 +104,14 @@ WebRequestEvent.prototype.addListener =
|
| // Unregisters a callback.
|
| WebRequestEvent.prototype.removeListener = function(cb) {
|
| if (!this.eventOptions_.supportsListeners)
|
| - throw new Error("This event does not support listeners.");
|
| + throw new Error('This event does not support listeners.');
|
| var idx;
|
| while ((idx = this.findListener_(cb)) >= 0) {
|
| var e = this.subEvents_[idx];
|
| e.subEvent.removeListener(e.subEventCallback);
|
| if (e.subEvent.hasListeners()) {
|
| console.error(
|
| - "Internal error: webRequest subEvent has orphaned listeners.");
|
| + 'Internal error: webRequest subEvent has orphaned listeners.');
|
| }
|
| this.subEvents_.splice(idx, 1);
|
| }
|
| @@ -123,7 +123,7 @@ WebRequestEvent.prototype.findListener_ = function(cb) {
|
| if (e.callback === cb) {
|
| if (e.subEvent.findListener_(e.subEventCallback) > -1)
|
| return i;
|
| - console.error("Internal error: webRequest subEvent has no callback.");
|
| + console.error('Internal error: webRequest subEvent has no callback.');
|
| }
|
| }
|
|
|
| @@ -132,44 +132,41 @@ WebRequestEvent.prototype.findListener_ = function(cb) {
|
|
|
| WebRequestEvent.prototype.addRules = function(rules, opt_cb) {
|
| if (!this.eventOptions_.supportsRules)
|
| - throw new Error("This event does not support rules.");
|
| + throw new Error('This event does not support rules.');
|
| this.eventForRules_.addRules(rules, opt_cb);
|
| }
|
|
|
| WebRequestEvent.prototype.removeRules = function(ruleIdentifiers, opt_cb) {
|
| if (!this.eventOptions_.supportsRules)
|
| - throw new Error("This event does not support rules.");
|
| + throw new Error('This event does not support rules.');
|
| this.eventForRules_.removeRules(ruleIdentifiers, opt_cb);
|
| }
|
|
|
| WebRequestEvent.prototype.getRules = function(ruleIdentifiers, cb) {
|
| if (!this.eventOptions_.supportsRules)
|
| - throw new Error("This event does not support rules.");
|
| + throw new Error('This event does not support rules.');
|
| this.eventForRules_.getRules(ruleIdentifiers, cb);
|
| }
|
|
|
| -chromeHidden.registerCustomEvent("webRequest", WebRequestEvent);
|
| +chromeHidden.registerCustomEvent('webRequest', WebRequestEvent);
|
|
|
| -chromeHidden.registerCustomHook("webRequest", function(api) {
|
| +chromeHidden.registerCustomHook('webRequest', function(api) {
|
| var apiFunctions = api.apiFunctions;
|
| var sendRequest = api.sendRequest;
|
|
|
| - apiFunctions.setHandleRequest("webRequest.addEventListener",
|
| - function() {
|
| + apiFunctions.setHandleRequest('addEventListener', function() {
|
| var args = Array.prototype.slice.call(arguments);
|
| sendRequest(this.name, args, this.definition.parameters,
|
| {forIOThread: true});
|
| });
|
|
|
| - apiFunctions.setHandleRequest("webRequest.eventHandled",
|
| - function() {
|
| + apiFunctions.setHandleRequest('eventHandled', function() {
|
| var args = Array.prototype.slice.call(arguments);
|
| sendRequest(this.name, args, this.definition.parameters,
|
| {forIOThread: true});
|
| });
|
|
|
| - apiFunctions.setHandleRequest("webRequest.handlerBehaviorChanged",
|
| - function() {
|
| + apiFunctions.setHandleRequest('handlerBehaviorChanged', function() {
|
| var args = Array.prototype.slice.call(arguments);
|
| sendRequest(this.name, args, this.definition.parameters,
|
| {forIOThread: true});
|
|
|