static jobject JNICALL JniGetElementHidingSelectors(JNIEnv* env, jclass clazz,
    jlong ptr, jstring jDomain)
{
  AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr);

  std::string domain = JniJavaToStdString(env, jDomain);

  try
  {
    std::vector<std::string> selectors = engine.GetElementHidingSelectors(
        domain);

    jobject list = NewJniArrayList(env);

    for (std::vector<std::string>::iterator it = selectors.begin(), end =
        selectors.end(); it != end; it++)
    {
      JniAddObjectToList(env, list,
          *JniLocalReference<jstring>(env, env->NewStringUTF(it->c_str())));
    }

    return list;
  }
  CATCH_THROW_AND_RETURN(env, 0)
}
static jobject SubscriptionsToArrayList(JNIEnv* env, std::vector<AdblockPlus::Subscription>&& subscriptions)
{
  jobject list = NewJniArrayList(env);

  for (std::vector<AdblockPlus::Subscription>::iterator it = subscriptions.begin(), end = subscriptions.end(); it != end; it++)
  {
    JniAddObjectToList(env, list, NewJniSubscription(env, std::move(*it)));
  }

  return list;
}
Пример #3
0
jobject JniJsValueListToArrayList(JNIEnv* env, AdblockPlus::JsValueList& list)
{
    jobject arrayList = NewJniArrayList(env);

    for (AdblockPlus::JsValueList::iterator it = list.begin(), end = list.end(); it != end; ++it)
    {
        JniAddObjectToList(env, arrayList,
                           *JniLocalReference<jobject>(env, NewJniJsValue(env, *it)));
    }

    return arrayList;
}
static jobject JNICALL JniGetListedFilters(JNIEnv* env, jclass clazz, jlong ptr)
{
  AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr);

  try
  {
    std::vector<AdblockPlus::Filter> filters = engine.GetListedFilters();

    jobject list = NewJniArrayList(env);

    for (std::vector<AdblockPlus::Filter>::iterator it = filters.begin(), end = filters.end(); it != end; it++)
    {
      JniAddObjectToList(env, list, *JniLocalReference<jobject>(env, NewJniFilter(env, std::move(*it))));
    }

    return list;
  }
  CATCH_THROW_AND_RETURN(env, 0);
}
static jobject JNICALL JniGetElementHidingEmulationSelectors(JNIEnv* env, jclass clazz,
    jlong ptr, jstring jDomain)
{
  AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr);

  std::string domain = JniJavaToStdString(env, jDomain);

  try
  {
    std::vector<AdblockPlus::FilterEngine::EmulationSelector> selectors = engine.GetElementHidingEmulationSelectors(domain);

    jobject list = NewJniArrayList(env);

    for (auto it = selectors.cbegin(), end = selectors.cend(); it != end; ++it)
    {
      JniAddObjectToList(env, list, NewJniEmulationSelector(env, *it));
    }

    return list;
  }
  CATCH_THROW_AND_RETURN(env, 0)
}