| OLD | NEW |
| 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 classID: Components.ID("cfeaabe6-1dd1-11b2-a0c6-cb5c268894c9"), | 374 classID: Components.ID("cfeaabe6-1dd1-11b2-a0c6-cb5c268894c9"), |
| 375 contractID: "@adblockplus.org/abp/policy;1", | 375 contractID: "@adblockplus.org/abp/policy;1", |
| 376 xpcom_categories: ["content-policy", "net-channel-event-sinks"], | 376 xpcom_categories: ["content-policy", "net-channel-event-sinks"], |
| 377 | 377 |
| 378 /** | 378 /** |
| 379 * Registers the content policy on startup. | 379 * Registers the content policy on startup. |
| 380 */ | 380 */ |
| 381 init: function() | 381 init: function() |
| 382 { | 382 { |
| 383 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); | 383 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); |
| 384 try | 384 registrar.registerFactory(this.classID, this.classDescription, this.contract
ID, this); |
| 385 { | |
| 386 registrar.registerFactory(this.classID, this.classDescription, this.contra
ctID, this); | |
| 387 } | |
| 388 catch (e) | |
| 389 { | |
| 390 // See bug 924340 - it might be too early to init now, the old version | |
| 391 // we are replacing didn't finish removing itself yet. | |
| 392 if (e.result == Cr.NS_ERROR_FACTORY_EXISTS) | |
| 393 { | |
| 394 Utils.runAsync(this.init.bind(this)); | |
| 395 return; | |
| 396 } | |
| 397 | |
| 398 Cu.reportError(e); | |
| 399 } | |
| 400 | 385 |
| 401 let catMan = Utils.categoryManager; | 386 let catMan = Utils.categoryManager; |
| 402 for (let category of this.xpcom_categories) | 387 for (let category of this.xpcom_categories) |
| 403 catMan.addCategoryEntry(category, this.contractID, this.contractID, false,
true); | 388 catMan.addCategoryEntry(category, this.contractID, this.contractID, false,
true); |
| 404 | 389 |
| 405 // http-on-opening-request is new in Gecko 18, http-on-modify-request can | 390 // http-on-opening-request is new in Gecko 18, http-on-modify-request can |
| 406 // be used in earlier releases. | 391 // be used in earlier releases. |
| 407 let httpTopic = "http-on-opening-request"; | 392 let httpTopic = "http-on-opening-request"; |
| 408 if (Services.vc.compare(Utils.platformVersion, "18.0") < 0) | 393 if (Services.vc.compare(Utils.platformVersion, "18.0") < 0) |
| 409 httpTopic = "http-on-modify-request"; | 394 httpTopic = "http-on-modify-request"; |
| 410 | 395 |
| 411 Services.obs.addObserver(this, httpTopic, true); | 396 Services.obs.addObserver(this, httpTopic, true); |
| 412 Services.obs.addObserver(this, "content-document-global-created", true); | 397 Services.obs.addObserver(this, "content-document-global-created", true); |
| 413 | 398 |
| 414 onShutdown.add(function() | 399 onShutdown.add(function() |
| 415 { | 400 { |
| 416 // Our category observers should be removed before changing category | 401 // Our category observers should be removed before changing category |
| 417 // memberships, just in case. | 402 // memberships, just in case. |
| 418 Services.obs.removeObserver(this, httpTopic); | 403 Services.obs.removeObserver(this, httpTopic); |
| 419 Services.obs.removeObserver(this, "content-document-global-created"); | 404 Services.obs.removeObserver(this, "content-document-global-created"); |
| 420 | 405 |
| 421 for (let category of this.xpcom_categories) | 406 for (let category of this.xpcom_categories) |
| 422 catMan.deleteCategoryEntry(category, this.contractID, false); | 407 catMan.deleteCategoryEntry(category, this.contractID, false); |
| 423 | 408 |
| 424 // This needs to run asynchronously, see bug 753687 | 409 registrar.unregisterFactory(this.classID, this); |
| 425 Utils.runAsync(function() | |
| 426 { | |
| 427 registrar.unregisterFactory(this.classID, this); | |
| 428 }.bind(this)); | |
| 429 | 410 |
| 430 this.previousRequest = null; | 411 this.previousRequest = null; |
| 431 }.bind(this)); | 412 }.bind(this)); |
| 432 }, | 413 }, |
| 433 | 414 |
| 434 // | 415 // |
| 435 // nsISupports interface implementation | 416 // nsISupports interface implementation |
| 436 // | 417 // |
| 437 | 418 |
| 438 QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy, Ci.nsIObserver, | 419 QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy, Ci.nsIObserver, |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 if (!wnd || wnd.closed) | 785 if (!wnd || wnd.closed) |
| 805 return; | 786 return; |
| 806 | 787 |
| 807 if (entry.type == Policy.type.OBJECT) | 788 if (entry.type == Policy.type.OBJECT) |
| 808 { | 789 { |
| 809 node.removeEventListener("mouseover", objectMouseEventHander, true); | 790 node.removeEventListener("mouseover", objectMouseEventHander, true); |
| 810 node.removeEventListener("mouseout", objectMouseEventHander, true); | 791 node.removeEventListener("mouseout", objectMouseEventHander, true); |
| 811 } | 792 } |
| 812 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true)
; | 793 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true)
; |
| 813 } | 794 } |
| OLD | NEW |