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

import("//build/config/features.gni")

# GYP version: extensions/extensions.gyp:extensions_common
source_set("common") {
  sources = [
    "api/messaging/message.h",
    "api/bluetooth/bluetooth_manifest_data.cc",
    "api/bluetooth/bluetooth_manifest_data.h",
    "api/bluetooth/bluetooth_manifest_handler.cc",
    "api/bluetooth/bluetooth_manifest_handler.h",
    "api/bluetooth/bluetooth_manifest_permission.cc",
    "api/bluetooth/bluetooth_manifest_permission.h",
    "api/sockets/sockets_manifest_data.cc",
    "api/sockets/sockets_manifest_data.h",
    "api/sockets/sockets_manifest_handler.cc",
    "api/sockets/sockets_manifest_handler.h",
    "api/sockets/sockets_manifest_permission.cc",
    "api/sockets/sockets_manifest_permission.h",
    "common_manifest_handlers.cc",
    "common_manifest_handlers.h",
    "constants.cc",
    "constants.h",
    "csp_validator.cc",
    "csp_validator.h",
    "dom_action_types.h",
    "draggable_region.cc",
    "draggable_region.h",
    "error_utils.cc",
    "error_utils.h",
    "event_filter.cc",
    "event_filter.h",
    "event_filtering_info.cc",
    "event_filtering_info.h",
    "event_matcher.cc",
    "event_matcher.h",
    "extension.cc",
    "extension.h",
    "extension_api.cc",
    "extension_api.h",
    "extension_api_stub.cc",
    "extension_icon_set.cc",
    "extension_icon_set.h",
    "extension_l10n_util.cc",
    "extension_l10n_util.h",
    "extension_message_generator.cc",
    "extension_message_generator.h",
    "extension_messages.cc",
    "extension_messages.h",
    "extension_paths.cc",
    "extension_paths.h",
    "extension_resource.cc",
    "extension_resource.h",
    "extension_set.cc",
    "extension_set.h",
    "extension_urls.cc",
    "extension_urls.h",
    "extensions_client.cc",
    "extensions_client.h",
    "feature_switch.cc",
    "feature_switch.h",
    "features/api_feature.cc",
    "features/api_feature.h",
    "features/base_feature_provider.cc",
    "features/base_feature_provider.h",
    "features/complex_feature.cc",
    "features/complex_feature.h",
    "features/feature.cc",
    "features/feature.h",
    "features/feature_provider.cc",
    "features/feature_provider.h",
    "features/json_feature_provider_source.cc",
    "features/json_feature_provider_source.h",
    "features/manifest_feature.cc",
    "features/manifest_feature.h",
    "features/permission_feature.cc",
    "features/permission_feature.h",
    "features/simple_feature.cc",
    "features/simple_feature.h",
    "features/simple_feature_filter.cc",
    "features/simple_feature_filter.h",
    "file_util.cc",
    "file_util.h",
    "guest_view/guest_view_constants.cc",
    "guest_view/guest_view_constants.h",
    "install_warning.cc",
    "install_warning.h",
    "manifest.cc",
    "manifest.h",
    "manifest_constants.cc",
    "manifest_constants.h",
    "manifest_handler.cc",
    "manifest_handler.h",
    "manifest_handler_helpers.cc",
    "manifest_handler_helpers.h",
    "manifest_handlers/background_info.cc",
    "manifest_handlers/background_info.h",
    "manifest_handlers/csp_info.cc",
    "manifest_handlers/csp_info.h",
    "manifest_handlers/externally_connectable.cc",
    "manifest_handlers/externally_connectable.h",
    "manifest_handlers/file_handler_info.cc",
    "manifest_handlers/file_handler_info.h",
    "manifest_handlers/icons_handler.cc",
    "manifest_handlers/icons_handler.h",
    "manifest_handlers/incognito_info.cc",
    "manifest_handlers/incognito_info.h",
    "manifest_handlers/kiosk_mode_info.cc",
    "manifest_handlers/kiosk_mode_info.h",
    "manifest_handlers/launcher_page_info.cc",
    "manifest_handlers/launcher_page_info.h",
    "manifest_handlers/offline_enabled_info.cc",
    "manifest_handlers/offline_enabled_info.h",
    "manifest_handlers/options_page_info.cc",
    "manifest_handlers/options_page_info.h",
    "manifest_handlers/permissions_parser.cc",
    "manifest_handlers/permissions_parser.h",
    "manifest_handlers/requirements_info.cc",
    "manifest_handlers/requirements_info.h",
    "manifest_handlers/sandboxed_page_info.cc",
    "manifest_handlers/sandboxed_page_info.h",
    "manifest_handlers/shared_module_info.cc",
    "manifest_handlers/shared_module_info.h",
    "manifest_handlers/web_accessible_resources_info.cc",
    "manifest_handlers/web_accessible_resources_info.h",
    "manifest_handlers/webview_info.cc",
    "manifest_handlers/webview_info.h",
    "message_bundle.cc",
    "message_bundle.h",
    "one_shot_event.cc",
    "one_shot_event.h",
    "permissions/api_permission.cc",
    "permissions/api_permission.h",
    "permissions/api_permission_set.cc",
    "permissions/api_permission_set.h",
    "permissions/base_set_operators.h",
    "permissions/extensions_api_permissions.cc",
    "permissions/extensions_api_permissions.h",
    "permissions/manifest_permission.cc",
    "permissions/manifest_permission.h",
    "permissions/manifest_permission_set.cc",
    "permissions/manifest_permission_set.h",
    "permissions/media_galleries_permission.cc",
    "permissions/media_galleries_permission.h",
    "permissions/media_galleries_permission_data.cc",
    "permissions/media_galleries_permission_data.h",
    "permissions/permission_message.cc",
    "permissions/permission_message.h",
    "permissions/permission_message_provider.cc",
    "permissions/permission_message_provider.h",
    "permissions/permission_message_util.cc",
    "permissions/permission_message_util.h",
    "permissions/permission_set.cc",
    "permissions/permission_set.h",
    "permissions/permissions_data.cc",
    "permissions/permissions_data.h",
    "permissions/permissions_info.cc",
    "permissions/permissions_info.h",
    "permissions/permissions_provider.h",
    "permissions/set_disjunction_permission.h",
    "permissions/settings_override_permission.cc",
    "permissions/settings_override_permission.h",
    "permissions/socket_permission.cc",
    "permissions/socket_permission.h",
    "permissions/socket_permission_data.cc",
    "permissions/socket_permission_data.h",
    "permissions/socket_permission_entry.cc",
    "permissions/socket_permission_entry.h",
    "permissions/usb_device_permission.cc",
    "permissions/usb_device_permission.h",
    "permissions/usb_device_permission_data.cc",
    "permissions/usb_device_permission_data.h",
    "stack_frame.cc",
    "stack_frame.h",
    "switches.cc",
    "switches.h",
    "update_manifest.cc",
    "update_manifest.h",
    "url_pattern.cc",
    "url_pattern.h",
    "url_pattern_set.cc",
    "url_pattern_set.h",
    "user_script.cc",
    "user_script.h",
    "value_counter.cc",
    "value_counter.h",
    "view_type.cc",
    "view_type.h",
  ]

  deps = [
    # TODO(benwells): figure out what to do with the api target and
    # api resources compiled into the chrome resource bundle.
    # http://crbug.com/162530
    "//chrome:resources",
    "//components/crx_file",
    "//components/url_matcher",
    "//content/public/common",
    "//crypto",
    "//extensions/strings",
    "//ipc",
    "//net",
    "//third_party/icu",
    "//third_party/libxml",
    "//third_party/re2",
    "//ui/base",
    "//ui/gfx/geometry",
    "//ui/gfx/ipc",
    "//url",
  ]

  if (enable_extensions) {
    sources -= [
      "extension_api_stub.cc",
    ]

    deps += [
      "//device/bluetooth",
      "//device/usb",
      "//extensions/common/api",
    ]
  } else {
    sources -= [
      "api/bluetooth/bluetooth_manifest_data.cc",
      "api/bluetooth/bluetooth_manifest_data.h",
      "api/bluetooth/bluetooth_manifest_handler.cc",
      "api/bluetooth/bluetooth_manifest_handler.h",
      "api/bluetooth/bluetooth_manifest_permission.cc",
      "api/bluetooth/bluetooth_manifest_permission.h",
      "api/messaging/message.h",
      "api/sockets/sockets_manifest_data.cc",
      "api/sockets/sockets_manifest_data.h",
      "api/sockets/sockets_manifest_handler.cc",
      "api/sockets/sockets_manifest_handler.h",
      "api/sockets/sockets_manifest_permission.cc",
      "api/sockets/sockets_manifest_permission.h",
      "extension_api.cc",
      "manifest_handlers/externally_connectable.cc",
      "manifest_handlers/externally_connectable.h",
      "manifest_handlers/options_page_info.cc",
      "manifest_handlers/options_page_info.h",
    ]
  }

  if (enable_nacl) {
    sources += [
      "manifest_handlers/nacl_modules_handler.cc",
      "manifest_handlers/nacl_modules_handler.h",
    ]
  }

  if (is_win) {
    cflags = [
      "/wd4267", # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
    ]
  }
}