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

Unified Diff: adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/engine/Engine.java

Issue 29524668: Issue 3916 - Supporting Adding filter lists via URL (Closed)
Patch Set: fixes Created Oct. 4, 2017, 3:14 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
+ }
}

Powered by Google App Engine
This is Rietveld