clay: Expose the feature flag in Java at the //component layer

Bug: b:355242212
Change-Id: I68a732561637dcaaa1179b22fb3e09eda4b39e94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5797108
Reviewed-by: Tanmoy Mollik <[email protected]>
Reviewed-by: David Roger <[email protected]>
Auto-Submit: Nicolas Dossou-Gbété <[email protected]>
Commit-Queue: Nicolas Dossou-Gbété <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1344275}
diff --git a/components/search_engines/android/search_engines_feature_map.cc b/components/search_engines/android/search_engines_feature_map.cc
new file mode 100644
index 0000000..56aee7e
--- /dev/null
+++ b/components/search_engines/android/search_engines_feature_map.cc
@@ -0,0 +1,39 @@
+// Copyright 2024 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <iterator>
+#include <string>
+
+#include "base/android/feature_map.h"
+#include "base/feature_list.h"
+#include "base/features.h"
+#include "base/no_destructor.h"
+#include "components/search_engines/search_engines_switches.h"
+
+// Must come after all headers that specialize FromJniType() / ToJniType().
+#include "components/search_engines/android/features_jni_headers/SearchEnginesFeatureMap_jni.h"
+
+namespace search_engines {
+
+namespace {
+
+// Array of features exposed through the Java BaseFeatureMap API. Entries in
+// this array refer to features defined in //search_engines features.
+const base::Feature* const kFeaturesExposedToJava[] = {
+    &switches::kClayBlocking};
+
+// static
+base::android::FeatureMap* GetFeatureMap() {
+  static base::NoDestructor<base::android::FeatureMap> kFeatureMap(std::vector(
+      std::begin(kFeaturesExposedToJava), std::end(kFeaturesExposedToJava)));
+  return kFeatureMap.get();
+}
+
+}  // namespace
+
+static jlong JNI_SearchEnginesFeatureMap_GetNativeMap(JNIEnv* env) {
+  return reinterpret_cast<jlong>(GetFeatureMap());
+}
+
+}  // namespace search_engines