Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 { | 58 { |
59 try | 59 try |
60 { | 60 { |
61 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); | 61 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); |
62 | 62 |
63 return engine.IsFirstRun() ? JNI_TRUE : JNI_FALSE; | 63 return engine.IsFirstRun() ? JNI_TRUE : JNI_FALSE; |
64 } | 64 } |
65 CATCH_THROW_AND_RETURN(env, JNI_FALSE); | 65 CATCH_THROW_AND_RETURN(env, JNI_FALSE); |
66 } | 66 } |
67 | 67 |
68 static jlong JNICALL JniGetFilterEnginePtr(JNIEnv* env, jclass clazz, jlong ptr) | |
sergei
2017/09/26 09:44:13
It looks strange to have this method in this file
anton
2017/09/26 10:55:06
it's required to pass filter engine to c++ side fo
| |
69 { | |
70 try | |
71 { | |
72 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); | |
73 return (jlong)&engine; | |
74 } | |
75 CATCH_THROW_AND_RETURN(env, 0); | |
76 } | |
77 | |
68 static jobject JNICALL JniGetFilter(JNIEnv* env, jclass clazz, jlong ptr, jstrin g jText) | 78 static jobject JNICALL JniGetFilter(JNIEnv* env, jclass clazz, jlong ptr, jstrin g jText) |
69 { | 79 { |
70 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); | 80 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); |
71 std::string text = JniJavaToStdString(env, jText); | 81 std::string text = JniJavaToStdString(env, jText); |
72 | 82 |
73 try | 83 try |
74 { | 84 { |
75 return NewJniFilter(env, engine.GetFilter(text)); | 85 return NewJniFilter(env, engine.GetFilter(text)); |
76 } | 86 } |
77 CATCH_THROW_AND_RETURN(env, 0); | 87 CATCH_THROW_AND_RETURN(env, 0); |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 { (char*)"isDocumentWhitelisted", (char*)"(JLjava/lang/String;[Ljava/lang/Stri ng;)Z", (void*)JniIsDocumentWhitelisted }, | 531 { (char*)"isDocumentWhitelisted", (char*)"(JLjava/lang/String;[Ljava/lang/Stri ng;)Z", (void*)JniIsDocumentWhitelisted }, |
522 { (char*)"isElemhideWhitelisted", (char*)"(JLjava/lang/String;[Ljava/lang/Stri ng;)Z", (void*)JniIsElemhideWhitelisted }, | 532 { (char*)"isElemhideWhitelisted", (char*)"(JLjava/lang/String;[Ljava/lang/Stri ng;)Z", (void*)JniIsElemhideWhitelisted }, |
523 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG etPref }, | 533 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG etPref }, |
524 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref }, | 534 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref }, |
525 { (char*)"getHostFromURL", (char*)"(JLjava/lang/String;)Ljava/lang/String;", ( void*)JniGetHostFromURL }, | 535 { (char*)"getHostFromURL", (char*)"(JLjava/lang/String;)Ljava/lang/String;", ( void*)JniGetHostFromURL }, |
526 { (char*)"setAllowedConnectionType", (char*)"(JLjava/lang/String;)V", (void*)J niSetAllowedConnectionType }, | 536 { (char*)"setAllowedConnectionType", (char*)"(JLjava/lang/String;)V", (void*)J niSetAllowedConnectionType }, |
527 { (char*)"getAllowedConnectionType", (char*)"(J)Ljava/lang/String;", (void*)Jn iGetAllowedConnectionType }, | 537 { (char*)"getAllowedConnectionType", (char*)"(J)Ljava/lang/String;", (void*)Jn iGetAllowedConnectionType }, |
528 { (char*)"setAcceptableAdsEnabled", (char*)"(JZ)V", (void*)JniSetAcceptableAds Enabled }, | 538 { (char*)"setAcceptableAdsEnabled", (char*)"(JZ)V", (void*)JniSetAcceptableAds Enabled }, |
529 { (char*)"isAcceptableAdsEnabled", (char*)"(J)Z", (void*)JniIsAcceptableAdsEna bled }, | 539 { (char*)"isAcceptableAdsEnabled", (char*)"(J)Z", (void*)JniIsAcceptableAdsEna bled }, |
530 { (char*)"getAcceptableAdsSubscriptionURL", (char*)"(J)Ljava/lang/String;", (v oid*)JniGetAcceptableAdsSubscriptionURL }, | 540 { (char*)"getAcceptableAdsSubscriptionURL", (char*)"(J)Ljava/lang/String;", (v oid*)JniGetAcceptableAdsSubscriptionURL }, |
531 { (char*)"updateFiltersAsync", (char*)"(JLjava/lang/String;)V", (void*)JniUpda teFiltersAsync } | 541 { (char*)"updateFiltersAsync", (char*)"(JLjava/lang/String;)V", (void*)JniUpda teFiltersAsync }, |
542 { (char*)"getFilterEnginePtr", (char*)"(J)J", (void*)JniGetFilterEnginePtr }, | |
532 }; | 543 }; |
533 | 544 |
534 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz) | 545 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz) |
535 { | 546 { |
536 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 547 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
537 } | 548 } |
OLD | NEW |