chromium/components/feature_engagement/public/BUILD.gn

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

if (is_chromeos) {
  import("//build/config/chromeos/ui_mode.gni")
}

if (is_android) {
  import("//build/config/android/config.gni")
  import("//build/config/android/rules.gni")
  import("//third_party/jni_zero/jni_zero.gni")
}

source_set("public") {
  sources = [
    "configuration.cc",
    "configuration.h",
    "configuration_provider.cc",
    "configuration_provider.h",
    "default_session_controller.cc",
    "default_session_controller.h",
    "event_constants.cc",
    "event_constants.h",
    "feature_configurations.cc",
    "feature_configurations.h",
    "feature_constants.cc",
    "feature_constants.h",
    "feature_list.cc",
    "feature_list.h",
    "field_trial_configuration_provider.cc",
    "field_trial_configuration_provider.h",
    "field_trial_utils.cc",
    "field_trial_utils.h",
    "group_configurations.cc",
    "group_configurations.h",
    "group_constants.cc",
    "group_constants.h",
    "group_list.cc",
    "group_list.h",
    "local_configuration_provider.cc",
    "local_configuration_provider.h",
    "session_controller.h",
    "stats.cc",
    "stats.h",
    "tracker.cc",
    "tracker.h",
  ]

  public_deps = [ "//base" ]
  deps = [
    "//build:branding_buildflags",
    "//components/feed:feature_list",
    "//components/flags_ui",
    "//components/keyed_service/core",
    "//extensions/buildflags",
  ]
  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  if (is_android) {
    sources += [
      "android/wrapping_test_tracker.cc",
      "android/wrapping_test_tracker.h",
    ]

    deps += [ "//components/feature_engagement/public:jni_headers" ]
  }

  if (is_ios) {
    sources += [
      "ios_promo_feature_configuration.cc",
      "ios_promo_feature_configuration.h",
    ]
  }

  if (is_chromeos && is_chromeos_ash) {
    sources += [
      "scalable_iph_feature_configurations.cc",
      "scalable_iph_feature_configurations.h",
    ]
    deps += [
      "//ash/constants",
      "//chromeos/ash/components/scalable_iph:constants",
    ]
  }
}

source_set("unit_tests") {
  testonly = true

  visibility = [ "//components/feature_engagement:unit_tests" ]

  # IMPORTANT NOTE: When adding new tests, also remember to update the list of
  # tests in //components/feature_engagement/components_unittests.filter
  sources = [
    "configuration_unittest.cc",
    "feature_list_unittest.cc",
  ]

  deps = [
    ":public",
    "//testing/gtest",
  ]
}

if (is_android) {
  android_library("public_java") {
    sources = [
      "android/java/src/org/chromium/components/feature_engagement/CppWrappedTestTracker.java",
      "android/java/src/org/chromium/components/feature_engagement/EventConstants.java",
      "android/java/src/org/chromium/components/feature_engagement/FeatureConstants.java",
      "android/java/src/org/chromium/components/feature_engagement/Tracker.java",
      "android/java/src/org/chromium/components/feature_engagement/TriggerDetails.java",
    ]

    deps = [
      ":jni_headers",
      "//base:base_java",
      "//third_party/androidx:androidx_annotation_annotation_java",
      "//third_party/jni_zero:jni_zero_java",
    ]

    srcjar_deps = [
      ":jni_headers",
      ":public_java_enums_srcjar",
    ]
  }

  java_cpp_enum("public_java_enums_srcjar") {
    visibility = [ ":*" ]

    sources = [ "tracker.h" ]
  }

  generate_jni("jni_headers") {
    sources = [ "android/java/src/org/chromium/components/feature_engagement/CppWrappedTestTracker.java" ]
  }
}