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

Delta Between Two Patch Sets: messageResponder.js

Issue 29338734: Issue 3839 - Adapt for Prefs event changes (Closed)
Left Patch Set: Cleaned up onFilterChange() Created March 22, 2016, 7:19 a.m.
Right Patch Set: Addresed comments Created March 22, 2016, 2:22 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 | « 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-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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 function onFilterChange(action) 82 function onFilterChange(action)
83 { 83 {
84 var type; 84 var type;
85 if (action == "load") 85 if (action == "load")
86 { 86 {
87 type = "filter"; 87 type = "filter";
88 action = "loaded"; 88 action = "loaded";
89 } 89 }
90 else 90 else
91 { 91 {
92 var parts = action.split(".", 2); 92 var parts = action.split(".");
Sebastian Noack 2016/03/22 14:24:10 I just realized that the second argument is redund
93 type = parts[0]; 93 type = parts[0];
94 action = parts[1]; 94 action = parts[1];
95 } 95 }
96 96
97 if (!(type in messageTypes)) 97 if (!(type in messageTypes))
98 return; 98 return;
99 99
100 var args = []; 100 var args = [];
101 for (var i = 1; i < arguments.length; i++) 101 for (var i = 1; i < arguments.length; i++)
Sebastian Noack 2016/03/22 07:29:56 Note that passing arguments to other functions wil
102 { 102 {
103 var arg = arguments[i]; 103 var arg = arguments[i];
104 if (arg instanceof Subscription) 104 if (arg instanceof Subscription)
105 args.push(convertSubscription(arg)); 105 args.push(convertSubscription(arg));
106 else if (arg instanceof Filter) 106 else if (arg instanceof Filter)
107 args.push(convertFilter(arg)); 107 args.push(convertFilter(arg));
108 else 108 else
109 args.push(arg); 109 args.push(arg);
110 } 110 }
111 111
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 if (!(filter.text in seenFilter)) 275 if (!(filter.text in seenFilter))
276 FilterStorage.removeFilter(filter); 276 FilterStorage.removeFilter(filter);
277 } 277 }
278 } 278 }
279 break; 279 break;
280 case "filters.listen": 280 case "filters.listen":
281 var listenerFilters = getListenerFilters(sender.page); 281 var listenerFilters = getListenerFilters(sender.page);
282 if (message.filter) 282 if (message.filter)
283 { 283 {
284 FilterNotifier.addListener(onFilterChange); 284 FilterNotifier.addListener(onFilterChange);
Sebastian Noack 2016/03/22 07:29:56 Since FilterNotifier.addListener() only adds the l
285 listenerFilters.filter = message.filter; 285 listenerFilters.filter = message.filter;
286 } 286 }
287 else 287 else
288 delete listenerFilters.filter; 288 delete listenerFilters.filter;
289 break; 289 break;
290 case "filters.remove": 290 case "filters.remove":
291 var filter = Filter.fromText(message.text); 291 var filter = Filter.fromText(message.text);
292 var subscription = null; 292 var subscription = null;
293 if (message.subscriptionUrl) 293 if (message.subscriptionUrl)
294 subscription = Subscription.fromURL(message.subscriptionUrl); 294 subscription = Subscription.fromURL(message.subscriptionUrl);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 var subscription = Subscription.fromURL(message.url); 331 var subscription = Subscription.fromURL(message.url);
332 if ("title" in message) 332 if ("title" in message)
333 subscription.title = message.title; 333 subscription.title = message.title;
334 if ("homepage" in message) 334 if ("homepage" in message)
335 subscription.homepage = message.homepage; 335 subscription.homepage = message.homepage;
336 336
337 if (message.confirm) 337 if (message.confirm)
338 { 338 {
339 ext.showOptions(function() 339 ext.showOptions(function()
340 { 340 {
341 sendMessage("app", "addSubscription", [convertSubscription(subscript ion)]); 341 sendMessage("app", "addSubscription", [convertSubscription(subscript ion)]);
Sebastian Noack 2016/03/22 07:29:56 Sorry for the unrelated change, but it seems inapp
342 }); 342 });
343 } 343 }
344 else 344 else
345 { 345 {
346 subscription.disabled = false; 346 subscription.disabled = false;
347 FilterStorage.addSubscription(subscription); 347 FilterStorage.addSubscription(subscription);
348 348
349 if (subscription instanceof DownloadableSubscription && !subscription. lastDownload) 349 if (subscription instanceof DownloadableSubscription && !subscription. lastDownload)
350 Synchronizer.execute(subscription); 350 Synchronizer.execute(subscription);
351 } 351 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 if (subscription instanceof DownloadableSubscription) 410 if (subscription instanceof DownloadableSubscription)
411 Synchronizer.execute(subscription, true); 411 Synchronizer.execute(subscription, true);
412 } 412 }
413 break; 413 break;
414 case "subscriptions.isDownloading": 414 case "subscriptions.isDownloading":
415 callback(Synchronizer.isExecuting(message.url)); 415 callback(Synchronizer.isExecuting(message.url));
416 break; 416 break;
417 } 417 }
418 }); 418 });
419 })(this); 419 })(this);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld