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

Delta Between Two Patch Sets: messageResponder.js

Issue 4864767881641984: Issue 1528 - Implemented backend for general tab of new options page (Closed)
Left Patch Set: Added addSubscription querystring parameter for testing Created Jan. 30, 2015, 6:06 p.m.
Right Patch Set: Created June 8, 2015, 4:09 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
« background.js ('K') | « ext/background.js ('k') | no next file » | 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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 (function(global) 18 (function(global)
19 { 19 {
20 if (!global.ext) 20 if (!global.ext)
21 global.ext = require("ext_background"); 21 global.ext = require("ext_background");
22 22
23 var Prefs = require("prefs").Prefs; 23 var Prefs = require("prefs").Prefs;
24 var Utils = require("utils").Utils; 24 var Utils = require("utils").Utils;
25 var FilterStorage = require("filterStorage").FilterStorage; 25 var FilterStorage = require("filterStorage").FilterStorage;
26 var FilterNotifier = require("filterNotifier").FilterNotifier; 26 var FilterNotifier = require("filterNotifier").FilterNotifier;
27 var defaultMatcher = require("matcher").defaultMatcher; 27 var defaultMatcher = require("matcher").defaultMatcher;
28 28
29 var filterClasses = require("filterClasses"); 29 var filterClasses = require("filterClasses");
Felix Dahlke 2015/05/28 20:35:41 Nit: adblockpluschrome typically uses `with` for t
Thomas Greiner 2015/06/08 16:12:43 "Using with is not recommended, and is forbidden i
Felix Dahlke 2015/06/09 13:04:47 Oh, I wasn't aware that with isn't working in stri
30 var Filter = filterClasses.Filter; 30 var Filter = filterClasses.Filter;
31 var BlockingFilter = filterClasses.BlockingFilter; 31 var BlockingFilter = filterClasses.BlockingFilter;
32 var Synchronizer = require("synchronizer").Synchronizer; 32 var Synchronizer = require("synchronizer").Synchronizer;
33 33
34 var subscriptionClasses = require("subscriptionClasses"); 34 var subscriptionClasses = require("subscriptionClasses");
35 var Subscription = subscriptionClasses.Subscription; 35 var Subscription = subscriptionClasses.Subscription;
36 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription; 36 var DownloadableSubscription = subscriptionClasses.DownloadableSubscription;
37 var SpecialSubscription = subscriptionClasses.SpecialSubscription; 37 var SpecialSubscription = subscriptionClasses.SpecialSubscription;
38 38
39 function convertObject(keys, obj) 39 function convertObject(keys, obj)
40 { 40 {
41 var result = {}; 41 var result = {};
42 for (var i = 0; i < keys.length; i++) 42 for (var i = 0; i < keys.length; i++)
43 result[keys[i]] = obj[keys[i]]; 43 result[keys[i]] = obj[keys[i]];
44 return result; 44 return result;
45 } 45 }
46 46
47 var convertSubscription = convertObject.bind(null, ["disabled", "downloadStatu s", 47 var convertSubscription = convertObject.bind(null, ["disabled",
Felix Dahlke 2015/05/28 20:35:41 Nit: We might as well go for 80 columns if we wrap
Thomas Greiner 2015/06/08 16:12:43 Done.
48 "homepage", "lastSuccess", "title", "url"]); 48 "downloadStatus", "homepage", "lastSuccess", "title", "url"]);
49 var convertFilter = convertObject.bind(null, ["text"]); 49 var convertFilter = convertObject.bind(null, ["text"]);
50 50
51 var changeListeners = null; 51 var changeListeners = null;
52 var messageTypes = { 52 var messageTypes = {
53 "app": "app.listen", 53 "app": "app.listen",
54 "filter": "filters.listen", 54 "filter": "filters.listen",
55 "subscription": "subscriptions.listen" 55 "subscription": "subscriptions.listen"
56 }; 56 };
57 57
58 function onFilterChange(action) 58 function onFilterChange(action)
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 delete listenerFilters.app; 170 delete listenerFilters.app;
171 break; 171 break;
172 case "app.open": 172 case "app.open":
173 if (message.what == "options") 173 if (message.what == "options")
174 ext.showOptions(); 174 ext.showOptions();
175 break; 175 break;
176 case "filters.add": 176 case "filters.add":
177 var filter = Filter.fromText(message.text); 177 var filter = Filter.fromText(message.text);
178 FilterStorage.addFilter(filter); 178 FilterStorage.addFilter(filter);
179 break; 179 break;
180 case "filters.blocked": 180 case "filters.blocked":
Felix Dahlke 2015/05/28 20:35:41 Nit: `filters.blocking` maybe?
Thomas Greiner 2015/06/08 16:12:43 This part was added by Wladimir and would require
Felix Dahlke 2015/06/09 13:04:47 Na, let's leave it alone then, not really worth ch
181 var filter = defaultMatcher.matchesAny(message.url, message.requestType, 181 var filter = defaultMatcher.matchesAny(message.url, message.requestType,
182 message.docDomain, message.thirdParty); 182 message.docDomain, message.thirdParty);
183 callback(filter instanceof BlockingFilter); 183 callback(filter instanceof BlockingFilter);
184 break; 184 break;
185 case "filters.get": 185 case "filters.get":
186 var subscription = Subscription.fromURL(message.subscriptionUrl); 186 var subscription = Subscription.fromURL(message.subscriptionUrl);
187 if (!subscription) 187 if (!subscription)
188 { 188 {
189 callback([]); 189 callback([]);
190 break; 190 break;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 subscription.title = message.title; 264 subscription.title = message.title;
265 subscription.homepage = message.homepage; 265 subscription.homepage = message.homepage;
266 FilterStorage.addSubscription(subscription); 266 FilterStorage.addSubscription(subscription);
267 if (!subscription.lastDownload) 267 if (!subscription.lastDownload)
268 Synchronizer.execute(subscription); 268 Synchronizer.execute(subscription);
269 } 269 }
270 break; 270 break;
271 } 271 }
272 }); 272 });
273 })(this); 273 })(this);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld