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

Side by Side Diff: lib/subscriptionInit.js

Issue 29827646: Issue 6783 - opt-in to anti circumvention filter list on upgrade (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created July 12, 2018, 2:24 a.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/prefs.js ('k') | no next file » | 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 { 204 {
205 let antiAdblockSubscription = Subscription.fromURL( 205 let antiAdblockSubscription = Subscription.fromURL(
206 Prefs.subscriptions_antiadblockurl 206 Prefs.subscriptions_antiadblockurl
207 ); 207 );
208 antiAdblockSubscription.disabled = true; 208 antiAdblockSubscription.disabled = true;
209 subscriptions.push(antiAdblockSubscription); 209 subscriptions.push(antiAdblockSubscription);
210 } 210 }
211 } 211 }
212 212
213 // Add default ad blocking subscription (e.g. EasyList) 213 // Add default ad blocking subscription (e.g. EasyList)
214 if (shouldAddDefaultSubscription()) 214 // Ensure the Anti Circumvention is added on upgrade.
215 if (shouldAddDefaultSubscription() || !Prefs.subscriptions_checkedanticv)
Manish Jethani 2018/07/12 07:54:27 But this will add an "ads" list as well. Shouldn't
kzar 2018/07/12 10:07:59 Yea, this logic doesn't look right. Perhaps split
hub 2018/07/12 17:14:09 This came to my mind before falling asleep. I'll f
215 { 216 {
216 return fetch("subscriptions.xml") 217 return fetch("subscriptions.xml")
217 .then(response => response.text()) 218 .then(response => response.text())
218 .then(text => 219 .then(text =>
219 { 220 {
220 let doc = new DOMParser().parseFromString(text, "application/xml"); 221 let doc = new DOMParser().parseFromString(text, "application/xml");
221 let nodes = doc.getElementsByTagName("subscription"); 222 let nodes = doc.getElementsByTagName("subscription");
222 223
223 let defaultSubscriptions = chooseFilterSubscriptions(nodes); 224 let defaultSubscriptions = chooseFilterSubscriptions(nodes);
224 if (defaultSubscriptions) 225 if (defaultSubscriptions)
225 { 226 {
226 for (let name in defaultSubscriptions) 227 for (let name in defaultSubscriptions)
227 { 228 {
228 let node = defaultSubscriptions[name]; 229 let node = defaultSubscriptions[name];
229 if (!node) 230 if (!node)
230 continue; 231 continue;
231 232
232 let url = node.getAttribute("url"); 233 let url = node.getAttribute("url");
233 if (url) 234 if (url)
234 { 235 {
235 let subscription = Subscription.fromURL(url); 236 let subscription = Subscription.fromURL(url);
236 subscription.disabled = false; 237 subscription.disabled = false;
237 subscription.title = node.getAttribute("title"); 238 subscription.title = node.getAttribute("title");
238 subscription.homepage = node.getAttribute("homepage"); 239 subscription.homepage = node.getAttribute("homepage");
239 subscription.type = node.getAttribute("type"); 240 subscription.type = node.getAttribute("type");
240 subscriptions.push(subscription); 241 subscriptions.push(subscription);
242 if (subscription.type == "circumvention")
243 Prefs.subscriptions_checkedanticv = true;
241 } 244 }
242 } 245 }
243 } 246 }
244 247
245 return subscriptions; 248 return subscriptions;
246 }); 249 });
247 } 250 }
248 251
249 return subscriptions; 252 return subscriptions;
250 } 253 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 * 327 *
325 * @param {function} callback 328 * @param {function} callback
326 */ 329 */
327 exports.setSubscriptionsCallback = callback => 330 exports.setSubscriptionsCallback = callback =>
328 { 331 {
329 subscriptionsCallback = callback; 332 subscriptionsCallback = callback;
330 }; 333 };
331 334
332 // Exports for tests only 335 // Exports for tests only
333 exports.chooseFilterSubscriptions = chooseFilterSubscriptions; 336 exports.chooseFilterSubscriptions = chooseFilterSubscriptions;
OLDNEW
« no previous file with comments | « lib/prefs.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld