123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- // Copyright 2022 The Chromium Authors. All rights reserved.
- // 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/notreached.h"
- #include "ui/base/ui_base_features.h"
- #include "ui/base/ui_base_jni_headers/UiBaseFeatureList_jni.h"
- using base::android::ConvertJavaStringToUTF8;
- using base::android::JavaParamRef;
- namespace features {
- namespace {
- // Array of features exposed through the Java UiBaseFeatureList API. Entries in
- // this array may either refer to features defined in the header of this file or
- // in other locations in the code base (e.g. ui_base_features.h).
- const base::Feature* const kFeaturesExposedToJava[] = {
- &features::kAndroidPermissionsCache,
- }; // namespace
- const base::Feature* FindFeatureExposedToJava(const std::string& feature_name) {
- for (const base::Feature* feature : kFeaturesExposedToJava) {
- if (feature->name == feature_name)
- return feature;
- }
- NOTREACHED() << "Queried feature cannot be found in BaseFeatureList: "
- << feature_name;
- return nullptr;
- }
- } // namespace
- static jboolean JNI_UiBaseFeatureList_IsEnabled(
- JNIEnv* env,
- const JavaParamRef<jstring>& jfeature_name) {
- const base::Feature* feature =
- FindFeatureExposedToJava(ConvertJavaStringToUTF8(env, jfeature_name));
- return base::FeatureList::IsEnabled(*feature);
- }
- } // namespace features
|