chromium/extensions/shell/BUILD.gn

# Copyright 2014 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/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//build/util/lastchange.gni")
import("//build/util/process_version.gni")
import("//components/nacl/features.gni")
import("//extensions/buildflags/buildflags.gni")
import("//testing/test.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/v8_context_snapshot/v8_context_snapshot.gni")

if (is_linux || is_chromeos) {
  import("//build/linux/extract_symbols.gni")
}

assert(enable_extensions)

grit("resources") {
  source = "app_shell_resources.grd"
  outputs = [
    "grit/app_shell_resources.h",
    "app_shell_resources.pak",
  ]
}

source_set("app_shell_lib") {
  # TODO(jamescook): investigate and get rid of test dependencies. This library
  # is testonly because it depends on testonly libraries, namely
  # //content/shell:content_shell_lib. See http://crbug.com/438283
  testonly = true
  deps = [
    ":resources",
    ":version_header",
    "//apps",
    "//base",
    "//build:chromeos_buildflags",
    "//components/feedback",
    "//components/feedback/content:factory",
    "//components/guest_view/browser",
    "//components/guest_view/common:mojom",
    "//components/guest_view/renderer",
    "//components/keep_alive_registry",
    "//components/keyed_service/content:content",
    "//components/nacl/common:buildflags",
    "//components/network_session_configurator/common",
    "//components/origin_trials:browser",
    "//components/origin_trials:common",
    "//components/pref_registry",
    "//components/prefs",
    "//components/sessions",
    "//components/storage_monitor",
    "//components/update_client",
    "//components/user_prefs",
    "//components/version_info",
    "//content",
    "//content/shell:content_shell_lib",
    "//device/bluetooth",
    "//extensions:extensions_resources",
    "//extensions:shell_and_test_pak",
    "//extensions/browser",
    "//extensions/browser/kiosk",
    "//extensions/browser/updater",
    "//extensions/common",
    "//extensions/common:core_api_provider",
    "//extensions/common/api",
    "//extensions/renderer",
    "//extensions/shell/browser/system_logs",
    "//extensions/shell/common/api:extensions_features",
    "//services/network/public/mojom",
    "//third_party/blink/public:blink",
    "//third_party/blink/public/common",
    "//ui/base",
    "//ui/base/ime/init",
  ]

  # TODO(michaelpg): remove Mac support and always use aura.
  if (use_aura) {
    deps += [ "//ui/aura" ]
  }

  if (toolkit_views) {
    deps += [ "//ui/views" ]
  }

  sources = [
    "app/shell_main_delegate.cc",
    "app/shell_main_delegate.h",
    "browser/api/feedback_private/shell_feedback_private_delegate.cc",
    "browser/api/feedback_private/shell_feedback_private_delegate.h",
    "browser/api/runtime/shell_runtime_api_delegate.cc",
    "browser/api/runtime/shell_runtime_api_delegate.h",
    "browser/default_shell_browser_main_delegate.cc",
    "browser/default_shell_browser_main_delegate.h",
    "browser/delegates/shell_kiosk_delegate.cc",
    "browser/delegates/shell_kiosk_delegate.h",
    "browser/desktop_controller.cc",
    "browser/desktop_controller.h",
    "browser/shell_app_delegate.cc",
    "browser/shell_app_delegate.h",
    "browser/shell_app_view_guest_delegate.cc",
    "browser/shell_app_view_guest_delegate.h",
    "browser/shell_app_window_client.cc",
    "browser/shell_app_window_client.h",
    "browser/shell_browser_context.cc",
    "browser/shell_browser_context.h",
    "browser/shell_browser_context_keyed_service_factories.cc",
    "browser/shell_browser_context_keyed_service_factories.h",
    "browser/shell_browser_main_delegate.h",
    "browser/shell_browser_main_parts.cc",
    "browser/shell_browser_main_parts.h",
    "browser/shell_content_browser_client.cc",
    "browser/shell_content_browser_client.h",
    "browser/shell_display_info_provider.cc",
    "browser/shell_display_info_provider.h",
    "browser/shell_extension_host_delegate.cc",
    "browser/shell_extension_host_delegate.h",
    "browser/shell_extension_loader.cc",
    "browser/shell_extension_loader.h",
    "browser/shell_extension_system.cc",
    "browser/shell_extension_system.h",
    "browser/shell_extension_system_factory.cc",
    "browser/shell_extension_system_factory.h",
    "browser/shell_extension_web_contents_observer.cc",
    "browser/shell_extension_web_contents_observer.h",
    "browser/shell_extensions_api_client.cc",
    "browser/shell_extensions_api_client.h",
    "browser/shell_extensions_browser_client.cc",
    "browser/shell_extensions_browser_client.h",
    "browser/shell_keep_alive_requester.cc",
    "browser/shell_keep_alive_requester.h",
    "browser/shell_native_app_window.cc",
    "browser/shell_native_app_window.h",
    "browser/shell_navigation_ui_data.cc",
    "browser/shell_navigation_ui_data.h",
    "browser/shell_prefs.cc",
    "browser/shell_prefs.h",
    "browser/shell_special_storage_policy.cc",
    "browser/shell_special_storage_policy.h",
    "browser/shell_speech_recognition_manager_delegate.cc",
    "browser/shell_speech_recognition_manager_delegate.h",
    "browser/shell_update_query_params_delegate.cc",
    "browser/shell_update_query_params_delegate.h",
    "browser/shell_virtual_keyboard_delegate.cc",
    "browser/shell_virtual_keyboard_delegate.h",
    "browser/shell_web_view_guest_delegate.cc",
    "browser/shell_web_view_guest_delegate.h",
    "common/shell_content_client.cc",
    "common/shell_content_client.h",
    "common/shell_extensions_api_provider.cc",
    "common/shell_extensions_api_provider.h",
    "common/shell_extensions_client.cc",
    "common/shell_extensions_client.h",
    "common/switches.cc",
    "common/switches.h",
    "renderer/api/shell_extensions_renderer_api_provider.cc",
    "renderer/api/shell_extensions_renderer_api_provider.h",
    "renderer/shell_content_renderer_client.cc",
    "renderer/shell_content_renderer_client.h",
    "renderer/shell_extensions_renderer_client.cc",
    "renderer/shell_extensions_renderer_client.h",
  ]

  if (is_mac) {
    sources += [
      "app/shell_main_delegate_mac.mm",
      "browser/shell_app_window_client_mac.mm",
      "browser/shell_desktop_controller_mac.h",
      "browser/shell_desktop_controller_mac.mm",
      "browser/shell_native_app_window_mac.h",
      "browser/shell_native_app_window_mac.mm",
    ]
  }

  if (is_chromeos_ash) {
    sources += [
      "browser/shell_audio_controller_chromeos.cc",
      "browser/shell_audio_controller_chromeos.h",
      "browser/shell_network_controller_chromeos.cc",
      "browser/shell_network_controller_chromeos.h",
    ]
  }

  if (use_aura) {
    sources += [
      "browser/root_window_controller.cc",
      "browser/root_window_controller.h",
      "browser/shell_app_window_client_aura.cc",
      "browser/shell_desktop_controller_aura.cc",
      "browser/shell_desktop_controller_aura.h",
      "browser/shell_native_app_window_aura.cc",
      "browser/shell_native_app_window_aura.h",
    ]
    deps += [
      "//ui/base/cursor",
      "//ui/base/cursor/mojom:cursor_type",
      "//ui/platform_window",
      "//ui/wm",
      "//ui/wm/public",
    ]
    if (is_chromeos_ash) {
      deps += [ "//ui/ozone" ]
    }
  }

  if (is_linux || is_chromeos_lacros) {
    sources += [
      "browser/api/file_system/shell_file_system_delegate.cc",
      "browser/api/file_system/shell_file_system_delegate.h",
    ]
    deps += [
      "//build:branding_buildflags",
      "//components/version_info:generate_version_info",
    ]
  }

  if (is_chromeos) {
    deps += [
      "//chromeos/dbus/constants",
      "//chromeos/dbus/power",
    ]
  }

  if (is_chromeos_ash) {
    sources += [
      "browser/shell_screen.cc",
      "browser/shell_screen.h",
    ]
    deps += [
      "//ash/constants",
      "//chromeos/ash/components/audio",
      "//chromeos/ash/components/dbus",
      "//chromeos/ash/components/dbus/audio",
      "//chromeos/ash/components/dbus/cros_disks",
      "//chromeos/ash/components/dbus/hermes",
      "//chromeos/ash/components/dbus/shill",
      "//chromeos/ash/components/disks",
      "//chromeos/ash/components/login/login_state",
      "//chromeos/ash/components/network",
      "//ui/chromeos",
      "//ui/display/manager",
    ]
  }

  if (is_chromeos_lacros) {
    deps += [ "//chromeos/lacros/dbus" ]
  }
  if (enable_nacl) {
    sources += [
      "browser/shell_nacl_browser_delegate.cc",
      "browser/shell_nacl_browser_delegate.h",
    ]

    deps += [
      "//components/nacl/browser",
      "//components/nacl/common",
      "//components/nacl/renderer",
      "//components/nacl/renderer/plugin:nacl_trusted_plugin",
      "//ppapi/shared_impl:shared_impl",
    ]

    # TODO(https://crbug.com/1299021): These dependencies might be
    # redundant given that we were able to disable them, apparently without
    # negative consequences, for the ARM32-NaCl-on-ARM64 case.
    if (target_cpu != "arm64") {
      deps += [ "//components/nacl/loader" ]
      if (is_linux || is_chromeos) {
        deps += [ "//components/nacl/loader:nacl_helper" ]
      }
    }
  }
}

executable("app_shell") {
  # testonly because :app_shell_lib is testonly. See :app_shell_lib comment.
  testonly = true
  sources = [ "app/shell_main.cc" ]

  deps = [
    ":app_shell_lib",
    "//build/win:default_exe_manifest",
    "//content/public/app",
    "//extensions:shell_and_test_pak",
  ]

  if (is_win) {
    configs += [ "//build/config/win:windowed" ]
    configs -= [ "//build/config/win:console" ]
    deps += [ "//sandbox/win:sandbox" ]
  }
}

test("app_shell_unittests") {
  use_xvfb = use_xvfb_in_this_config

  sources = [
    "../test/extensions_unittests_main.cc",
    "browser/shell_content_browser_client_unittest.cc",
    "browser/shell_extension_loader_unittest.cc",
    "browser/shell_keep_alive_requester_unittest.cc",
    "browser/shell_prefs_unittest.cc",
    "browser/system_logs/shell_system_logs_fetcher_unittest.cc",
    "test/shell_test_extensions_browser_client.cc",
    "test/shell_test_extensions_browser_client.h",
  ]

  data = [
    "//extensions/test/data/",
    "$root_out_dir/extensions_shell_and_test.pak",
  ]

  deps = [
    ":app_shell_lib",
    "//apps",
    "//base",
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//components/crx_file",
    "//components/feedback",
    "//components/keep_alive_registry",
    "//components/prefs",
    "//components/user_prefs",
    "//content/test:test_support",
    "//extensions:shell_and_test_pak",
    "//extensions:test_support",
    "//extensions/browser",
    "//extensions/common",
    "//extensions/common/api",
    "//extensions/shell/browser/system_logs",
    "//testing/gtest",
    "//ui/display:test_support",
    "//ui/gl:test_support",
    "//ui/platform_window",
  ]

  data_deps = [
    # "//gin", # TODO(dpranke): Either gin or v8 data is needed ...
    "//third_party/angle:includes",
  ]

  if (use_aura) {
    sources += [
      "browser/root_window_controller_unittest.cc",
      "browser/shell_desktop_controller_aura_unittest.cc",
      "browser/shell_native_app_window_aura_unittest.cc",
      "test/shell_test_base_aura.cc",
      "test/shell_test_base_aura.h",
      "test/shell_test_helper_aura.cc",
      "test/shell_test_helper_aura.h",
    ]
    deps += [
      "//ui/aura:test_support",
      "//ui/base:test_support",
      "//ui/base/ime/init",
      "//ui/compositor:test_support",
    ]
  }

  if (is_chromeos) {
    deps += [ "//chromeos/dbus/power" ]
  }

  if (is_chromeos_ash) {
    sources += [
      "browser/shell_audio_controller_chromeos_unittest.cc",
      "browser/shell_screen_unittest.cc",
    ]
    deps += [
      "//chromeos/ash/components/audio",
      "//chromeos/ash/components/dbus:test_support",
      "//chromeos/ash/components/dbus/audio",
    ]
  }

  if (enable_nacl) {
    sources += [ "browser/shell_nacl_browser_delegate_unittest.cc" ]
  }
}

process_version("version_header") {
  template_file = "common/version.h.in"
  sources = [
    "//chrome/VERSION",
    lastchange_file,
  ]
  output = "$target_gen_dir/common/version.h"
}

source_set("browser_tests") {
  testonly = true
  sources = [
    "browser/api/runtime/runtime_apitest.cc",
    "browser/shell_browsertest.cc",
    "test/extensions_render_view_test.cc",
    "test/extensions_render_view_test.h",
    "test/shell_apitest.cc",
    "test/shell_apitest.h",
    "test/shell_test.cc",
    "test/shell_test.h",
    "test/shell_test_launcher_delegate.cc",
    "test/shell_test_launcher_delegate.h",
    "test/shell_tests_main.cc",
    "test/test_shell_main_delegate.cc",
    "test/test_shell_main_delegate.h",
  ]

  defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]

  deps = [
    ":app_shell_lib",
    "//base",
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//components/keep_alive_registry",
    "//components/version_info",
    "//content/shell:content_shell_lib",
    "//content/test:test_support",
    "//extensions:test_support",
    "//extensions/browser",
    "//extensions/browser:test_support",
    "//extensions/common",
    "//extensions/renderer",
    "//ui/base",
  ]

  if (is_chromeos_lacros) {
    deps += [ "//chromeos/lacros" ]
  }

  if (use_aura) {
    sources += [ "browser/shell_desktop_controller_aura_browsertest.cc" ]
    deps += [ "//ui/aura" ]
  }
}

source_set("unit_tests") {
  testonly = true
  sources = []

  deps = [
    ":app_shell_lib",
    "//base",
    "//base/test:test_support",
    "//extensions/browser",
  ]

  if (is_chromeos_ash) {
    deps += [ "//components/keyed_service/content" ]
  }
}