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

Unified Diff: lib/whitelisting.js

Issue 29532767: Issue 5593 - Use messaging in popup for prefs, whitelisting, and stats (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Revert one more instance of ext.pages.open Created Sept. 27, 2017, 9:40 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/stats.js ('k') | notification.js » ('j') | stats.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/whitelisting.js
===================================================================
--- a/lib/whitelisting.js
+++ b/lib/whitelisting.js
@@ -15,18 +15,19 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
/** @module whitelisting */
"use strict";
const {defaultMatcher} = require("matcher");
-const {RegExpFilter} = require("filterClasses");
+const {Filter, RegExpFilter} = require("filterClasses");
const {FilterNotifier} = require("filterNotifier");
+const {FilterStorage} = require("filterStorage");
const {stringifyURL, getDecodedHostname,
extractHostFromFrame, isThirdParty} = require("url");
const {port} = require("messaging");
const devtools = require("devtools");
const {verifySignature} = require("rsa");
let sitekeys = new ext.PageMap();
@@ -82,16 +83,51 @@
}
return filter;
}
return match(page, page.url, typeMask);
};
+port.on("filters.isWhitelisted", message =>
+{
+ return !!checkWhitelisted(new ext.Page(message.tab));
+});
+
+port.on("filters.whitelist", message =>
+{
+ let page = new ext.Page(message.tab);
+ let host = getDecodedHostname(page.url).replace(/^www\./, "");
+ let filter = Filter.fromText("@@||" + host + "^$document");
+ if (filter.subscriptions.length && filter.disabled)
+ {
+ filter.disabled = false;
+ }
+ else
+ {
+ filter.disabled = false;
+ FilterStorage.addFilter(filter);
+ }
+});
+
+port.on("filters.unwhitelist", message =>
+{
+ let page = new ext.Page(message.tab);
+ // Remove any exception rules applying to this URL
+ let filter = checkWhitelisted(page);
+ while (filter)
+ {
+ FilterStorage.removeFilter(filter);
+ if (filter.subscriptions.length)
+ filter.disabled = true;
+ filter = checkWhitelisted(page);
+ }
+});
+
function revalidateWhitelistingState(page)
{
FilterNotifier.emit(
"page.WhitelistingStateRevalidate",
page, checkWhitelisted(page)
);
}
« no previous file with comments | « lib/stats.js ('k') | notification.js » ('j') | stats.js » ('J')

Powered by Google App Engine
This is Rietveld