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

Unified Diff: libadblockplus-android/jni/JniFilterEngine.cpp

Issue 29351744: Issue 4399 - Add WebView inheritor with ad blocking (Closed)
Patch Set: changed packages, now using AdblockEngine (original ABPEngine), improved demo app Created Oct. 25, 2016, 11:20 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
« no previous file with comments | « libadblockplus-android/build.gradle ('k') | libadblockplus-android/jni/Utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libadblockplus-android/jni/JniFilterEngine.cpp
diff --git a/libadblockplus-android/jni/JniFilterEngine.cpp b/libadblockplus-android/jni/JniFilterEngine.cpp
index cfbe8348d782c5941ba5ec16d92584b55ddc4671..f9981f024922c74874f6a70c096c21cb23dc8e6e 100644
--- a/libadblockplus-android/jni/JniFilterEngine.cpp
+++ b/libadblockplus-android/jni/JniFilterEngine.cpp
@@ -415,6 +415,25 @@ static void JNICALL JniSetPref(JNIEnv* env, jclass clazz, jlong ptr, jstring jPr
CATCH_AND_THROW(env)
}
+static jstring JNICALL JniGetHostFromURL(JNIEnv* env, jclass clazz, jlong ptr, jstring jurl)
+{
+ if (jurl == NULL)
+ {
+ return NULL;
+ }
+
+ AdblockPlus::FilterEngine* engine = JniLongToTypePtr<AdblockPlus::FilterEngine>(ptr);
+
+ std::string url = JniJavaToStdString(env, jurl);
+ try
+ {
+ std::string host = engine->GetHostFromURL(url);
+
+ return JniStdStringToJava(env, host);
+ }
+ CATCH_THROW_AND_RETURN(env, 0)
+}
+
static JNINativeMethod methods[] =
{
{ (char*)"ctor", (char*)"(J)J", (void*)JniCtor },
@@ -439,6 +458,7 @@ static JNINativeMethod methods[] =
{ (char*)"isElemhideWhitelisted", (char*)"(JLjava/lang/String;[Ljava/lang/String;)Z", (void*)JniIsElemhideWhitelisted },
{ (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniGetPref },
{ (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref },
+ { (char*)"getHostFromURL", (char*)"(JLjava/lang/String;)Ljava/lang/String;", (void*)JniGetHostFromURL },
{ (char*)"dtor", (char*)"(J)V", (void*)JniDtor }
};
« no previous file with comments | « libadblockplus-android/build.gradle ('k') | libadblockplus-android/jni/Utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld