chromium/chrome/browser/preferences/BUILD.gn

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

import("//build/config/android/rules.gni")
import("//third_party/jni_zero/jni_zero.gni")

android_library("java") {
  sources = [
    "android/java/src/org/chromium/chrome/browser/preferences/AllPreferenceKeyRegistries.java",
    "android/java/src/org/chromium/chrome/browser/preferences/ChromePreferenceKeys.java",
    "android/java/src/org/chromium/chrome/browser/preferences/ChromeSharedPreferences.java",
    "android/java/src/org/chromium/chrome/browser/preferences/DeprecatedChromePreferenceKeys.java",
    "android/java/src/org/chromium/chrome/browser/preferences/LegacyChromePreferenceKeys.java",
    "android/java/src/org/chromium/chrome/browser/preferences/PrefChangeRegistrar.java",
  ]

  public_deps = [ "//base:base_shared_preferences_java" ]

  deps = [
    "//base:base_cached_flags_java",
    "//base:base_java",
    "//build/android:build_java",
    "//components/browser_ui/accessibility/android:constants_java",
    "//components/browser_ui/share/android:constants_java",
    "//components/browser_ui/site_settings/android:constants_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
    "//third_party/jni_zero:jni_zero_java",
  ]

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

# TODO(chouinard,estade): Consider breaking this target up into a different target for each pref file.
java_cpp_strings("java_pref_names_srcjar") {
  sources = [
    "//chrome/browser/enterprise/reporting/prefs.cc",
    "//chrome/browser/ui/safety_hub/safety_hub_prefs.h",
    "//chrome/common/pref_names.h",
    "//components/autofill/core/common/autofill_prefs.h",
    "//components/commerce/core/pref_names.h",
    "//components/dom_distiller/core/pref_names.h",
    "//components/embedder_support/pref_names.h",
    "//components/feed/core/common/pref_names.cc",
    "//components/feed/core/shared_prefs/pref_names.cc",
    "//components/history/core/common/pref_names.cc",
    "//components/language/core/browser/pref_names.h",
    "//components/password_manager/core/common/password_manager_pref_names.h",
    "//components/payments/core/payment_prefs.h",
    "//components/policy/core/common/policy_pref_names.cc",
    "//components/privacy_sandbox/privacy_sandbox_prefs.h",
    "//components/privacy_sandbox/tracking_protection_prefs.h",
    "//components/safe_browsing/core/common/safe_browsing_prefs.h",
    "//components/saved_tab_groups/pref_names.h",
    "//components/signin/public/base/signin_pref_names.cc",
    "//components/supervised_user/core/common/pref_names.h",
    "//components/translate/core/browser/translate_pref_names.h",
  ]

  template = "android/java_templates/Pref.java.tmpl"
}

generate_jni("jni_headers") {
  sources = [
    "android/java/src/org/chromium/chrome/browser/preferences/ChromeSharedPreferences.java",
    "android/java/src/org/chromium/chrome/browser/preferences/PrefChangeRegistrar.java",
  ]
}

source_set("android") {
  sources = [
    "android/chrome_shared_preferences.cc",
    "android/chrome_shared_preferences.h",
  ]
  deps = [
    ":jni_headers",
    "//base",
  ]
}

robolectric_library("preferences_junit_tests") {
  sources = [ "android/java/src/org/chromium/chrome/browser/preferences/ChromePreferenceKeysTest.java" ]
  deps = [
    ":java",
    "//base:base_java",
    "//base:base_java_test_support",
    "//base:base_junit_test_support",
    "//base/test:test_support_java",
    "//third_party/android_deps:guava_android_java",
    "//third_party/androidx:androidx_test_runner_java",
    "//third_party/junit:junit",
    "//third_party/mockito:mockito_java",
  ]
}