1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41

base / android / features_jni.cc [blame]

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/android/jni_string.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"

// Must come after all headers that specialize FromJniType() / ToJniType().
#include "base/base_jni/Features_jni.h"

namespace base {
namespace android {

jboolean JNI_Features_IsEnabled(JNIEnv* env, jlong native_feature_pointer) {
  return base::FeatureList::IsEnabled(
      *reinterpret_cast<base::Feature*>(native_feature_pointer));
}

jboolean JNI_Features_GetFieldTrialParamByFeatureAsBoolean(
    JNIEnv* env,
    jlong native_feature_pointer,
    std::string& param_name,
    const jboolean jdefault_value) {
  const base::Feature& feature =
      *reinterpret_cast<base::Feature*>(native_feature_pointer);
  return base::GetFieldTrialParamByFeatureAsBool(feature, param_name,
                                                 jdefault_value);
}

std::string JNI_Features_GetFieldTrialParamByFeatureAsString(
    JNIEnv* env,
    jlong native_feature_pointer,
    std::string& param_name) {
  const base::Feature& feature =
      *reinterpret_cast<base::Feature*>(native_feature_pointer);
  return base::GetFieldTrialParamValueByFeature(feature, param_name);
}

}  // namespace android
}  // namespace base