| 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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 const notImplemented = () => Cr.NS_ERROR_NOT_IMPLEMENTED; | 47 const notImplemented = () => Cr.NS_ERROR_NOT_IMPLEMENTED; |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * about: URL module used to count hits. | 50 * about: URL module used to count hits. |
| 51 * @class | 51 * @class |
| 52 */ | 52 */ |
| 53 let AboutHandler = | 53 let AboutHandler = |
| 54 { | 54 { |
| 55 classID: Components.ID("{55fb7be0-1dd2-11b2-98e6-9e97caf8ba67}"), | 55 classID: Components.ID("{55fb7be0-1dd2-11b2-98e6-9e97caf8ba67}"), |
| 56 classDescription: "Element hiding hit registration protocol handler", | 56 classDescription: "Element hiding hit registration protocol handler", |
| 57 aboutPrefix: "abp-elemhidehit", | 57 aboutPrefix: "abp-elemhide", |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * Registers handler on startup. | 60 * Registers handler on startup. |
| 61 */ | 61 */ |
| 62 init: function() | 62 init: function() |
| 63 { | 63 { |
| 64 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); | 64 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); |
| 65 registrar.registerFactory(this.classID, this.classDescription, | 65 registrar.registerFactory(this.classID, this.classDescription, |
| 66 "@mozilla.org/network/protocol/about;1?what=" + this.aboutPrefix, this); | 66 "@mozilla.org/network/protocol/about;1?what=" + this.aboutPrefix, this); |
| 67 onShutdown.add(function() | 67 onShutdown.add(function() |
| (...skipping 18 matching lines...) Expand all Loading... |
| 86 // About module implementation | 86 // About module implementation |
| 87 // | 87 // |
| 88 | 88 |
| 89 getURIFlags: function(uri) | 89 getURIFlags: function(uri) |
| 90 { | 90 { |
| 91 return Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT; | 91 return Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT; |
| 92 }, | 92 }, |
| 93 | 93 |
| 94 newChannel: function(uri, loadInfo) | 94 newChannel: function(uri, loadInfo) |
| 95 { | 95 { |
| 96 let match = /\?(\d+|css)$/.exec(uri.path); | 96 let match = /\?(?:hit(\d+)|css)$/.exec(uri.path); |
| 97 if (!match) | 97 if (!match) |
| 98 throw Cr.NS_ERROR_FAILURE; | 98 throw Cr.NS_ERROR_FAILURE; |
| 99 | 99 |
| 100 if (match[1] == "css") | 100 if (match[1]) |
| 101 return new HitRegistrationChannel(uri, loadInfo, match[1]); |
| 102 else |
| 101 return new StyleDataChannel(uri, loadInfo); | 103 return new StyleDataChannel(uri, loadInfo); |
| 102 else | |
| 103 return new HitRegistrationChannel(uri, loadInfo, match[1]); | |
| 104 }, | 104 }, |
| 105 | 105 |
| 106 QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory, Ci.nsIAboutModule]) | 106 QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory, Ci.nsIAboutModule]) |
| 107 }; | 107 }; |
| 108 AboutHandler.init(); | 108 AboutHandler.init(); |
| 109 | 109 |
| 110 /** | 110 /** |
| 111 * Base class for channel implementations, subclasses usually only need to | 111 * Base class for channel implementations, subclasses usually only need to |
| 112 * override BaseChannel._getResponse() method. | 112 * override BaseChannel._getResponse() method. |
| 113 * @constructor | 113 * @constructor |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 { | 224 { |
| 225 function escapeChar(match) | 225 function escapeChar(match) |
| 226 { | 226 { |
| 227 return "\\" + match.charCodeAt(0).toString(16) + " "; | 227 return "\\" + match.charCodeAt(0).toString(16) + " "; |
| 228 } | 228 } |
| 229 | 229 |
| 230 // Would be great to avoid sync messaging here but nsIStyleSheetService | 230 // Would be great to avoid sync messaging here but nsIStyleSheetService |
| 231 // insists on opening channels synchronously. | 231 // insists on opening channels synchronously. |
| 232 let domains = port.emitSync("getSelectors"); | 232 let domains = port.emitSync("getSelectors"); |
| 233 | 233 |
| 234 let cssPrefix = "{-moz-binding: url(about:abp-elemhidehit?"; | 234 let cssPrefix = "{-moz-binding: url(about:abp-elemhide?hit"; |
| 235 let cssSuffix = "#dummy) !important;}\n"; | 235 let cssSuffix = "#dummy) !important;}\n"; |
| 236 let result = []; | 236 let result = []; |
| 237 | 237 |
| 238 for (let [domain, selectors] of domains) | 238 for (let [domain, selectors] of domains) |
| 239 { | 239 { |
| 240 if (domain) | 240 if (domain) |
| 241 { | 241 { |
| 242 result.push('@-moz-document domain("', | 242 result.push('@-moz-document domain("', |
| 243 domain.replace(/[^\x01-\x7F]/g, escapeChar) | 243 domain.replace(/[^\x01-\x7F]/g, escapeChar) |
| 244 .split(",").join('"),domain("'), | 244 .split(",").join('"),domain("'), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 return new Promise((resolve, reject) => | 286 return new Promise((resolve, reject) => |
| 287 { | 287 { |
| 288 let window = Utils.getRequestWindow(this); | 288 let window = Utils.getRequestWindow(this); |
| 289 shouldAllowAsync(window, window.document, "ELEMHIDE", this.key, allow => | 289 shouldAllowAsync(window, window.document, "ELEMHIDE", this.key, allow => |
| 290 { | 290 { |
| 291 resolve(allow ? allowXBL : hideXBL); | 291 resolve(allow ? allowXBL : hideXBL); |
| 292 }); | 292 }); |
| 293 }); | 293 }); |
| 294 } | 294 } |
| 295 }; | 295 }; |
| OLD | NEW |