Index: adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/engine/Engine.java |
=================================================================== |
--- a/adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/engine/Engine.java |
+++ b/adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/engine/Engine.java |
@@ -251,16 +251,31 @@ public final class Engine |
public void subscriptionStateChanged() |
{ |
if (this.subscriptionUpdateCallback != null) |
{ |
subscriptionUpdateCallback.subscriptionUpdatedApplied(); |
} |
} |
+ public void createAndAddSubscriptionFromUrl(final String url, final SubscriptionAddedCallback callback) throws IOException |
anton
2017/10/10 08:15:06
the line seems to be too long (>100)
|
+ { |
+ final Subscription sub = Subscription.create(url); |
+ sub.putMeta(Subscription.KEY_TITLE, url); |
+ sub.setEnabled(true); |
+ subscriptions.add(sub); |
+ subscriptions.persistSubscription(sub); |
+ callback.subscriptionAdded(); |
+ } |
+ |
+ public void removeSubscriptionById(final String subscriptionId) |
+ { |
+ subscriptions.remove(subscriptionId); |
+ } |
+ |
void downloadFinished(final String id, final int responseCode, final String response, |
final Map<String, String> headers) |
{ |
this.engineEvents.add(new DownloadFinishedEvent(id, responseCode, response, headers)); |
} |
private void createAndWriteFile() |
{ |
@@ -606,16 +621,21 @@ public final class Engine |
else |
{ |
sb.append("4%2B"); // "4+" URL encoded |
} |
return new URL(sb.toString()); |
} |
+ public boolean isAcceptableAdsUrl(final SubscriptionInfo subscriptionInfo) |
+ { |
+ return getPrefsDefault(SUBSCRIPTIONS_EXCEPTIONSURL).equals(subscriptionInfo.getUrl()); |
+ } |
+ |
private static class EventHandler implements Runnable |
{ |
private static final String TAG = EventHandler.class.getSimpleName(); |
private final Engine engine; |
public EventHandler(final Engine engine) |
{ |
this.engine = engine; |
@@ -782,9 +802,14 @@ public final class Engine |
this.downloader.connectivityChanged(); |
} |
public interface SubscriptionUpdateCallback |
{ |
void subscriptionUpdateRequested(boolean enabled); |
void subscriptionUpdatedApplied(); |
} |
+ |
+ public interface SubscriptionAddedCallback |
+ { |
+ void subscriptionAdded(); |
+ } |
} |