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

Delta Between Two Patch Sets: background.js

Issue 29333819: Issue 2375 - Implement "Blocking lists" section in new options page (Closed)
Left Patch Set: Small fixes and improved download messages for filter lists Created Feb. 3, 2016, 5:41 p.m.
Right Patch Set: Fixed the progress indicator and small fixes Created Feb. 4, 2016, 5:43 p.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 | « README.md ('k') | i18n.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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 "subscriptions_exceptionsurl": "https://easylist-downloads.adblockplus.org /exceptionrules.txt" 65 "subscriptions_exceptionsurl": "https://easylist-downloads.adblockplus.org /exceptionrules.txt"
66 } 66 }
67 }; 67 };
68 68
69 modules.subscriptionClasses = { 69 modules.subscriptionClasses = {
70 Subscription: function(url) 70 Subscription: function(url)
71 { 71 {
72 this.url = url; 72 this.url = url;
73 this.title = "Subscription " + url; 73 this.title = "Subscription " + url;
74 this.disabled = false; 74 this.disabled = false;
75 this._lastDownload = 0; 75 this._lastDownload = 1234;
76 this.homepage = "https://easylist.adblockplus.org/"; 76 this.homepage = "https://easylist.adblockplus.org/";
77 this.downloadStatus = params.downloadStatus; 77 this.downloadStatus = params.downloadStatus;
78 }, 78 },
79 79
80 SpecialSubscription: function(url) 80 SpecialSubscription: function(url)
81 { 81 {
82 this.url = url; 82 this.url = url;
83 this.disabled = false; 83 this.disabled = false;
84 this.filters = knownFilters.slice(); 84 this.filters = knownFilters.slice();
85 } 85 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 filters: text.split("\n") 197 filters: text.split("\n")
198 .filter(function(filter) {return !!filter;}) 198 .filter(function(filter) {return !!filter;})
199 .map(modules.filterClasses.Filter.fromText), 199 .map(modules.filterClasses.Filter.fromText),
200 errors: [] 200 errors: []
201 }; 201 };
202 } 202 }
203 }; 203 };
204 204
205 modules.synchronizer = { 205 modules.synchronizer = {
206 Synchronizer: { 206 Synchronizer: {
207 downloading: false,
Thomas Greiner 2016/02/04 20:23:46 Detail: Since this is a "private" property I'd sug
207 execute: function(subscription, manual) 208 execute: function(subscription, manual)
208 { 209 {
209 subscription.lastDownload = 0; 210 subscription.lastDownload = 0;
211 modules.synchronizer.Synchronizer.downloading = true;
210 setTimeout(function() 212 setTimeout(function()
211 { 213 {
214 modules.synchronizer.Synchronizer.downloading = false;
212 subscription.lastDownload = Date.now() / 1000; 215 subscription.lastDownload = Date.now() / 1000;
213 }, 500); 216 }, 500);
217 },
218 isExecuting: function(url)
219 {
220 return modules.synchronizer.Synchronizer.downloading;
214 } 221 }
215 } 222 }
216 }; 223 };
217 224
218 modules.matcher = { 225 modules.matcher = {
219 defaultMatcher: { 226 defaultMatcher: {
220 matchesAny: function(url, requestType, docDomain, thirdParty) 227 matchesAny: function(url, requestType, docDomain, thirdParty)
221 { 228 {
222 var blocked = params.blockedURLs.split(","); 229 var blocked = params.blockedURLs.split(",");
223 if (blocked.indexOf(url) >= 0) 230 if (blocked.indexOf(url) >= 0)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 var knownFilters = filters.map(modules.filterClasses.Filter.fromText); 311 var knownFilters = filters.map(modules.filterClasses.Filter.fromText);
305 312
306 var subscriptions = [ 313 var subscriptions = [
307 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", 314 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt",
308 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", 315 "https://easylist-downloads.adblockplus.org/exceptionrules.txt",
309 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", 316 "https://easylist-downloads.adblockplus.org/fanboy-social.txt",
310 "~user~786254" 317 "~user~786254"
311 ]; 318 ];
312 var knownSubscriptions = Object.create(null); 319 var knownSubscriptions = Object.create(null);
313 for (var subscriptionUrl of subscriptions) 320 for (var subscriptionUrl of subscriptions)
314 {
315 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti on.fromURL(subscriptionUrl); 321 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti on.fromURL(subscriptionUrl);
316 knownSubscriptions[subscriptionUrl].lastDownload = 1234; 322
Thomas Greiner 2016/02/04 15:28:16 This will trigger the "subscriptions.lastDownload"
saroyanm 2016/02/04 17:50:06 Done.
Thomas Greiner 2016/02/04 20:23:45 Detail: This empty line has been added without tou
317 }
318 var customSubscription = knownSubscriptions["~user~786254"]; 323 var customSubscription = knownSubscriptions["~user~786254"];
319 324
320 global.seenDataCorruption = params.seenDataCorruption; 325 global.seenDataCorruption = params.seenDataCorruption;
321 global.filterlistsReinitialized = params.filterlistsReinitialized; 326 global.filterlistsReinitialized = params.filterlistsReinitialized;
322 327
323 if (params.addSubscription) 328 if (params.addSubscription)
324 { 329 {
325 // We don't know how long it will take for the page to fully load 330 // We don't know how long it will take for the page to fully load
326 // so we'll post the message after one second 331 // so we'll post the message after one second
327 setTimeout(function() 332 setTimeout(function()
328 { 333 {
329 window.postMessage({ 334 window.postMessage({
330 type: "message", 335 type: "message",
331 payload: { 336 payload: {
332 title: "Custom subscription", 337 title: "Custom subscription",
333 url: "http://example.com/custom.txt", 338 url: "http://example.com/custom.txt",
334 type: "add-subscription" 339 type: "add-subscription"
335 } 340 }
336 }, "*"); 341 }, "*");
337 }, 1000); 342 }, 1000);
338 } 343 }
339 })(this); 344 })(this);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld