import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//chrome/common/features.gni")
import("//components/spellcheck/spellcheck_build_features.gni")
import("//pdf/features.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//printing/buildflags/buildflags.gni")
import("//extensions/buildflags/buildflags.gni")

source_set("qtwebengine_spellcheck_sources") {
  include_dirs = core_include_dirs
  configs += [
    "//third_party/boringssl:external_config",
  ]
  sources = [
    "//chrome/browser/spellchecker/spell_check_host_chrome_impl.cc",
    "//chrome/browser/spellchecker/spell_check_host_chrome_impl.h",
    "//chrome/browser/spellchecker/spellcheck_custom_dictionary.cc",
    "//chrome/browser/spellchecker/spellcheck_custom_dictionary.h",
    "//chrome/browser/spellchecker/spellcheck_factory.cc",
    "//chrome/browser/spellchecker/spellcheck_factory.h",
    "//chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc",
    "//chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h",
    "//chrome/browser/spellchecker/spellcheck_service.cc",
    "//chrome/browser/spellchecker/spellcheck_service.h",
    "//components/language/core/browser/pref_names.cc",
    "//components/language/core/browser/pref_names.h",
  ]
  deps = [
    "//components/spellcheck/browser",
    "//components/spellcheck/renderer",
    "//third_party/blink/public:blink",
    "//third_party/hunspell",
  ]
  if (is_mac && use_browser_spellchecker) {
    sources += [
        "//chrome/browser/spellchecker/spell_check_host_chrome_impl_mac.cc",
    ]
  }
}

source_set("qtwebengine_sources") {
  configs += [
    "//skia:skia_config",
    "//third_party/boringssl:external_config",
  ]

  deps = [
    "//build:branding_buildflags",
    "//chrome/browser/resources/quota_internals:quota_internals_resources",
    "//chrome/common:buildflags",
    "//components/nacl/common:buildflags",
    "//components/performance_manager",
    "//components/plugins/renderer/",
    "//extensions/buildflags:buildflags",
    "//qtwebengine/common:mojo_bindings",
    "//rlz/buildflags:buildflags",
    "//third_party/blink/public/mojom:mojom_platform",
  ]

  sources = [
    "//chrome/browser/accessibility/accessibility_ui.cc",
    "//chrome/browser/accessibility/accessibility_ui.h",
    "//chrome/browser/custom_handlers/protocol_handler_registry.cc",
    "//chrome/browser/custom_handlers/protocol_handler_registry.h",
    "//chrome/browser/custom_handlers/protocol_handler_registry_factory.cc",
    "//chrome/browser/custom_handlers/protocol_handler_registry_factory.h",
    "//chrome/browser/devtools/devtools_eye_dropper.cc",
    "//chrome/browser/devtools/devtools_eye_dropper.h",
    "//chrome/browser/media/webrtc/desktop_media_list.h",
    "//chrome/browser/net/chrome_mojo_proxy_resolver_factory.cc",
    "//chrome/browser/net/chrome_mojo_proxy_resolver_factory.h",
    "//chrome/browser/prefs/chrome_command_line_pref_store.cc",
    "//chrome/browser/prefs/chrome_command_line_pref_store.h",
    "//chrome/browser/profiles/profile.cc",
    "//chrome/browser/profiles/profile.h",
    "//chrome/browser/tab_contents/form_interaction_tab_helper.cc",
    "//chrome/browser/tab_contents/form_interaction_tab_helper.h",
    "//chrome/browser/ui/webui/devtools_ui.cc",
    "//chrome/browser/ui/webui/devtools_ui.h",
    "//chrome/browser/ui/webui/devtools_ui_data_source.cc",
    "//chrome/browser/ui/webui/devtools_ui_data_source.h",
    "//chrome/browser/ui/webui/net_internals/net_internals_ui.cc",
    "//chrome/browser/ui/webui/net_internals/net_internals_ui.h",
    "//chrome/browser/ui/webui/quota_internals/quota_internals_handler.cc",
    "//chrome/browser/ui/webui/quota_internals/quota_internals_handler.h",
    "//chrome/browser/ui/webui/quota_internals/quota_internals_proxy.cc",
    "//chrome/browser/ui/webui/quota_internals/quota_internals_proxy.h",
    "//chrome/browser/ui/webui/quota_internals/quota_internals_types.cc",
    "//chrome/browser/ui/webui/quota_internals/quota_internals_types.h",
    "//chrome/browser/ui/webui/quota_internals/quota_internals_ui.cc",
    "//chrome/browser/ui/webui/quota_internals/quota_internals_ui.h",
    "//chrome/browser/ui/webui/user_actions/user_actions_ui.cc",
    "//chrome/browser/ui/webui/user_actions/user_actions_ui.h",
    "//chrome/browser/ui/webui/user_actions/user_actions_ui_handler.cc",
    "//chrome/browser/ui/webui/user_actions/user_actions_ui_handler.h",
    "//chrome/browser/ui/webui/webui_util.cc",
    "//chrome/browser/ui/webui/webui_util.h",
    "//chrome/common/custom_handlers/protocol_handler.cc",
    "//chrome/common/custom_handlers/protocol_handler.h",
    "//chrome/common/chrome_switches.cc",
    "//chrome/common/chrome_switches.h",
    "//chrome/common/pref_names.cc",
    "//chrome/common/pref_names.h",
    "//chrome/common/url_constants.cc",
    "//chrome/common/url_constants.h",
    "//chrome/common/webui_url_constants.cc",
    "//chrome/common/webui_url_constants.h",
  ]

  if (enable_extensions) {
    deps += [
      ":qtwebengine_extensions_features",
      "//chrome/app:generated_resources",
      "//chrome/browser/extensions/api:api_registration",
      "//chrome/browser/resources:component_extension_resources_grit",
      "//chrome/common/extensions/api",
      "//chrome/common/extensions/api:api",
      "//chrome/common/extensions/api:extensions_features",
      "//components/crx_file",
      "//components/crx_file:crx_creator",
      "//components/spellcheck:buildflags",
      "//extensions/buildflags:buildflags",
      "//extensions/common",
      "//extensions/common/api",
      "//extensions/common:core_api_provider",
      "//extensions/browser",
      "//extensions/browser/api",
      "//extensions/browser:core_api_provider",
      "//extensions/renderer",
      "//extensions:extensions_resources",
      "//extensions/strings",
      "//qtwebengine/browser/extensions/api:api_registration",
      "//qtwebengine/common/extensions/api:api",
    ]
    sources += [
      "//chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api.cc",
      "//chrome/browser/extensions/api/enterprise_hardware_platform/enterprise_hardware_platform_api.h",
      "//chrome/common/extensions/permissions/chrome_api_permissions.cc",
      "//chrome/common/extensions/permissions/chrome_api_permissions.h",
      "//chrome/common/extensions/permissions/chrome_permission_message_provider.cc",
      "//chrome/common/extensions/permissions/chrome_permission_message_provider.h",
      "//chrome/common/extensions/permissions/chrome_permission_message_rules.cc",
      "//chrome/common/extensions/permissions/chrome_permission_message_rules.h",
    ]
  } else {
    deps += [
      "//extensions/common:common_constants",
    ]
    sources += [
      "//extensions/common/url_pattern.cc",
      "//extensions/common/url_pattern.h",
    ]
  }

  if (is_linux) {
    sources += [
      "//chrome/browser/ui/webui/sandbox/sandbox_internals_ui.cc",
      "//chrome/browser/ui/webui/sandbox/sandbox_internals_ui.h",
    ]
  }

  if (enable_spellcheck) {
    deps += [
      ":qtwebengine_spellcheck_sources",
      "//chrome/tools/convert_dict",
    ]
  }

  if (enable_plugins) {
      sources += [
        "//chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.cc",
        "//chrome/browser/renderer_host/pepper/pepper_flash_clipboard_message_filter.h",
        "//chrome/renderer/pepper/pepper_flash_font_file_host.cc",
        "//chrome/renderer/pepper/pepper_flash_font_file_host.h",
        "//chrome/renderer/pepper/pepper_shared_memory_message_filter.cc",
        "//chrome/renderer/pepper/pepper_shared_memory_message_filter.h",
      ]
  }

  if (enable_basic_printing || enable_print_preview) {
    sources += [
      "//chrome/browser/printing/printer_query.cc",
      "//chrome/browser/printing/printer_query.h",
      "//chrome/browser/printing/print_job.cc",
      "//chrome/browser/printing/print_job.h",
      "//chrome/browser/printing/print_job_manager.cc",
      "//chrome/browser/printing/print_job_manager.h",
      "//chrome/browser/printing/print_job_worker.cc",
      "//chrome/browser/printing/print_job_worker.h",
    ]
    deps += [
      "//printing/buildflags:buildflags",
    ]
  }

  if (enable_pdf) {
      deps += [
         "//pdf",
         "//pdf:buildflags",
         "//pdf:pdf_ppapi",
         "//components/pdf/browser:browser",
         "//components/pdf/renderer:renderer",
         "//components/printing/browser",
         "//components/printing/renderer"
      ]
      sources += [
         "//chrome/browser/extensions/api/streams_private/streams_private_api.cc",
      ]
  }

  if (enable_webrtc && enable_extensions) {
    deps += [
      "//chrome/browser/resources/media:webrtc_logs_resources",
      "//components/upload_list",
      "//components/webrtc_logging/browser",
      "//components/webrtc_logging/common",
    ]

    sources += [
      "//chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.cc",
      "//chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.h",
      "//chrome/browser/media/webrtc/audio_debug_recordings_handler.cc",
      "//chrome/browser/media/webrtc/audio_debug_recordings_handler.h",
      "//chrome/browser/media/webrtc/webrtc_event_log_history.cc",
      "//chrome/browser/media/webrtc/webrtc_event_log_history.h",
      "//chrome/browser/media/webrtc/webrtc_event_log_manager.cc",
      "//chrome/browser/media/webrtc/webrtc_event_log_manager.h",
      "//chrome/browser/media/webrtc/webrtc_event_log_manager_common.cc",
      "//chrome/browser/media/webrtc/webrtc_event_log_manager_common.h",
      "//chrome/browser/media/webrtc/webrtc_event_log_manager_local.cc",
      "//chrome/browser/media/webrtc/webrtc_event_log_manager_local.h",
      "//chrome/browser/media/webrtc/webrtc_event_log_manager_remote.cc",
      "//chrome/browser/media/webrtc/webrtc_event_log_manager_remote.h",
      "//chrome/browser/media/webrtc/webrtc_event_log_uploader.cc",
      "//chrome/browser/media/webrtc/webrtc_event_log_uploader.h",
      "//chrome/browser/media/webrtc/webrtc_log_buffer.cc",
      "//chrome/browser/media/webrtc/webrtc_log_buffer.h",
      "//chrome/browser/media/webrtc/webrtc_log_uploader.cc",
      "//chrome/browser/media/webrtc/webrtc_log_uploader.h",
      "//chrome/browser/media/webrtc/webrtc_logging_controller.cc",
      "//chrome/browser/media/webrtc/webrtc_logging_controller.h",
      "//chrome/browser/media/webrtc/webrtc_rtp_dump_handler.cc",
      "//chrome/browser/media/webrtc/webrtc_rtp_dump_handler.h",
      "//chrome/browser/media/webrtc/webrtc_rtp_dump_writer.cc",
      "//chrome/browser/media/webrtc/webrtc_rtp_dump_writer.h",
      "//chrome/browser/media/webrtc/webrtc_text_log_handler.cc",
      "//chrome/browser/media/webrtc/webrtc_text_log_handler.h",
      "//chrome/browser/ui/webui/media/webrtc_logs_ui.cc",
      "//chrome/browser/ui/webui/media/webrtc_logs_ui.h",
      "//chrome/renderer/media/webrtc_logging_agent_impl.cc",
      "//chrome/renderer/media/webrtc_logging_agent_impl.h",
    ]
  }
}

if (is_win) {
  shared_library("qtwebengine_sandbox_win") {
    create_pri_file = true
    public_deps = [ "//sandbox/win:sandbox" ]
  }
}
