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

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

Issue 29331923: Issue 3364 - Implement JNI bindings for IsDocument/ElemhideWhitelisted (Closed)
Patch Set: referrerChain, comments, consistency Created Dec. 4, 2015, 4:53 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 | « src/org/adblockplus/android/ABPEngine.java ('k') | src/org/adblockplus/android/AndroidWebRequest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/org/adblockplus/android/AdblockPlus.java
diff --git a/src/org/adblockplus/android/AdblockPlus.java b/src/org/adblockplus/android/AdblockPlus.java
index eb44cc168d2cfc52197f283f200d1f8a151ef807..356c78041b492703f3ea31f3128a84e36b2c86f7 100755
--- a/src/org/adblockplus/android/AdblockPlus.java
+++ b/src/org/adblockplus/android/AdblockPlus.java
@@ -269,27 +269,42 @@ public class AdblockPlus extends Application
}
/**
- * Returns ElemHide selectors for domain.
+ * Returns ElemHide selectors for the supplied URL.
*
- * @param domain The domain
+ * @param url The URL
* @return A list of CSS selectors
*/
- public String[] getSelectorsForDomain(final String domain)
+ public String[] getSelectorsForDomain(final String url, String referrer)
{
- /* We need to ignore element hiding rules here to work around two bugs:
- * 1. CSS is being injected even when there's an exception rule with $elemhide
- * 2. The injected CSS causes blank pages in Chrome for Android
- *
- * Starting with 1.1.2, we ignored element hiding rules after download anyway, to keep the
- * memory usage down. Doing this with libadblockplus is trickier, but would be the clean
- * solution. */
- return null;
-/*
- if (!filteringEnabled)
+ if (this.abpEngine.isElemhideEnabled() && this.filteringEnabled)
+ {
+ if (referrer != null)
+ {
+ this.referrerMapping.add(url, referrer);
+ }
+ final List<String> referrerChain = this.referrerMapping.buildReferrerChain(referrer);
+ final String[] referrerChainArray = referrerChain.toArray(new String[referrerChain.size()]);
+ final List<String> selectors = this.abpEngine.getElementHidingSelectors(url, referrerChainArray);
+ // We're returning 'null' when no selectors are available to be consistent
+ // with the previous implementation
+ return selectors.isEmpty() ? null : selectors.toArray(new String[selectors.size()]);
+ }
+ else
+ {
+ /*
+ * This case is still the default for Adblock Plus for Android, as we did not yet
+ * re-enabled element hiding but only enhanced/fixed the current implementation.
Felix Dahlke 2015/12/04 17:03:37 Typo, should be: "[...] as we did not yet re-enabl
René Jeschke 2015/12/04 17:44:25 Done.
+ * See: https://issues.adblockplus.org/ticket/3364
+ */
+ /* We need to ignore element hiding rules here to work around two bugs:
+ * 1. CSS is being injected even when there's an exception rule with $elemhide
+ * 2. The injected CSS causes blank pages in Chrome for Android
+ *
+ * Starting with 1.1.2, we ignored element hiding rules after download anyway, to keep the
+ * memory usage down. Doing this with libadblockplus is trickier, but would be the clean
+ * solution. */
return null;
-
- return abpEngine.getSelectorsForDomain(domain);
-*/
+ }
}
/**
« no previous file with comments | « src/org/adblockplus/android/ABPEngine.java ('k') | src/org/adblockplus/android/AndroidWebRequest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld