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

source_set("external_protocol") {
  sources = [
    "constants.h",
    "external_protocol_handler.h",
    "external_protocol_observer.h",
  ]

  public_deps = [
    "//chrome/browser:shell_integration",
    "//content/public/browser",
    "//ui/base",
  ]

  if (!is_android && !is_chromeos) {
    sources += [ "auto_launch_protocols_policy_handler.h" ]
    public_deps += [ "//components/policy/core/browser" ]
  }
}

source_set("impl") {
  sources = [
    "constants.cc",
    "external_protocol_handler.cc",
    "external_protocol_observer.cc",
  ]

  public_deps = [ ":external_protocol" ]

  deps = [
    "//base",
    "//chrome/browser:browser_process",
    "//chrome/browser:primitives",
    "//chrome/browser/profiles:profile",
    "//chrome/browser/safe_browsing",
    "//chrome/browser/ui/browser_window",
    "//chrome/common:constants",
    "//components/prefs",
    "//components/url_matcher",
    "//services/network/public/cpp",
    "//third_party/blink/public/common",
    "//url",
  ]

  if (is_android) {
    deps += [ "//components/navigation_interception" ]
  } else {
    deps += [
      "//components/url_formatter",
      "//components/web_modal",
    ]
  }

  if (!is_android && !is_chromeos) {
    sources += [ "auto_launch_protocols_policy_handler.cc" ]
  }
}

source_set("unit_tests") {
  testonly = true

  sources = [ "external_protocol_handler_unittest.cc" ]

  deps = [
    ":external_protocol",
    ":impl",
    "//base",
    "//chrome/browser/prefs",
    "//chrome/common:constants",
    "//chrome/test:test_support",
    "//components/prefs",
    "//components/prefs:test_support",
    "//content/public/browser",
    "//content/test:test_support",
    "//testing/gtest",
  ]

  if (is_android) {
    deps += [ "//components/navigation_interception" ]
  } else {
    deps += [ "//components/web_modal" ]
  }
}

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

    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]

    sources = [
      "external_protocol_handler_browsertest.cc",
      "external_protocol_policy_browsertest.cc",
    ]

    deps = [
      ":external_protocol",
      ":impl",
      "//base",
      "//chrome/browser:browser_features",
      "//chrome/browser:shell_integration",
      "//chrome/browser/policy:test_support",
      "//chrome/browser/profiles:profile",
      "//chrome/browser/ui",
      "//chrome/test:test_support",
      "//chrome/test:test_support_ui",
      "//components/policy:generated",
      "//components/policy/core/browser",
      "//components/policy/core/common",
      "//components/prefs",
      "//content/public/browser",
      "//content/test:test_support",
      "//testing/gtest",
    ]
  }
}
