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

Side by Side Diff: lib/filterListener.js

Issue 29870577: Issue 6916 - Encapsulate filter subscriptions (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Add subscriptionCount property Created Sept. 1, 2018, 2:16 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/filterClasses.js ('k') | lib/filterStorage.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 * if necessary. 136 * if necessary.
137 * @param {Filter} filter filter that has been added 137 * @param {Filter} filter filter that has been added
138 */ 138 */
139 function addFilter(filter) 139 function addFilter(filter)
140 { 140 {
141 if (!(filter instanceof ActiveFilter) || filter.disabled) 141 if (!(filter instanceof ActiveFilter) || filter.disabled)
142 return; 142 return;
143 143
144 let hasEnabled = false; 144 let hasEnabled = false;
145 let allowSnippets = false; 145 let allowSnippets = false;
146 for (let subscription of filter.subscriptions) 146 for (let subscription of filter.subscriptions())
147 { 147 {
148 if (!subscription.disabled) 148 if (!subscription.disabled)
149 { 149 {
150 hasEnabled = true; 150 hasEnabled = true;
151 151
152 // Allow snippets to be executed only by the circumvention lists or the 152 // Allow snippets to be executed only by the circumvention lists or the
153 // user's own filters. 153 // user's own filters.
154 if (subscription.type == "circumvention" || 154 if (subscription.type == "circumvention" ||
155 subscription instanceof SpecialSubscription) 155 subscription instanceof SpecialSubscription)
156 { 156 {
(...skipping 26 matching lines...) Expand all
183 * @param {Filter} filter filter that has been removed 183 * @param {Filter} filter filter that has been removed
184 */ 184 */
185 function removeFilter(filter) 185 function removeFilter(filter)
186 { 186 {
187 if (!(filter instanceof ActiveFilter)) 187 if (!(filter instanceof ActiveFilter))
188 return; 188 return;
189 189
190 if (!filter.disabled) 190 if (!filter.disabled)
191 { 191 {
192 let hasEnabled = false; 192 let hasEnabled = false;
193 for (let subscription of filter.subscriptions) 193 for (let subscription of filter.subscriptions())
194 { 194 {
195 if (!subscription.disabled) 195 if (!subscription.disabled)
196 { 196 {
197 hasEnabled = true; 197 hasEnabled = true;
198 break; 198 break;
199 } 199 }
200 } 200 }
201 if (hasEnabled) 201 if (hasEnabled)
202 return; 202 return;
203 } 203 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 { 340 {
341 if (!subscription.disabled) 341 if (!subscription.disabled)
342 addFilters(subscription.filters); 342 addFilters(subscription.filters);
343 } 343 }
344 } 344 }
345 345
346 function onSave() 346 function onSave()
347 { 347 {
348 isDirty = 0; 348 isDirty = 0;
349 } 349 }
OLDNEW
« no previous file with comments | « lib/filterClasses.js ('k') | lib/filterStorage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld