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

Side by Side Diff: background.js

Issue 5655474749833216: Issue 2658 - Got rid of try..catch for filter validation (Closed)
Patch Set: Improved comments Created June 8, 2015, 11:59 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 | « no previous file | lib/filterValidation.js » ('j') | 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-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
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 case "get-domain-enabled-state": 353 case "get-domain-enabled-state":
354 // Returns whether this domain is in the exclusion list. 354 // Returns whether this domain is in the exclusion list.
355 // The browser action popup asks us this. 355 // The browser action popup asks us this.
356 if(sender.page) 356 if(sender.page)
357 { 357 {
358 sendResponse({enabled: !isPageWhitelisted(sender.page)}); 358 sendResponse({enabled: !isPageWhitelisted(sender.page)});
359 return; 359 return;
360 } 360 }
361 break; 361 break;
362 case "add-filters": 362 case "add-filters":
363 var filters; 363 var result = parseFilters(msg.text);
364 try 364
365 if (result.error)
365 { 366 {
366 filters = parseFilters(msg.text); 367 sendResponse({status: "invalid", error: result.error});
367 }
368 catch (error)
369 {
370 sendResponse({status: "invalid", error: error});
371 break; 368 break;
372 } 369 }
373 370
374 for (var i = 0; i < filters.length; i++) 371 for (var i = 0; i < result.filters.length; i++)
375 FilterStorage.addFilter(filters[i]); 372 FilterStorage.addFilter(result.filters[i]);
376 373
377 sendResponse({status: "ok"}); 374 sendResponse({status: "ok"});
378 break; 375 break;
379 case "add-subscription": 376 case "add-subscription":
380 ext.showOptions(function(page) 377 ext.showOptions(function(page)
381 { 378 {
382 page.sendMessage(msg); 379 page.sendMessage(msg);
383 }); 380 });
384 break; 381 break;
385 case "add-sitekey": 382 case "add-sitekey":
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 break; 414 break;
418 } 415 }
419 }); 416 });
420 417
421 // update icon when page changes location 418 // update icon when page changes location
422 ext.pages.onLoading.addListener(function(page) 419 ext.pages.onLoading.addListener(function(page)
423 { 420 {
424 page.sendMessage({type: "clickhide-deactivate"}); 421 page.sendMessage({type: "clickhide-deactivate"});
425 refreshIconAndContextMenu(page); 422 refreshIconAndContextMenu(page);
426 }); 423 });
OLDNEW
« no previous file with comments | « no previous file | lib/filterValidation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld