Nicolas Dossou-Gbete | b6d25183 | 2024-08-20 18:14:03 | [diff] [blame] | 1 | // Copyright 2024 The Chromium Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include <iterator> |
| 6 | #include <string> |
| 7 | |
| 8 | #include "base/android/feature_map.h" |
| 9 | #include "base/feature_list.h" |
| 10 | #include "base/features.h" |
| 11 | #include "base/no_destructor.h" |
| 12 | #include "components/search_engines/search_engines_switches.h" |
| 13 | |
| 14 | // Must come after all headers that specialize FromJniType() / ToJniType(). |
| 15 | #include "components/search_engines/android/features_jni_headers/SearchEnginesFeatureMap_jni.h" |
| 16 | |
| 17 | namespace search_engines { |
| 18 | |
| 19 | namespace { |
| 20 | |
| 21 | // Array of features exposed through the Java BaseFeatureMap API. Entries in |
| 22 | // this array refer to features defined in //search_engines features. |
| 23 | const base::Feature* const kFeaturesExposedToJava[] = { |
Tanmoy Mollik | 6cb9bca | 2024-11-04 13:49:15 | [diff] [blame] | 24 | &switches::kClayBlocking, &switches::kClayBackendConnectionV2, |
| 25 | &switches::kClaySnackbar}; |
Nicolas Dossou-Gbete | b6d25183 | 2024-08-20 18:14:03 | [diff] [blame] | 26 | |
| 27 | // static |
| 28 | base::android::FeatureMap* GetFeatureMap() { |
David Benjamin | abf93ed | 2025-01-29 22:09:03 | [diff] [blame] | 29 | static base::NoDestructor<base::android::FeatureMap> kFeatureMap( |
| 30 | kFeaturesExposedToJava); |
Nicolas Dossou-Gbete | b6d25183 | 2024-08-20 18:14:03 | [diff] [blame] | 31 | return kFeatureMap.get(); |
| 32 | } |
| 33 | |
| 34 | } // namespace |
| 35 | |
| 36 | static jlong JNI_SearchEnginesFeatureMap_GetNativeMap(JNIEnv* env) { |
| 37 | return reinterpret_cast<jlong>(GetFeatureMap()); |
| 38 | } |
| 39 | |
| 40 | } // namespace search_engines |