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

Side by Side Diff: background.js

Issue 29333819: Issue 2375 - Implement "Blocking lists" section in new options page (Closed)
Patch Set: Small fixes and fix for Object.defineProperty Created Feb. 3, 2016, 2:02 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 | « no previous file | i18n.js » ('j') | options.js » ('J')
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-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 18 matching lines...) Expand all
29 data[parts[0]] = decodeURIComponent(parts[1]); 29 data[parts[0]] = decodeURIComponent(parts[1]);
30 } 30 }
31 } 31 }
32 } 32 }
33 33
34 var params = { 34 var params = {
35 blockedURLs: "", 35 blockedURLs: "",
36 seenDataCorruption: false, 36 seenDataCorruption: false,
37 filterlistsReinitialized: false, 37 filterlistsReinitialized: false,
38 addSubscription: false, 38 addSubscription: false,
39 filterError: false 39 filterError: false,
40 downloadStatus: "synchronize_ok",
41 lastDownload: 1234
40 }; 42 };
41 updateFromURL(params); 43 updateFromURL(params);
42 44
43 var modules = {}; 45 var modules = {};
44 global.require = function(module) 46 global.require = function(module)
45 { 47 {
46 return modules[module]; 48 return modules[module];
47 }; 49 };
48 50
49 modules.utils = { 51 modules.utils = {
(...skipping 14 matching lines...) Expand all
64 "subscriptions_exceptionsurl": "https://easylist-downloads.adblockplus.org /exceptionrules.txt" 66 "subscriptions_exceptionsurl": "https://easylist-downloads.adblockplus.org /exceptionrules.txt"
65 } 67 }
66 }; 68 };
67 69
68 modules.subscriptionClasses = { 70 modules.subscriptionClasses = {
69 Subscription: function(url) 71 Subscription: function(url)
70 { 72 {
71 this.url = url; 73 this.url = url;
72 this.title = "Subscription " + url; 74 this.title = "Subscription " + url;
73 this.disabled = false; 75 this.disabled = false;
74 this.lastDownload = 1234; 76 this._lastDownload = params.lastDownload;
77 this.homepage = "https://easylist.adblockplus.org/";
78 this.downloadStatus = params.downloadStatus;
Thomas Greiner 2016/02/03 14:50:14 Please document those newly introduced parameters
saroyanm 2016/02/03 17:43:11 Done.
75 }, 79 },
76 80
77 SpecialSubscription: function(url) 81 SpecialSubscription: function(url)
78 { 82 {
79 this.url = url; 83 this.url = url;
80 this.disabled = false; 84 this.disabled = false;
81 this.filters = knownFilters.slice(); 85 this.filters = knownFilters.slice();
82 } 86 }
83 }; 87 };
84 modules.subscriptionClasses.Subscription.fromURL = function(url) 88 modules.subscriptionClasses.Subscription.fromURL = function(url)
85 { 89 {
90 if (url in knownSubscriptions)
91 return knownSubscriptions[url];
92
86 if (/^https?:\/\//.test(url)) 93 if (/^https?:\/\//.test(url))
87 return new modules.subscriptionClasses.Subscription(url); 94 return new modules.subscriptionClasses.Subscription(url);
88 else 95 else
89 return new modules.subscriptionClasses.SpecialSubscription(url); 96 return new modules.subscriptionClasses.SpecialSubscription(url);
90 }; 97 };
91 modules.subscriptionClasses.DownloadableSubscription = modules.subscriptionCla sses.Subscription; 98 modules.subscriptionClasses.DownloadableSubscription = modules.subscriptionCla sses.Subscription;
92 99
100 modules.subscriptionClasses.Subscription.prototype =
101 {
102 get lastDownload()
103 {
104 return this._lastDownload;
105 },
106 set lastDownload(value)
107 {
108 this._lastDownload = value;
109 modules.filterNotifier.FilterNotifier.triggerListeners("subscription.lastD ownload", this);
110 }
111 };
112
93 modules.filterStorage = { 113 modules.filterStorage = {
94 FilterStorage: { 114 FilterStorage: {
95 get subscriptions() 115 get subscriptions()
96 { 116 {
97 var subscriptions = []; 117 var subscriptions = [];
98 for (var url in modules.filterStorage.FilterStorage.knownSubscriptions) 118 for (var url in modules.filterStorage.FilterStorage.knownSubscriptions)
99 subscriptions.push(modules.filterStorage.FilterStorage.knownSubscripti ons[url]); 119 subscriptions.push(modules.filterStorage.FilterStorage.knownSubscripti ons[url]);
100 return subscriptions; 120 return subscriptions;
101 }, 121 },
102 122
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 return { 197 return {
178 filters: text.split("\n") 198 filters: text.split("\n")
179 .filter(function(filter) {return !!filter;}) 199 .filter(function(filter) {return !!filter;})
180 .map(modules.filterClasses.Filter.fromText), 200 .map(modules.filterClasses.Filter.fromText),
181 errors: [] 201 errors: []
182 }; 202 };
183 } 203 }
184 }; 204 };
185 205
186 modules.synchronizer = { 206 modules.synchronizer = {
187 Synchronizer: {} 207 Synchronizer: {
208 execute: function(subscription, manual)
209 {
210 subscription.lastDownload = Date.now() / 1000;
211 }
212 }
188 }; 213 };
189 214
190 modules.matcher = { 215 modules.matcher = {
191 defaultMatcher: { 216 defaultMatcher: {
192 matchesAny: function(url, requestType, docDomain, thirdParty) 217 matchesAny: function(url, requestType, docDomain, thirdParty)
193 { 218 {
194 var blocked = params.blockedURLs.split(","); 219 var blocked = params.blockedURLs.split(",");
195 if (blocked.indexOf(url) >= 0) 220 if (blocked.indexOf(url) >= 0)
196 return new modules.filterClasses.BlockingFilter(); 221 return new modules.filterClasses.BlockingFilter();
197 else 222 else
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 type: "message", 324 type: "message",
300 payload: { 325 payload: {
301 title: "Custom subscription", 326 title: "Custom subscription",
302 url: "http://example.com/custom.txt", 327 url: "http://example.com/custom.txt",
303 type: "add-subscription" 328 type: "add-subscription"
304 } 329 }
305 }, "*"); 330 }, "*");
306 }, 1000); 331 }, 1000);
307 } 332 }
308 })(this); 333 })(this);
OLDNEW
« no previous file with comments | « no previous file | i18n.js » ('j') | options.js » ('J')

Powered by Google App Engine
This is Rietveld