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: Created Nov. 23, 2013, 12:03 a.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
@@ -41,7 +41,8 @@
JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_refreshSubscription(JNIEnv *pEnv, jobject, jstring url);
JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_actualizeSubscriptionStatus(JNIEnv *pEnv, jobject, jstring url);
JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_setAcceptableAdsEnabled(JNIEnv *pEnv, jobject, jboolean enabled);
- 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);
};
@@ -455,23 +456,31 @@
}
}
-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/AdblockPlus.java » ('J')

Powered by Google App Engine
This is Rietveld