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

Side by Side Diff: libadblockplus-android/jni/JniFilterEngine.cpp

Issue 29405564: Issue 5121 - Use Acceptable Ads API in libadblockplus (Closed)
Patch Set: updated dependency to -binaries Created April 7, 2017, 10:14 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 if (value == NULL) 481 if (value == NULL)
482 { 482 {
483 return NULL; 483 return NULL;
484 } 484 }
485 485
486 return JniStdStringToJava(env, *value.get()); 486 return JniStdStringToJava(env, *value.get());
487 } 487 }
488 CATCH_THROW_AND_RETURN(env, 0) 488 CATCH_THROW_AND_RETURN(env, 0)
489 } 489 }
490 490
491 static void JNICALL JniSetAcceptableAdsEnabled(JNIEnv* env, jclass clazz, jlong ptr, jboolean jvalue)
492 {
493 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::FilterEn ginePtr>(ptr);
494
495 try
496 {
497 engine->SetAAEnabled((bool)(jvalue == JNI_TRUE));
498 }
499 CATCH_AND_THROW(env)
500 }
501
502 static jboolean JNICALL JniIsAcceptableAdsEnabled(JNIEnv* env, jclass clazz, jlo ng ptr)
503 {
504 try
505 {
506 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::Filter EnginePtr>(ptr);
507 return (engine->IsAAEnabled() ? JNI_TRUE : JNI_FALSE);
508 }
509 CATCH_THROW_AND_RETURN(env, 0)
510 }
511
512 static jstring JNICALL JniGetAcceptableAdsSubscriptionURL(JNIEnv* env, jclass cl azz, jlong ptr)
513 {
514 try
515 {
516 AdblockPlus::FilterEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::Filter EnginePtr>(ptr);
517 std::string url = engine->GetAAUrl();
518 return JniStdStringToJava(env, url);
519 }
520 CATCH_THROW_AND_RETURN(env, 0)
521 }
522
491 static JNINativeMethod methods[] = 523 static JNINativeMethod methods[] =
492 { 524 {
493 { (char*)"ctor", (char*)"(JJ)J", (void*)JniCtor }, 525 { (char*)"ctor", (char*)"(JJ)J", (void*)JniCtor },
494 { (char*)"isFirstRun", (char*)"(J)Z", (void*)JniIsFirstRun }, 526 { (char*)"isFirstRun", (char*)"(J)Z", (void*)JniIsFirstRun },
495 { (char*)"getFilter", (char*)"(JLjava/lang/String;)" TYP("Filter"), (void*)Jni GetFilter }, 527 { (char*)"getFilter", (char*)"(JLjava/lang/String;)" TYP("Filter"), (void*)Jni GetFilter },
496 { (char*)"getListedFilters", (char*)"(J)Ljava/util/List;", (void*)JniGetListed Filters }, 528 { (char*)"getListedFilters", (char*)"(J)Ljava/util/List;", (void*)JniGetListed Filters },
497 { (char*)"getSubscription", (char*)"(JLjava/lang/String;)" TYP("Subscription") , (void*)JniGetSubscription }, 529 { (char*)"getSubscription", (char*)"(JLjava/lang/String;)" TYP("Subscription") , (void*)JniGetSubscription },
498 { (char*)"showNextNotification", (char*)"(JLjava/lang/String;)V", (void*)JniSh owNextNotification }, 530 { (char*)"showNextNotification", (char*)"(JLjava/lang/String;)V", (void*)JniSh owNextNotification },
499 { (char*)"setShowNotificationCallback", (char*)"(JJ)V", (void*)JniSetShowNotif icationCallback }, 531 { (char*)"setShowNotificationCallback", (char*)"(JJ)V", (void*)JniSetShowNotif icationCallback },
500 { (char*)"removeShowNotificationCallback", (char*)"(J)V", (void*)JniRemoveShow NotificationCallback }, 532 { (char*)"removeShowNotificationCallback", (char*)"(J)V", (void*)JniRemoveShow NotificationCallback },
501 { (char*)"getListedSubscriptions", (char*)"(J)Ljava/util/List;", (void*)JniGet ListedSubscriptions }, 533 { (char*)"getListedSubscriptions", (char*)"(J)Ljava/util/List;", (void*)JniGet ListedSubscriptions },
502 { (char*)"fetchAvailableSubscriptions", (char*)"(J)Ljava/util/List;", (void*)J niFetchAvailableSubscriptions }, 534 { (char*)"fetchAvailableSubscriptions", (char*)"(J)Ljava/util/List;", (void*)J niFetchAvailableSubscriptions },
503 { (char*)"setUpdateAvailableCallback", (char*)"(JJ)V", (void*)JniSetUpdateAvai lableCallback }, 535 { (char*)"setUpdateAvailableCallback", (char*)"(JJ)V", (void*)JniSetUpdateAvai lableCallback },
504 { (char*)"removeUpdateAvailableCallback", (char*)"(J)V", (void*)JniRemoveUpdat eAvailableCallback }, 536 { (char*)"removeUpdateAvailableCallback", (char*)"(J)V", (void*)JniRemoveUpdat eAvailableCallback },
505 { (char*)"setFilterChangeCallback", (char*)"(JJ)V", (void*)JniSetFilterChangeC allback }, 537 { (char*)"setFilterChangeCallback", (char*)"(JJ)V", (void*)JniSetFilterChangeC allback },
506 { (char*)"removeFilterChangeCallback", (char*)"(J)V", (void*)JniRemoveFilterCh angeCallback }, 538 { (char*)"removeFilterChangeCallback", (char*)"(J)V", (void*)JniRemoveFilterCh angeCallback },
507 { (char*)"forceUpdateCheck", (char*)"(JJ)V", (void*)JniForceUpdateCheck }, 539 { (char*)"forceUpdateCheck", (char*)"(JJ)V", (void*)JniForceUpdateCheck },
508 { (char*)"getElementHidingSelectors", (char*)"(JLjava/lang/String;)Ljava/util/ List;", (void*)JniGetElementHidingSelectors }, 540 { (char*)"getElementHidingSelectors", (char*)"(JLjava/lang/String;)Ljava/util/ List;", (void*)JniGetElementHidingSelectors },
509 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp e") "Ljava/lang/String;)" TYP("Filter"), (void*)JniMatches }, 541 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp e") "Ljava/lang/String;)" TYP("Filter"), (void*)JniMatches },
510 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp e") "[Ljava/lang/String;)" TYP("Filter"), (void*)JniMatchesMany }, 542 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp e") "[Ljava/lang/String;)" TYP("Filter"), (void*)JniMatchesMany },
511 { (char*)"isDocumentWhitelisted", (char*)"(JLjava/lang/String;[Ljava/lang/Stri ng;)Z", (void*)JniIsDocumentWhitelisted }, 543 { (char*)"isDocumentWhitelisted", (char*)"(JLjava/lang/String;[Ljava/lang/Stri ng;)Z", (void*)JniIsDocumentWhitelisted },
512 { (char*)"isElemhideWhitelisted", (char*)"(JLjava/lang/String;[Ljava/lang/Stri ng;)Z", (void*)JniIsElemhideWhitelisted }, 544 { (char*)"isElemhideWhitelisted", (char*)"(JLjava/lang/String;[Ljava/lang/Stri ng;)Z", (void*)JniIsElemhideWhitelisted },
513 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG etPref }, 545 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG etPref },
514 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref }, 546 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref },
515 { (char*)"getHostFromURL", (char*)"(JLjava/lang/String;)Ljava/lang/String;", ( void*)JniGetHostFromURL }, 547 { (char*)"getHostFromURL", (char*)"(JLjava/lang/String;)Ljava/lang/String;", ( void*)JniGetHostFromURL },
516 { (char*)"setAllowedConnectionType", (char*)"(JLjava/lang/String;)V", (void*)J niSetAllowedConnectionType }, 548 { (char*)"setAllowedConnectionType", (char*)"(JLjava/lang/String;)V", (void*)J niSetAllowedConnectionType },
517 { (char*)"getAllowedConnectionType", (char*)"(J)Ljava/lang/String;", (void*)Jn iGetAllowedConnectionType }, 549 { (char*)"getAllowedConnectionType", (char*)"(J)Ljava/lang/String;", (void*)Jn iGetAllowedConnectionType },
550 { (char*)"setAcceptableAdsEnabled", (char*)"(JZ)V", (void*)JniSetAcceptableAds Enabled },
551 { (char*)"isAcceptableAdsEnabled", (char*)"(J)Z", (void*)JniIsAcceptableAdsEna bled },
552 { (char*)"getAcceptableAdsSubscriptionURL", (char*)"(J)Ljava/lang/String;", (v oid*)JniGetAcceptableAdsSubscriptionURL },
518 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } 553 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor }
519 }; 554 };
520 555
521 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz) 556 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz)
522 { 557 {
523 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 558 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
524 } 559 }
OLDNEW

Powered by Google App Engine
This is Rietveld