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

Unified Diff: src/org/adblockplus/android/ABPEngine.java

Issue 29331923: Issue 3364 - Implement JNI bindings for IsDocument/ElemhideWhitelisted (Closed)
Patch Set: Issues No. 1 Created Dec. 4, 2015, 3:55 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
« no previous file with comments | « jni/JniFilterEngine.cpp ('k') | src/org/adblockplus/android/AdblockPlus.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/org/adblockplus/android/ABPEngine.java
diff --git a/src/org/adblockplus/android/ABPEngine.java b/src/org/adblockplus/android/ABPEngine.java
index 418185e0f0fcde90f0fde593af69e92c206fec8e..f7134931e4570857a4e166eb8043db189bd8aca9 100644
--- a/src/org/adblockplus/android/ABPEngine.java
+++ b/src/org/adblockplus/android/ABPEngine.java
@@ -17,6 +17,7 @@
package org.adblockplus.android;
+import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -63,10 +64,12 @@ public final class ABPEngine
private volatile UpdateCheckDoneCallback updateCheckDoneCallback;
private volatile FilterChangeCallback filterChangeCallback;
private volatile ShowNotificationCallback showNotificationCallback;
+ private final boolean elemhideEnabled;
- private ABPEngine(final Context context)
+ private ABPEngine(final Context context, final boolean enableElemhide)
{
this.context = context;
+ this.elemhideEnabled = enableElemhide;
}
public static AppInfo generateAppInfo(final Context context)
@@ -97,7 +100,12 @@ public final class ABPEngine
public static ABPEngine create(final Context context, final AppInfo appInfo, final String basePath)
{
- final ABPEngine engine = new ABPEngine(context);
+ return create(context, appInfo, basePath, false);
+ }
+
+ public static ABPEngine create(final Context context, final AppInfo appInfo, final String basePath, boolean enableElemhide)
+ {
+ final ABPEngine engine = new ABPEngine(context, enableElemhide);
engine.jsEngine = new JsEngine(appInfo);
engine.jsEngine.setDefaultFileSystem(basePath);
@@ -105,7 +113,7 @@ public final class ABPEngine
engine.logSystem = new AndroidLogSystem();
engine.jsEngine.setLogSystem(engine.logSystem);
- engine.webRequest = new AndroidWebRequest();
+ engine.webRequest = new AndroidWebRequest(enableElemhide);
engine.jsEngine.setWebRequest(engine.webRequest);
engine.filterEngine = new FilterEngine(engine.jsEngine);
@@ -182,6 +190,11 @@ public final class ABPEngine
return this.filterEngine.isFirstRun();
}
+ public boolean isElemhideEnabled()
+ {
+ return this.elemhideEnabled;
+ }
+
private static org.adblockplus.android.Subscription convertJsSubscription(final Subscription jsSubscription)
{
final org.adblockplus.android.Subscription subscription = new org.adblockplus.android.Subscription();
@@ -278,6 +291,27 @@ public final class ABPEngine
return filter.getType() != Filter.Type.EXCEPTION;
}
+ public boolean isDocumentWhitelisted(final String url, final String[] documentUrls)
+ {
+ return this.filterEngine.isDocumentWhitelisted(url, documentUrls);
+ }
+
+ public boolean isElemhideWhitelisted(final String url, final String[] documentUrls)
+ {
+ return this.filterEngine.isElemhideWhitelisted(url, documentUrls);
+ }
+
+ public List<String> getElementHidingSelectors(final String url, final String[] documentUrls)
+ {
+ if (!this.elemhideEnabled
+ || this.isDocumentWhitelisted(url, documentUrls)
+ || this.isElemhideWhitelisted(url, documentUrls))
+ {
+ return new ArrayList<String>();
+ }
+ return this.filterEngine.getElementHidingSelectors(url);
+ }
+
public void checkForUpdates()
{
this.filterEngine.forceUpdateCheck(this.updateCheckDoneCallback);
@@ -291,4 +325,9 @@ public final class ABPEngine
Utils.updateSubscriptionStatus(this.context, sub);
}
}
+
+ public FilterEngine getFilterEngine()
+ {
+ return this.filterEngine;
+ }
}
« no previous file with comments | « jni/JniFilterEngine.cpp ('k') | src/org/adblockplus/android/AdblockPlus.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld