| 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 | 
| 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 12  * GNU General Public License for more details. | 12  * GNU General Public License for more details. | 
| 13  * | 13  * | 
| 14  * You should have received a copy of the GNU General Public License | 14  * You should have received a copy of the GNU General Public License | 
| 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 
| 16  */ | 16  */ | 
| 17 | 17 | 
| 18 /** @module whitelisting */ | 18 /** @module whitelisting */ | 
| 19 | 19 | 
| 20 "use strict"; | 20 "use strict"; | 
| 21 | 21 | 
| 22 let {defaultMatcher} = require("matcher"); | 22 let {defaultMatcher} = require("matcher"); | 
| 23 let {RegExpFilter} = require("filterClasses"); | 23 let {RegExpFilter} = require("filterClasses"); | 
|  | 24 let {DownloadableSubscription} = require("subscriptionClasses"); | 
|  | 25 let {FilterNotifier} = require("filterNotifier"); | 
| 24 let {stringifyURL, getDecodedHostname, extractHostFromFrame, isThirdParty} = req
     uire("url"); | 26 let {stringifyURL, getDecodedHostname, extractHostFromFrame, isThirdParty} = req
     uire("url"); | 
| 25 let {port} = require("messaging"); | 27 let {port} = require("messaging"); | 
| 26 let devtools = require("devtools"); | 28 let devtools = require("devtools"); | 
| 27 | 29 | 
| 28 let pagesWithKey = new ext.PageMap(); | 30 let pagesWithKey = new ext.PageMap(); | 
| 29 | 31 | 
| 30 function match(page, url, typeMask, docDomain, sitekey) | 32 function match(page, url, typeMask, docDomain, sitekey) | 
| 31 { | 33 { | 
| 32   let thirdParty = !!docDomain && isThirdParty(url, docDomain); | 34   let thirdParty = !!docDomain && isThirdParty(url, docDomain); | 
| 33   let urlString = stringifyURL(url); | 35   let urlString = stringifyURL(url); | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 75       filter = match(page, frame.url, typeMask, docDomain, sitekey); | 77       filter = match(page, frame.url, typeMask, docDomain, sitekey); | 
| 76       frame = parent; | 78       frame = parent; | 
| 77     } | 79     } | 
| 78 | 80 | 
| 79     return filter; | 81     return filter; | 
| 80   } | 82   } | 
| 81 | 83 | 
| 82   return match(page, page.url, typeMask); | 84   return match(page, page.url, typeMask); | 
| 83 }; | 85 }; | 
| 84 | 86 | 
|  | 87 function revalidateWhitelistingState(page) | 
|  | 88 { | 
|  | 89   FilterNotifier.triggerListeners( | 
|  | 90     "page.WhitelistingStateRevalidate", | 
|  | 91     page, checkWhitelisted(page) | 
|  | 92   ); | 
|  | 93 } | 
|  | 94 | 
|  | 95 let revalidating = false; | 
|  | 96 FilterNotifier.addListener((action, arg) => | 
|  | 97 { | 
|  | 98   switch (action) | 
|  | 99   { | 
|  | 100     case "subscription.added": | 
|  | 101       if (arg instanceof DownloadableSubscription && !arg.lastDownload) | 
|  | 102         break; | 
|  | 103     case "subscription.removed": | 
|  | 104     case "subscription.disabled": | 
|  | 105     case "subscription.updated": | 
|  | 106     case "filter.added": | 
|  | 107     case "filter.removed": | 
|  | 108     case "filter.disabled": | 
|  | 109     case "load": | 
|  | 110       if (!revalidating) | 
|  | 111       { | 
|  | 112         revalidating = true; | 
|  | 113         ext.pages.query({}, pages => | 
|  | 114         { | 
|  | 115           revalidating = false; | 
|  | 116           for (let page of pages) | 
|  | 117             revalidateWhitelistingState(page); | 
|  | 118         }); | 
|  | 119       } | 
|  | 120   } | 
|  | 121 }); | 
|  | 122 | 
|  | 123 ext.pages.onLoading.addListener(revalidateWhitelistingState); | 
|  | 124 | 
| 85 let getKey = | 125 let getKey = | 
| 86 /** | 126 /** | 
| 87  * Gets the public key, previously recorded for the given page | 127  * Gets the public key, previously recorded for the given page | 
| 88  * and frame, to be considered for the $sitekey filter option. | 128  * and frame, to be considered for the $sitekey filter option. | 
| 89  * | 129  * | 
| 90  * @param {Page}  page | 130  * @param {Page}  page | 
| 91  * @param {Frame} frame | 131  * @param {Frame} frame | 
| 92  * @return {string} | 132  * @return {string} | 
| 93  */ | 133  */ | 
| 94 exports.getKey = function(page, frame) | 134 exports.getKey = function(page, frame) | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 157 | 197 | 
| 158 port.on("filters.addKey", (message, sender) => | 198 port.on("filters.addKey", (message, sender) => | 
| 159 { | 199 { | 
| 160   processKey(message.token, sender.page, sender.frame); | 200   processKey(message.token, sender.page, sender.frame); | 
| 161 }); | 201 }); | 
| 162 | 202 | 
| 163 port.on("filters.isPageWhitelisted", (message, sender) => | 203 port.on("filters.isPageWhitelisted", (message, sender) => | 
| 164 { | 204 { | 
| 165   return !!checkWhitelisted(sender.page); | 205   return !!checkWhitelisted(sender.page); | 
| 166 }); | 206 }); | 
| OLD | NEW | 
|---|