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

Unified Diff: jni/abpEngine.cpp

Issue 5172657418928128: Determine the frame structure (Closed)
Patch Set: Use LRU caching for the referrer mappings Created Nov. 27, 2013, 12:01 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: jni/abpEngine.cpp
===================================================================
--- a/jni/abpEngine.cpp
+++ b/jni/abpEngine.cpp
@@ -43,7 +43,8 @@
JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_setAcceptableAdsEnabled(JNIEnv *pEnv, jobject, jboolean enabled);
JNIEXPORT jstring JNICALL Java_org_adblockplus_android_ABPEngine_getDocumentationLink(
JNIEnv *env, jobject object);
Felix Dahlke 2013/11/27 12:19:33 This and the other changes in this file are unrela
- JNIEXPORT jboolean JNICALL Java_org_adblockplus_android_ABPEngine_matches(JNIEnv *pEnv, jobject, jstring url, jstring contentType, jstring documentUrl);
+ JNIEXPORT jboolean JNICALL Java_org_adblockplus_android_ABPEngine_matches(
+ JNIEnv *pEnv, jobject, jstring url, jstring contentType, jobjectArray documentUrls);
JNIEXPORT jobjectArray JNICALL Java_org_adblockplus_android_ABPEngine_getSelectorsForDomain(JNIEnv *pEnv, jobject, jstring domain);
JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_checkUpdates(JNIEnv *pEnv, jobject);
};
@@ -464,23 +465,31 @@
return env->NewStringUTF(documentationLink.c_str());
}
-JNIEXPORT jboolean JNICALL Java_org_adblockplus_android_ABPEngine_matches(JNIEnv *pEnv, jobject, jstring url, jstring contentType, jstring documentUrl)
+JNIEXPORT jboolean JNICALL Java_org_adblockplus_android_ABPEngine_matches(
+ JNIEnv *pEnv, jobject, jstring url, jstring contentType, jobjectArray documentUrls)
{
try
{
const std::string surl = GetString(pEnv, url);
const std::string stype = GetString(pEnv, contentType);
- const std::string sdoc = GetString(pEnv, documentUrl);
+ const int documentUrlsLength = pEnv->GetArrayLength(documentUrls);
+ std::vector<std::string> sdocumentUrls;
+ for(int i = 0; i < documentUrlsLength; i++)
+ {
+ jstring documentUrl = static_cast<jstring>(pEnv->GetObjectArrayElement(documentUrls, i));
+ sdocumentUrls.push_back(GetString(pEnv, documentUrl));
+ }
- AdblockPlus::FilterPtr filter = filterEngine->Matches(surl, stype, sdoc);
+ AdblockPlus::FilterPtr filter = filterEngine->Matches(surl, stype, sdocumentUrls);
if (! filter)
return JNI_FALSE;
- // hack: if there is no referrer block only if filter is domain-specific
+ // hack: if there is no referrer, block only if filter is domain-specific
// (to re-enable in-app ads blocking, proposed on 12.11.2012 Monday meeting)
- // documentUrl contains the referrer (Android application special case)
- if (sdoc.empty() && (filter->GetProperty("text")->AsString()).find("||") != std::string::npos)
+ // (documentUrls contains the referrers on Android)
+ if (!sdocumentUrls.size() &&
+ (filter->GetProperty("text")->AsString()).find("||") != std::string::npos)
return JNI_FALSE;
return filter->GetType() == AdblockPlus::Filter::TYPE_EXCEPTION ? JNI_FALSE : JNI_TRUE;
« no previous file with comments | « no previous file | src/org/adblockplus/android/ABPEngine.java » ('j') | src/org/adblockplus/android/ABPEngine.java » ('J')

Powered by Google App Engine
This is Rietveld