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

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

Issue 8934008: chrome.webRequest.*.removeListener removes callbacks that were registered multiple times (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/webrequest/test_api.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // This script contains privileged chrome extension related javascript APIs. 5 // This script contains privileged chrome extension related javascript APIs.
6 // It is loaded by pages whose URL has the chrome-extension protocol. 6 // It is loaded by pages whose URL has the chrome-extension protocol.
7 7
8 var chrome = chrome || {}; 8 var chrome = chrome || {};
9 (function() { 9 (function() {
10 native function GetExtensionAPIDefinition(); 10 native function GetExtensionAPIDefinition();
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 cb.apply(null, [details, handledCallback]); 262 cb.apply(null, [details, handledCallback]);
263 }; 263 };
264 } 264 }
265 this.subEvents_.push( 265 this.subEvents_.push(
266 {subEvent: subEvent, callback: cb, subEventCallback: subEventCallback}); 266 {subEvent: subEvent, callback: cb, subEventCallback: subEventCallback});
267 subEvent.addListener(subEventCallback); 267 subEvent.addListener(subEventCallback);
268 }; 268 };
269 269
270 // Unregisters a callback. 270 // Unregisters a callback.
271 chrome.WebRequestEvent.prototype.removeListener = function(cb) { 271 chrome.WebRequestEvent.prototype.removeListener = function(cb) {
272 var idx = this.findListener_(cb); 272 var idx;
273 if (idx < 0) { 273 while ((idx = this.findListener_(cb)) >= 0) {
274 return; 274 var e = this.subEvents_[idx];
275 e.subEvent.removeListener(e.subEventCallback);
276 if (e.subEvent.hasListeners()) {
277 console.error(
278 "Internal error: webRequest subEvent has orphaned listeners.");
279 }
280 this.subEvents_.splice(idx, 1);
275 } 281 }
276
277 var e = this.subEvents_[idx];
278 e.subEvent.removeListener(e.subEventCallback);
279 if (e.subEvent.hasListeners()) {
280 console.error(
281 "Internal error: webRequest subEvent has orphaned listeners.");
282 }
283 this.subEvents_.splice(idx, 1);
284 }; 282 };
285 283
286 chrome.WebRequestEvent.prototype.findListener_ = function(cb) { 284 chrome.WebRequestEvent.prototype.findListener_ = function(cb) {
287 for (var i in this.subEvents_) { 285 for (var i in this.subEvents_) {
288 var e = this.subEvents_[i]; 286 var e = this.subEvents_[i];
289 if (e.callback === cb) { 287 if (e.callback === cb) {
290 if (e.subEvent.findListener_(e.subEventCallback) > -1) 288 if (e.subEvent.findListener_(e.subEventCallback) > -1)
291 return i; 289 return i;
292 console.error("Internal error: webRequest subEvent has no callback."); 290 console.error("Internal error: webRequest subEvent has no callback.");
293 } 291 }
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 1114
1117 if (!chrome.tts) 1115 if (!chrome.tts)
1118 chrome.tts = {}; 1116 chrome.tts = {};
1119 1117
1120 if (!chrome.ttsEngine) 1118 if (!chrome.ttsEngine)
1121 chrome.ttsEngine = {}; 1119 chrome.ttsEngine = {};
1122 1120
1123 if (!chrome.experimental.downloads) 1121 if (!chrome.experimental.downloads)
1124 chrome.experimental.downloads = {}; 1122 chrome.experimental.downloads = {};
1125 })(); 1123 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/webrequest/test_api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698