chromium/chrome/browser/apps/platform_apps/api/BUILD.gn

# Copyright 2018 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("//build/config/features.gni")
import("//chrome/common/apps/platform_apps/api/api_sources.gni")
import("//extensions/buildflags/buildflags.gni")
import("//tools/json_schema_compiler/json_schema_api.gni")

assert(enable_extensions)

function_registration("api_registration") {
  sources = chrome_apps_api_schema_files
  impl_dir = "//chrome/browser/apps/platform_apps/api"
  configs = [ "//build/config:precompiled_headers" ]
  bundle_name = "ChromeApps"
  root_namespace = apps_api_root_namespace

  deps = [
    "//chrome/browser/apps/platform_apps/api",
    "//extensions/browser",
  ]
}

source_set("api") {
  sources = [
    "browser/browser_api.cc",
    "browser/browser_api.h",
    "browser_context_keyed_service_factories.cc",
    "browser_context_keyed_service_factories.h",
    "deprecation_features.cc",
    "deprecation_features.h",
    "media_galleries/blob_data_source_factory.cc",
    "media_galleries/blob_data_source_factory.h",
    "media_galleries/media_galleries_api.cc",
    "media_galleries/media_galleries_api.h",
    "media_galleries/media_galleries_api_util.cc",
    "media_galleries/media_galleries_api_util.h",
    "sync_file_system/extension_sync_event_observer.cc",
    "sync_file_system/extension_sync_event_observer.h",
    "sync_file_system/sync_file_system_api.cc",
    "sync_file_system/sync_file_system_api.h",
    "sync_file_system/sync_file_system_api_helpers.cc",
    "sync_file_system/sync_file_system_api_helpers.h",
  ]

  configs += [ "//build/config/compiler:wexit_time_destructors" ]

  public_deps = [ "//chrome/browser:browser_public_dependencies" ]

  deps = [
    "//build:chromeos_buildflags",
    "//chrome/app:generated_resources_grit",
    "//chrome/browser:primitives",

    # TODO(crbug.com/40593486): It'd be nice to have more APIs here
    # extracted into their own BUILD files (so they are easy to audit, add, or
    # remove), but any that depend on //chrome/browser:browser can't.
    "//chrome/browser:browser_process",
    "//chrome/browser/extensions",
    "//chrome/browser/profiles:profile",
    "//chrome/common",
    "//chrome/common/apps/platform_apps",
    "//chrome/common/apps/platform_apps/api",
    "//chrome/services/media_gallery_util/public/cpp",
    "//components/storage_monitor",
    "//components/web_modal",
    "//extensions/browser",
    "//ui/shell_dialogs",
  ]

  visibility = []

  if (is_chromeos) {
    sources += [
      "enterprise_remote_apps/enterprise_remote_apps_api.cc",
      "enterprise_remote_apps/enterprise_remote_apps_api.h",
    ]

    deps += [ "//chromeos/components/remote_apps/mojom" ]
  }

  if (is_chromeos_ash) {
    # For transition period of crosapi removal.
    visibility += [ "//chrome/browser/ash/crosapi" ]

    sources += [
      "arc_apps_private/arc_apps_private_api.cc",
      "arc_apps_private/arc_apps_private_api.h",
    ]

    deps += [
      "//chrome/browser/ash/app_list/arc",
      "//chrome/browser/ash/login/demo_mode",
      "//chrome/browser/ash/remote_apps",
      "//ui/events:event_constants",
    ]

    # TODO(crbug.com/40251081): Remove these deps. Needed only to allow circular includes.
    deps += [ "//chrome/browser/ash/extensions/file_manager" ]

    # TODO(crbug.com/40251079): Remove circular dependencies.
    allow_circular_includes_from =
        [ "//chrome/browser/ash/extensions/file_manager" ]
  }

  if (use_lld) {
    visibility += [
      "//chrome/browser",
      "//chrome/browser/ui",
    ]
  } else {
    # //chrome/browser:browser and //chrome/browser/ui:* will be split into
    # multiple libraries when not linking with lld.
    visibility += [
      "//chrome/browser:*",
      "//chrome/browser/ui:*",
    ]
  }
  visibility += [
    ":api_registration",
    "//chrome/browser/ash",
    "//chrome/browser/chromeos",
  ]
}