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

Side by Side Diff: lib/contentPolicy.js

Issue 9355011: Make sure ABP category cannot be removed (work-around for AVG toolbar issue) (Closed)
Patch Set: Created Feb. 8, 2013, 7:46 a.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 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
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");
386 Services.obs.removeObserver(this, "xpcom-category-cleared");
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
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.indexOf(category) < 0)
510 return;
511
512 if (topic == "xpcom-category-entry-removed" &&
513 subject instanceof Ci.nsISupportsCString &&
514 subject.data != this.contractID)
515 {
516 return;
517 }
518
519 // Our category entry was removed, make sure to add it back
520 let catMan = Utils.categoryManager;
521 catMan.addCategoryEntry(category, this.contractID, this.contractID, fals e, true);
522 break;
523 }
499 } 524 }
500 }, 525 },
501 526
502 // 527 //
503 // nsIChannelEventSink interface implementation 528 // nsIChannelEventSink interface implementation
504 // 529 //
505 530
506 asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback) 531 asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback)
507 { 532 {
508 let result = Cr.NS_OK; 533 let result = Cr.NS_OK;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 if (!wnd || wnd.closed) 738 if (!wnd || wnd.closed)
714 return; 739 return;
715 740
716 if (entry.type == Policy.type.OBJECT) 741 if (entry.type == Policy.type.OBJECT)
717 { 742 {
718 node.removeEventListener("mouseover", objectMouseEventHander, true); 743 node.removeEventListener("mouseover", objectMouseEventHander, true);
719 node.removeEventListener("mouseout", objectMouseEventHander, true); 744 node.removeEventListener("mouseout", objectMouseEventHander, true);
720 } 745 }
721 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; 746 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ;
722 } 747 }
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