# 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.

import("//build/config/chromeos/args.gni")

assert(is_win || is_mac || is_linux || is_chromeos || is_android)

source_set("find_bar") {
  sources = [
    "find_bar.h",
    "find_bar_state.h",
    "find_bar_state_factory.h",
  ]

  public_deps = [
    "//base",
    "//chrome/browser/profiles:profile",
    "//components/find_in_page",
    "//components/keyed_service/core",
    "//ui/base/data_transfer_policy",
  ]

  if (!is_android) {
    sources += [ "find_bar_controller.h" ]

    public_deps += [
      "//chrome/browser/ui/views/page_action",
      "//content/public/browser",
    ]
  }
}

source_set("impl") {
  sources = [
    "find_bar_state.cc",
    "find_bar_state_factory.cc",
  ]
  deps = [
    ":find_bar",
    "//chrome/browser/enterprise",
    "//content/public/browser",
  ]

  if (!is_android) {
    sources += [
      "find_bar_controller.cc",
      "find_bar_platform_helper.cc",
      "find_bar_platform_helper.h",
    ]
    public_deps = [ "//chrome/browser:browser_public_dependencies" ]
    deps += [ "//ui/gfx/range" ]
  }

  if (is_mac) {
    sources += [ "find_bar_platform_helper_mac.mm" ]
    deps += [ "//chrome/browser/ui/tabs:tab_strip" ]
  }
}

source_set("unit_tests") {
  testonly = true

  sources = [ "find_backend_unittest.cc" ]

  deps = [
    ":find_bar",
    "//chrome/test:test_support",
    "//components/enterprise/data_controls/core/browser:test_support",
  ]
}

if (!is_android) {
  source_set("browser_tests") {
    testonly = true

    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]

    sources = [
      "find_bar_controller_browsertest.cc",
      "find_bar_host_browsertest.cc",
    ]

    deps = [
      ":find_bar",
      "//chrome/browser/ui:chrome_pages",
      "//chrome/browser/ui:ui_features",
      "//chrome/browser/ui/browser_window",
      "//chrome/test:test_support",
    ]

    if (is_mac) {
      sources += [ "find_bar_platform_helper_mac_browsertest.mm" ]
    }
  }
}

if (!is_android && !is_chromeos_device) {
  source_set("interactive_ui_tests") {
    testonly = true

    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]

    sources = [ "find_bar_host_interactive_uitest.cc" ]

    deps = [
      ":find_bar",
      "//chrome/browser/ui:view_ids",
      "//chrome/browser/ui/browser_window",
      "//chrome/test:test_support",
    ]

    if (is_mac) {
      sources += [ "find_bar_platform_helper_mac_interactive_uitest.mm" ]
    }
  }
}
