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

Delta Between Two Patch Sets: lib/whitelisting.js

Issue 29338764: Issue 3842 - Split up the logic updating the icon and context menu (Closed)
Left Patch Set: Don't revalidate when multiple filter changes occur at the same time Created March 21, 2016, 10:44 a.m.
Right Patch Set: Rebased Created March 22, 2016, 8:26 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/icon.js ('k') | popup.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 ); 42 );
43 43
44 if (filter && devtools) 44 if (filter && devtools)
45 devtools.logWhitelistedDocument( 45 devtools.logWhitelistedDocument(
46 page, urlString, typeMask, docDomain, filter 46 page, urlString, typeMask, docDomain, filter
47 ); 47 );
48 48
49 return filter; 49 return filter;
50 } 50 }
51 51
52 let checkWhitelisted =
52 /** 53 /**
53 * Gets the active whitelisting filter for the document associated 54 * Gets the active whitelisting filter for the document associated
54 * with the given page/frame, or null if it's not whitelisted. 55 * with the given page/frame, or null if it's not whitelisted.
55 * 56 *
56 * @param {Page} page 57 * @param {Page} page
57 * @param {Frame} [frame] 58 * @param {Frame} [frame]
58 * @param {number} [typeMask=RegExpFilter.typeMap.DOCUMENT] 59 * @param {number} [typeMask=RegExpFilter.typeMap.DOCUMENT]
59 * @return {?WhitelistFilter} 60 * @return {?WhitelistFilter}
60 */ 61 */
61 exports.checkWhitelisted = function(page, frame, typeMask) 62 exports.checkWhitelisted = function(page, frame, typeMask)
(...skipping 17 matching lines...) Expand all
79 80
80 return filter; 81 return filter;
81 } 82 }
82 83
83 return match(page, page.url, typeMask); 84 return match(page, page.url, typeMask);
84 }; 85 };
85 86
86 function revalidateWhitelistingState(page) 87 function revalidateWhitelistingState(page)
87 { 88 {
88 FilterNotifier.triggerListeners( 89 FilterNotifier.triggerListeners(
89 "page.WhitelistingStateRevalidate", page, 90 "page.WhitelistingStateRevalidate",
90 match(page, page.url, RegExpFilter.typeMap.DOCUMENT) 91 page, checkWhitelisted(page)
91 ); 92 );
92 } 93 }
93 94
94 let revalidating = false; 95 let revalidating = false;
95 FilterNotifier.addListener((action, arg) => 96 FilterNotifier.addListener((action, arg) =>
96 { 97 {
97 switch (action) 98 switch (action)
98 { 99 {
99 case "subscription.added": 100 case "subscription.added":
100 if (arg instanceof DownloadableSubscription && !arg.lastDownload) 101 if (arg instanceof DownloadableSubscription && !arg.lastDownload)
101 break; 102 break;
102 case "load":
103 case "subscription.removed": 103 case "subscription.removed":
104 case "subscription.disabled": 104 case "subscription.disabled":
105 case "subscription.updated": 105 case "subscription.updated":
106 case "filter.added": 106 case "filter.added":
107 case "filter.removed": 107 case "filter.removed":
108 case "filter.disabled": 108 case "filter.disabled":
109 case "load":
109 if (!revalidating) 110 if (!revalidating)
110 { 111 {
111 revalidating = true; 112 revalidating = true;
112 ext.pages.query({}, pages => 113 ext.pages.query({}, pages =>
113 { 114 {
114 revalidating = false; 115 revalidating = false;
115 for (let page of pages) 116 for (let page of pages)
116 revalidateWhitelistingState(page); 117 revalidateWhitelistingState(page);
117 }); 118 });
118 } 119 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 key = key.replace(/=/g, ""); 192 key = key.replace(/=/g, "");
192 193
193 if (verifyKey(key, signature, frame.url)) 194 if (verifyKey(key, signature, frame.url))
194 recordKey(page, frame.url, key); 195 recordKey(page, frame.url, key);
195 }; 196 };
196 197
197 port.on("filters.addKey", (message, sender) => 198 port.on("filters.addKey", (message, sender) =>
198 { 199 {
199 processKey(message.token, sender.page, sender.frame); 200 processKey(message.token, sender.page, sender.frame);
200 }); 201 });
202
203 port.on("filters.isPageWhitelisted", (message, sender) =>
204 {
205 return !!checkWhitelisted(sender.page);
206 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld