Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/contentPolicy.js

Issue 29329390: Issue 3208 - Stop watching category removals (Closed)
Patch Set: Removed comment as well Created Oct. 26, 2015, 8:33 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 catMan.addCategoryEntry(category, this.contractID, this.contractID, false, true); 403 catMan.addCategoryEntry(category, this.contractID, this.contractID, false, true);
404 404
405 // http-on-opening-request is new in Gecko 18, http-on-modify-request can 405 // http-on-opening-request is new in Gecko 18, http-on-modify-request can
406 // be used in earlier releases. 406 // be used in earlier releases.
407 let httpTopic = "http-on-opening-request"; 407 let httpTopic = "http-on-opening-request";
408 if (Services.vc.compare(Utils.platformVersion, "18.0") < 0) 408 if (Services.vc.compare(Utils.platformVersion, "18.0") < 0)
409 httpTopic = "http-on-modify-request"; 409 httpTopic = "http-on-modify-request";
410 410
411 Services.obs.addObserver(this, httpTopic, true); 411 Services.obs.addObserver(this, httpTopic, true);
412 Services.obs.addObserver(this, "content-document-global-created", true); 412 Services.obs.addObserver(this, "content-document-global-created", true);
413 Services.obs.addObserver(this, "xpcom-category-entry-removed", true);
414 Services.obs.addObserver(this, "xpcom-category-cleared", true);
415 413
416 onShutdown.add(function() 414 onShutdown.add(function()
417 { 415 {
418 // Our category observers should be removed before changing category
419 // memberships, just in case.
420 Services.obs.removeObserver(this, httpTopic); 416 Services.obs.removeObserver(this, httpTopic);
421 Services.obs.removeObserver(this, "content-document-global-created"); 417 Services.obs.removeObserver(this, "content-document-global-created");
422 Services.obs.removeObserver(this, "xpcom-category-entry-removed");
423 Services.obs.removeObserver(this, "xpcom-category-cleared");
424 418
425 for (let category of this.xpcom_categories) 419 for (let category of this.xpcom_categories)
426 catMan.deleteCategoryEntry(category, this.contractID, false); 420 catMan.deleteCategoryEntry(category, this.contractID, false);
427 421
428 // This needs to run asynchronously, see bug 753687 422 // This needs to run asynchronously, see bug 753687
429 Utils.runAsync(function() 423 Utils.runAsync(function()
430 { 424 {
431 registrar.unregisterFactory(this.classID, this); 425 registrar.unregisterFactory(this.classID, this);
432 }.bind(this)); 426 }.bind(this));
433 427
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 if (wnd && wnd.opener && wnd.location.href == "about:blank") 531 if (wnd && wnd.opener && wnd.location.href == "about:blank")
538 { 532 {
539 this.observe(wnd, "content-document-global-created", null, subject.U RI); 533 this.observe(wnd, "content-document-global-created", null, subject.U RI);
540 if (subject instanceof Ci.nsIWritablePropertyBag) 534 if (subject instanceof Ci.nsIWritablePropertyBag)
541 subject.setProperty("abpRequestType", Policy.type.POPUP); 535 subject.setProperty("abpRequestType", Policy.type.POPUP);
542 } 536 }
543 } 537 }
544 538
545 break; 539 break;
546 } 540 }
547 case "xpcom-category-entry-removed":
548 case "xpcom-category-cleared":
549 {
550 let category = data;
551 if (this.xpcom_categories.indexOf(category) < 0)
552 return;
553
554 if (topic == "xpcom-category-entry-removed" &&
555 subject instanceof Ci.nsISupportsCString &&
556 subject.data != this.contractID)
557 {
558 return;
559 }
560
561 // Our category entry was removed, make sure to add it back
562 let catMan = Utils.categoryManager;
563 catMan.addCategoryEntry(category, this.contractID, this.contractID, fals e, true);
564 break;
565 }
566 } 541 }
567 }, 542 },
568 543
569 // 544 //
570 // nsIChannelEventSink interface implementation 545 // nsIChannelEventSink interface implementation
571 // 546 //
572 547
573 asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback) 548 asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback)
574 { 549 {
575 let result = Cr.NS_OK; 550 let result = Cr.NS_OK;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 if (!wnd || wnd.closed) 802 if (!wnd || wnd.closed)
828 return; 803 return;
829 804
830 if (entry.type == Policy.type.OBJECT) 805 if (entry.type == Policy.type.OBJECT)
831 { 806 {
832 node.removeEventListener("mouseover", objectMouseEventHander, true); 807 node.removeEventListener("mouseover", objectMouseEventHander, true);
833 node.removeEventListener("mouseout", objectMouseEventHander, true); 808 node.removeEventListener("mouseout", objectMouseEventHander, true);
834 } 809 }
835 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; 810 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ;
836 } 811 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld