Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of the Adblock Plus, | 2 * This file is part of the Adblock Plus, |
3 * Copyright (C) 2006-2012 Eyeo GmbH | 3 * Copyright (C) 2006-2012 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 { | 366 { |
367 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); | 367 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); |
368 registrar.registerFactory(this.classID, this.classDescription, this.contract ID, this); | 368 registrar.registerFactory(this.classID, this.classDescription, this.contract ID, this); |
369 | 369 |
370 let catMan = Utils.categoryManager; | 370 let catMan = Utils.categoryManager; |
371 for each (let category in this.xpcom_categories) | 371 for each (let category in this.xpcom_categories) |
372 catMan.addCategoryEntry(category, this.contractID, this.contractID, false, true); | 372 catMan.addCategoryEntry(category, this.contractID, this.contractID, false, true); |
373 | 373 |
374 Services.obs.addObserver(this, "http-on-modify-request", true); | 374 Services.obs.addObserver(this, "http-on-modify-request", true); |
375 Services.obs.addObserver(this, "content-document-global-created", true); | 375 Services.obs.addObserver(this, "content-document-global-created", true); |
376 Services.obs.addObserver(this, "xpcom-category-entry-removed", true); | |
377 Services.obs.addObserver(this, "xpcom-category-cleared", true); | |
376 | 378 |
377 onShutdown.add(function() | 379 onShutdown.add(function() |
378 { | 380 { |
381 // Our category observers should be removed before changing category | |
382 // memberships, just in case. | |
383 Services.obs.removeObserver(this, "http-on-modify-request"); | |
384 Services.obs.removeObserver(this, "content-document-global-created"); | |
385 Services.obs.removeObserver(this, "xpcom-category-entry-removed", true); | |
Thomas Greiner
2013/02/07 16:16:27
removeObserver doesn't require a third parameter
h
| |
386 Services.obs.removeObserver(this, "xpcom-category-cleared", true); | |
Thomas Greiner
2013/02/07 16:16:27
removeObserver doesn't require a third parameter
h
| |
387 | |
379 for each (let category in this.xpcom_categories) | 388 for each (let category in this.xpcom_categories) |
380 catMan.deleteCategoryEntry(category, this.contractID, false); | 389 catMan.deleteCategoryEntry(category, this.contractID, false); |
381 | 390 |
382 // This needs to run asynchronously, see bug 753687 | 391 // This needs to run asynchronously, see bug 753687 |
383 Utils.runAsync(function() | 392 Utils.runAsync(function() |
384 { | 393 { |
385 registrar.unregisterFactory(this.classID, this); | 394 registrar.unregisterFactory(this.classID, this); |
386 }.bind(this)); | 395 }.bind(this)); |
387 | 396 |
388 Services.obs.removeObserver(this, "http-on-modify-request"); | |
389 Services.obs.removeObserver(this, "content-document-global-created"); | |
390 | |
391 this.previousRequest = null; | 397 this.previousRequest = null; |
392 }.bind(this)); | 398 }.bind(this)); |
393 }, | 399 }, |
394 | 400 |
395 // | 401 // |
396 // nsISupports interface implementation | 402 // nsISupports interface implementation |
397 // | 403 // |
398 | 404 |
399 QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy, Ci.nsIObserver, | 405 QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy, Ci.nsIObserver, |
400 Ci.nsIChannelEventSink, Ci.nsIFactory, Ci.nsISupportsWeakReference]), | 406 Ci.nsIChannelEventSink, Ci.nsIFactory, Ci.nsISupportsWeakReference]), |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 | 495 |
490 if (this.expectingPopupLoad) | 496 if (this.expectingPopupLoad) |
491 { | 497 { |
492 let wnd = Utils.getRequestWindow(subject); | 498 let wnd = Utils.getRequestWindow(subject); |
493 if (wnd && wnd.opener && wnd.location.href == "about:blank") | 499 if (wnd && wnd.opener && wnd.location.href == "about:blank") |
494 this.observe(wnd, "content-document-global-created", null, subject.U RI); | 500 this.observe(wnd, "content-document-global-created", null, subject.U RI); |
495 } | 501 } |
496 | 502 |
497 break; | 503 break; |
498 } | 504 } |
505 case "xpcom-category-entry-removed": | |
506 case "xpcom-category-cleared": | |
507 { | |
508 let category = data; | |
509 if (!this.xpcom_categories.some(function(c) c == category)) | |
Thomas Greiner
2013/02/07 16:16:27
this.xpcom_categories.indexOf(category) == -1
shou
| |
510 return; | |
511 | |
512 if (topic == "xpcom-category-entry-removed" && subject instanceof Ci.nsI SupportsCString) | |
513 if (subject.data != this.contractID) | |
Thomas Greiner
2013/02/07 16:16:27
Why did you split this up into two if-statements?
Thomas Greiner
2013/02/07 16:16:27
You are already checking for the topic with the sw
Wladimir Palant
2013/02/08 07:52:31
Yes, this is possible of course. However, fallthro
| |
514 return; | |
515 | |
516 // Our category entry was removed, make sure to add it back | |
517 let catMan = Utils.categoryManager; | |
518 catMan.addCategoryEntry(category, this.contractID, this.contractID, fals e, true); | |
519 break; | |
520 } | |
499 } | 521 } |
500 }, | 522 }, |
501 | 523 |
502 // | 524 // |
503 // nsIChannelEventSink interface implementation | 525 // nsIChannelEventSink interface implementation |
504 // | 526 // |
505 | 527 |
506 asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback) | 528 asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback) |
507 { | 529 { |
508 let result = Cr.NS_OK; | 530 let result = Cr.NS_OK; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
713 if (!wnd || wnd.closed) | 735 if (!wnd || wnd.closed) |
714 return; | 736 return; |
715 | 737 |
716 if (entry.type == Policy.type.OBJECT) | 738 if (entry.type == Policy.type.OBJECT) |
717 { | 739 { |
718 node.removeEventListener("mouseover", objectMouseEventHander, true); | 740 node.removeEventListener("mouseover", objectMouseEventHander, true); |
719 node.removeEventListener("mouseout", objectMouseEventHander, true); | 741 node.removeEventListener("mouseout", objectMouseEventHander, true); |
720 } | 742 } |
721 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; | 743 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; |
722 } | 744 } |
OLD | NEW |