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

Side by Side Diff: libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java

Issue 29405564: Issue 5121 - Use Acceptable Ads API in libadblockplus (Closed)
Patch Set: removed comment Created April 28, 2017, 6:20 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
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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 { 503 {
504 s.updateFilters(); 504 s.updateFilters();
505 } 505 }
506 finally 506 finally
507 { 507 {
508 s.dispose(); 508 s.dispose();
509 } 509 }
510 } 510 }
511 } 511 }
512 512
513 public boolean isAcceptableAdsEnabled()
514 {
515 final String url = getAcceptableAdsSubscriptionURL();
516 List<Subscription> subscriptions = this.filterEngine.getListedSubscriptions( );
517 try
518 {
519 for (Subscription eachSubscription : subscriptions)
520 {
521 JsValue jsUrl = eachSubscription.getProperty("url");
522 try
523 {
524 if (jsUrl.toString().equals(url))
525 {
526 return true;
527 }
528 }
529 finally
530 {
531 jsUrl.dispose();
532 }
533 }
534 return false;
535 }
536 finally
537 {
538 if (subscriptions != null)
539 {
540 for (Subscription eachSubscription : subscriptions)
541 {
542 eachSubscription.dispose();
543 }
544 }
545 }
546 }
547
548 public void setEnabled(final boolean enabled) 513 public void setEnabled(final boolean enabled)
549 { 514 {
550 this.enabled = enabled; 515 this.enabled = enabled;
551 } 516 }
552 517
553 public boolean isEnabled() 518 public boolean isEnabled()
554 { 519 {
555 return enabled; 520 return enabled;
556 } 521 }
557 522
558 public String getAcceptableAdsSubscriptionURL() 523 public String getAcceptableAdsSubscriptionURL()
559 { 524 {
560 JsValue jsPref = this.filterEngine.getPref("subscriptions_exceptionsurl"); 525 return filterEngine.getAcceptableAdsSubscriptionURL();
561 try 526 }
562 { 527
563 return jsPref.toString(); 528 public boolean isAcceptableAdsEnabled()
564 } 529 {
565 finally 530 return filterEngine.isAcceptableAdsEnabled();
566 {
567 jsPref.dispose();
568 }
569 } 531 }
570 532
571 public void setAcceptableAdsEnabled(final boolean enabled) 533 public void setAcceptableAdsEnabled(final boolean enabled)
572 { 534 {
573 final String url = getAcceptableAdsSubscriptionURL(); 535 filterEngine.setAcceptableAdsEnabled(enabled);
574 final Subscription sub = this.filterEngine.getSubscription(url);
575 if (sub != null)
576 {
577 try
578 {
579 if (enabled)
580 {
581 sub.addToList();
582 }
583 else
584 {
585 sub.removeFromList();
586 }
587 }
588 finally
589 {
590 sub.dispose();
591 }
592 }
593 } 536 }
594 537
595 public String getDocumentationLink() 538 public String getDocumentationLink()
596 { 539 {
597 JsValue jsPref = this.filterEngine.getPref("documentation_link"); 540 JsValue jsPref = this.filterEngine.getPref("documentation_link");
598 try 541 try
599 { 542 {
600 return jsPref.toString(); 543 return jsPref.toString();
601 } 544 }
602 finally 545 finally
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 public void setWhitelistedDomains(List<String> domains) 670 public void setWhitelistedDomains(List<String> domains)
728 { 671 {
729 this.whitelistedDomains = domains; 672 this.whitelistedDomains = domains;
730 } 673 }
731 674
732 public List<String> getWhitelistedDomains() 675 public List<String> getWhitelistedDomains()
733 { 676 {
734 return whitelistedDomains; 677 return whitelistedDomains;
735 } 678 }
736 } 679 }
OLDNEW

Powered by Google App Engine
This is Rietveld