chromium/chrome/browser/apps/link_capturing/BUILD.gn

# Copyright 2023 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/ui_mode.gni")
import("//chrome/browser/buildflags.gni")
import("//extensions/buildflags/buildflags.gni")

assert(!is_android)

source_set("link_capturing") {
  sources = [
    "apps_intent_picker_delegate.h",
    "intent_picker_info.cc",
    "intent_picker_info.h",
    "link_capturing_navigation_throttle.cc",
    "link_capturing_navigation_throttle.h",
    "link_capturing_tab_data.cc",
    "link_capturing_tab_data.h",
  ]

  if (is_mac) {
    sources += [
      "mac_intent_picker_helpers.h",
      "mac_intent_picker_helpers.mm",
    ]
  }

  deps = [
    ":features",
    "//base",
    "//chrome/browser/profiles:profile",
    "//chrome/browser/web_applications",
    "//chrome/common:chrome_features",
    "//components/keep_alive_registry",
    "//components/page_load_metrics/browser",
    "//components/webapps/common:common",
    "//content/public/browser",
    "//third_party/abseil-cpp:absl",
    "//url",
  ]
  if (enable_extensions) {
    deps += [ "//extensions/common" ]
  }

  if (is_chromeos) {
    sources += [
      "chromeos_apps_intent_picker_delegate.cc",
      "chromeos_apps_intent_picker_delegate.h",
      "chromeos_link_capturing_delegate.cc",
      "chromeos_link_capturing_delegate.h",
      "metrics/intent_handling_metrics.cc",
      "metrics/intent_handling_metrics.h",
    ]
    deps += [
      "//ash/webui/projector_app/public/cpp",
      "//chrome/browser/apps/app_service",
    ]

    # Needed only to allow circular includes.
    deps += [ "//chrome/browser/chromeos/arc" ]

    allow_circular_includes_from = [ "//chrome/browser/chromeos/arc" ]
  } else {
    sources += [
      "enable_link_capturing_infobar_delegate.cc",
      "enable_link_capturing_infobar_delegate.h",
      "web_app_link_capturing_delegate.cc",
      "web_app_link_capturing_delegate.h",
      "web_apps_intent_picker_delegate.cc",
      "web_apps_intent_picker_delegate.h",
    ]
    deps += [
      "//chrome/app:generated_resources_grit",
      "//components/infobars/content",
      "//components/infobars/core",
      "//components/strings:components_strings_grit",
      "//components/vector_icons",
    ]
  }

  if (is_chromeos_ash) {
    deps += [ "//ash/components/arc:arc" ]
  }
}

source_set("features") {
  sources = [
    "link_capturing_features.cc",
    "link_capturing_features.h",
  ]
  public_deps = [ "//base" ]
  deps = [
    "//chrome/common:chrome_features",
    "//content/public/common",
  ]
}

source_set("test_support") {
  testonly = true
  sources = [
    "link_capturing_feature_test_support.cc",
    "link_capturing_feature_test_support.h",
  ]
  deps = [
    ":link_capturing",
    "//base/test:test_support",
    "//chrome/browser:test_support",
    "//chrome/browser/apps/link_capturing:features",
    "//chrome/browser/web_applications:web_applications",
    "//chrome/common:chrome_features",
    "//components/webapps/common",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [ "link_capturing_navigation_throttle_unittest.cc" ]
  deps = [
    ":features",
    ":link_capturing",
    "//base/test:test_support",
    "//chrome/browser/ui/views/toolbar",
    "//testing/gtest",
    "//ui/base:base",
    "//ui/display:test_support",
    "//url",
  ]

  if (is_chromeos) {
    sources += [
      "chromeos_link_capturing_delegate_unittest.cc",
      "metrics/intent_handling_metrics_unittest.cc",
    ]
    deps += [
      "//chrome/browser/apps/app_service",
      "//chrome/test:test_support",
      "//components/prefs:test_support",
      "//content/test:test_support",
    ]
  }
}

# Browser tests which require an Ash process with App Service to be running.
source_set("app_service_browser_tests") {
  testonly = true

  defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]

  sources = [ "link_capturing_navigation_throttle_browsertest.cc" ]

  deps = [
    ":link_capturing",
    ":test_support",
    "//chrome/browser/apps/app_service:app_registry_cache_waiter",
    "//chrome/browser/ui",
    "//chrome/browser/web_applications",
    "//chrome/browser/web_applications:web_applications_test_support",
    "//chrome/common:chrome_features",
    "//chrome/test:test_support",
    "//chrome/test:test_support_ui",
  ]
}