chromium/components/live_caption/BUILD.gn

# Copyright 2021 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/ui.gni")

if (!is_android && !is_ios) {
  static_library("live_caption") {
    sources = [
      "caption_bubble_context.h",
      "caption_bubble_context_remote.cc",
      "caption_bubble_context_remote.h",
      "caption_bubble_controller.h",
      "caption_bubble_session_observer.h",
    ]

    deps = [
      "//base",
      "//components/keyed_service/core",
      "//components/live_caption:constants",
      "//components/live_caption:utils",
      "//components/pref_registry",
      "//components/prefs",
      "//components/soda",
      "//components/soda:constants",
      "//components/sync_preferences",
      "//media",
      "//media/mojo/mojom",
      "//mojo/public/cpp/bindings",
      "//ui/native_theme",
    ]

    if (toolkit_views) {
      sources += [
        "views/caption_bubble.cc",
        "views/caption_bubble.h",
        "views/caption_bubble_controller_views.cc",
        "views/caption_bubble_controller_views.h",
        "views/caption_bubble_model.cc",
        "views/caption_bubble_model.h",
      ]

      public_deps = [ "//ui/base/mojom:ui_base_types" ]

      deps += [
        "//components/strings",
        "//components/vector_icons",
        "//third_party/re2",
        "//ui/accessibility",
        "//ui/base",
        "//ui/compositor",
        "//ui/gfx",
        "//ui/strings:ui_strings_grit",
        "//ui/views",
      ]
    }  # toolkit_views

    if (is_chromeos_ash) {
      sources += [
        "live_caption_ui_remote_driver.cc",
        "live_caption_ui_remote_driver.h",
      ]
    }  # is_chromeos_ash

    if (!is_chromeos_lacros) {
      sources += [
        "live_caption_controller.cc",
        "live_caption_controller.h",
      ]
    }
  }

  static_library("live_translate") {
    sources = [
      "greedy_text_stabilizer.cc",
      "greedy_text_stabilizer.h",
      "live_translate_controller.cc",
      "live_translate_controller.h",
    ]

    deps = [
      "//base",
      "//components/keyed_service/core",
      "//components/live_caption:constants",
      "//components/live_caption:utils",
      "//components/pref_registry",
      "//components/prefs",
      "//components/soda",
      "//components/soda:constants",
      "//components/sync_preferences",
      "//content/public/browser",
      "//google_apis:google_apis",
      "//media",
      "//media/mojo/mojom",
      "//services/data_decoder/public/cpp:cpp",
      "//services/data_decoder/public/mojom:mojom",
      "//services/network/public/cpp",
      "//services/network/public/mojom",
      "//ui/native_theme",
    ]
  }

  source_set("unit_tests") {
    testonly = true

    sources = [ "greedy_text_stabilizer_unittest.cc" ]

    if (is_chromeos_ash) {
      sources += [ "caption_bubble_context_remote_unittest.cc" ]
    }

    deps = [
      ":live_caption",
      ":live_translate",
      "//base",
      "//base/test:test_support",
      "//media/mojo/mojom:speech_recognition",
      "//mojo/public/cpp/bindings:bindings",
      "//testing/gmock",
      "//testing/gtest",
      "//ui/gfx/geometry:geometry",
    ]
  }
}  # !is_android

source_set("constants") {
  sources = [
    "pref_names.cc",
    "pref_names.h",
  ]

  deps = [
    "//base",
    "//components/prefs",
    "//media",
  ]

  if (!is_android) {
    deps += [ "//components/soda:constants" ]
  }
}

source_set("utils") {
  sources = [
    "caption_util.cc",
    "caption_util.h",
    "translation_util.cc",
    "translation_util.h",
  ]

  deps = [
    ":constants",
    "//base",
    "//components/prefs",
    "//media",
    "//third_party/icu",
    "//third_party/re2:re2",
    "//ui/base",
    "//ui/native_theme",
  ]

  if (!is_android) {
    deps += [ "//components/soda:utils" ]
  }
}