chromium/components/permissions/BUILD.gn

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

import("//device/vr/buildflags/buildflags.gni")
import("//services/device/public/cpp/geolocation/buildflags.gni")

source_set("permissions_common") {
  sources = [
    "constants.cc",
    "constants.h",
    "features.cc",
    "features.h",
    "permission_request_enums.h",
    "request_type.h",
  ]
  defines = [ "IS_PERMISSIONS_COMMON_IMPL" ]
  deps = [
    "//base",
    "//build:chromeos_buildflags",
    "//components/content_settings/core/common",
  ]
  public_deps = [ "//printing/buildflags" ]
}

source_set("permissions") {
  sources = [
    "bluetooth_delegate_impl.cc",
    "bluetooth_delegate_impl.h",
    "chooser_controller.cc",
    "chooser_controller.h",
    "contexts/accessibility_permission_context.cc",
    "contexts/accessibility_permission_context.h",
    "contexts/automatic_fullscreen_permission_context.cc",
    "contexts/automatic_fullscreen_permission_context.h",
    "contexts/bluetooth_chooser_context.cc",
    "contexts/bluetooth_chooser_context.h",
    "contexts/camera_pan_tilt_zoom_permission_context.cc",
    "contexts/camera_pan_tilt_zoom_permission_context.h",
    "contexts/clipboard_read_write_permission_context.cc",
    "contexts/clipboard_read_write_permission_context.h",
    "contexts/clipboard_sanitized_write_permission_context.cc",
    "contexts/clipboard_sanitized_write_permission_context.h",
    "contexts/geolocation_permission_context.cc",
    "contexts/geolocation_permission_context.h",
    "contexts/keyboard_lock_permission_context.cc",
    "contexts/keyboard_lock_permission_context.h",
    "contexts/local_fonts_permission_context.cc",
    "contexts/local_fonts_permission_context.h",
    "contexts/midi_permission_context.cc",
    "contexts/midi_permission_context.h",
    "contexts/midi_sysex_permission_context.cc",
    "contexts/midi_sysex_permission_context.h",
    "contexts/nfc_permission_context.cc",
    "contexts/nfc_permission_context.h",
    "contexts/payment_handler_permission_context.cc",
    "contexts/payment_handler_permission_context.h",
    "contexts/pointer_lock_permission_context.cc",
    "contexts/pointer_lock_permission_context.h",
    "contexts/sensor_permission_context.cc",
    "contexts/sensor_permission_context.h",
    "contexts/speaker_selection_permission_context.cc",
    "contexts/speaker_selection_permission_context.h",
    "contexts/wake_lock_permission_context.cc",
    "contexts/wake_lock_permission_context.h",
    "contexts/web_app_installation_permission_context.cc",
    "contexts/web_app_installation_permission_context.h",
    "contexts/webxr_permission_context.cc",
    "contexts/webxr_permission_context.h",
    "contexts/window_management_permission_context.cc",
    "contexts/window_management_permission_context.h",
    "notifications_engagement_service.cc",
    "notifications_engagement_service.h",
    "object_permission_context_base.cc",
    "object_permission_context_base.h",
    "origin_keyed_permission_action_service.cc",
    "origin_keyed_permission_action_service.h",
    "permission_actions_history.cc",
    "permission_actions_history.h",
    "permission_auditing_database.cc",
    "permission_auditing_database.h",
    "permission_auditing_service.cc",
    "permission_auditing_service.h",
    "permission_context_base.cc",
    "permission_context_base.h",
    "permission_decision_auto_blocker.cc",
    "permission_decision_auto_blocker.h",
    "permission_hats_trigger_helper.cc",
    "permission_hats_trigger_helper.h",
    "permission_indicators_tab_data.cc",
    "permission_indicators_tab_data.h",
    "permission_manager.cc",
    "permission_manager.h",
    "permission_prompt.h",
    "permission_recovery_success_rate_tracker.cc",
    "permission_recovery_success_rate_tracker.h",
    "permission_request.cc",
    "permission_request.h",
    "permission_request_data.cc",
    "permission_request_data.h",
    "permission_request_id.cc",
    "permission_request_id.h",
    "permission_request_manager.cc",
    "permission_request_manager.h",
    "permission_request_queue.cc",
    "permission_request_queue.h",
    "permission_ui_selector.cc",
    "permission_ui_selector.h",
    "permission_uma_util.cc",
    "permission_uma_util.h",
    "permission_usage_session.cc",
    "permission_usage_session.h",
    "permission_util.cc",
    "permission_util.h",
    "permissions_client.cc",
    "permissions_client.h",
    "pref_names.cc",
    "pref_names.h",
    "request_type.cc",
    "request_type.h",
    "switches.cc",
    "switches.h",
  ]
  deps = [
    "//base",
    "//build:chromeos_buildflags",
    "//components/back_forward_cache",
    "//components/content_settings/browser",
    "//components/content_settings/core/browser",
    "//components/content_settings/core/browser:cookie_settings",
    "//components/favicon/core:core",
    "//components/keyed_service/content",
    "//components/permissions/prediction_service",
    "//components/permissions/vector_icons",
    "//components/pref_registry",
    "//components/prefs",
    "//components/strings:components_branded_strings_grit",
    "//components/strings:components_strings_grit",
    "//components/ukm/content",
    "//components/url_formatter",
    "//components/variations",
    "//components/vector_icons",
    "//components/webrtc:media_stream_device_enumerator",
    "//content/public/browser",
    "//device/bluetooth",
    "//device/bluetooth/public/cpp",
    "//services/device/public/cpp/geolocation",
    "//services/device/public/mojom",
    "//services/metrics/public/cpp:ukm_builders",
    "//sql",
    "//third_party/blink/public/common",
    "//ui/base",
    "//ui/strings:ui_strings_grit",
    "//url",
  ]
  if (enable_vr) {
    deps += [ "//device/vr/public/cpp" ]
  }
  if (os_level_geolocation_permission_supported) {
    sources += [
      "contexts/geolocation_permission_context_system.cc",
      "contexts/geolocation_permission_context_system.h",
    ]
  }
  if (!is_android) {
    deps += [ "//components/guest_view/browser" ]
  }
  if (is_android) {
    sources += [
      "android/android_permission_util.cc",
      "android/android_permission_util.h",
      "android/bluetooth_chooser_android.cc",
      "android/bluetooth_chooser_android.h",
      "android/bluetooth_chooser_android_delegate.h",
      "android/bluetooth_scanning_prompt_android.cc",
      "android/bluetooth_scanning_prompt_android.h",
      "android/bluetooth_scanning_prompt_android_delegate.h",
      "android/permission_prompt/permission_dialog.cc",
      "android/permission_prompt/permission_dialog.h",
      "android/permission_prompt/permission_dialog_delegate.cc",
      "android/permission_prompt/permission_dialog_delegate.h",
      "android/permission_prompt/permission_message.cc",
      "android/permission_prompt/permission_message.h",
      "android/permission_prompt/permission_prompt_android.cc",
      "android/permission_prompt/permission_prompt_android.h",
      "android/permission_prompt/permission_prompt_android_factory.cc",
      "android/permission_prompt/permission_prompt_infobar.cc",
      "android/permission_prompt/permission_prompt_infobar.h",
      "android/permissions_android_feature_map.cc",
      "android/permissions_android_feature_map.h",
      "android/permissions_reprompt_controller_android.cc",
      "android/permissions_reprompt_controller_android.h",
      "contexts/geolocation_permission_context_android.cc",
      "contexts/geolocation_permission_context_android.h",
      "contexts/nfc_permission_context_android.cc",
      "contexts/nfc_permission_context_android.h",
    ]
    deps += [
      "//components/favicon_base:favicon_base",
      "//components/infobars/core",
      "//components/location/android:location_settings_dialog_enums_java",
      "//components/location/android:settings",
      "//components/messages/android:android",
      "//components/permissions/android:core_jni",
      "//components/permissions/android:jni_headers",
      "//components/permissions/android:native",
      "//components/prefs",
      "//components/resources:android_resources",
      "//components/security_state/core:core",
      "//components/strings:components_strings_grit",

      # Our corresponding java library references Java files which use the
      # jni depended on here.
      "//components/webxr/android:features",
      "//third_party/jni_zero",
      "//ui/android",
    ]
  } else {
    sources += [
      "bluetooth_chooser_controller.cc",
      "bluetooth_chooser_controller.h",
      "bluetooth_chooser_desktop.cc",
      "bluetooth_chooser_desktop.h",
      "bluetooth_scanning_prompt_controller.cc",
      "bluetooth_scanning_prompt_controller.h",
      "bluetooth_scanning_prompt_desktop.cc",
      "bluetooth_scanning_prompt_desktop.h",
      "permission_prompt_impl.cc",
    ]
  }

  public_deps = [ ":permissions_common" ]

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

source_set("test_support") {
  testonly = true
  sources = [
    "test/mock_permission_prompt.cc",
    "test/mock_permission_prompt.h",
    "test/mock_permission_prompt_factory.cc",
    "test/mock_permission_prompt_factory.h",
    "test/mock_permission_request.cc",
    "test/mock_permission_request.h",
    "test/object_permission_context_base_mock_permission_observer.cc",
    "test/object_permission_context_base_mock_permission_observer.h",
    "test/permission_request_observer.cc",
    "test/permission_request_observer.h",
    "test/permission_test_util.cc",
    "test/permission_test_util.h",
    "test/test_permissions_client.cc",
    "test/test_permissions_client.h",
  ]
  if (!is_android) {
    sources += [
      "fake_bluetooth_chooser_controller.cc",
      "fake_bluetooth_chooser_controller.h",
      "fake_usb_chooser_controller.cc",
      "fake_usb_chooser_controller.h",
      "mock_chooser_controller_view.cc",
      "mock_chooser_controller_view.h",
    ]
  }

  deps = [
    ":permissions",
    "//base",
    "//components/content_settings/core/browser",
    "//components/content_settings/core/browser:cookie_settings",
    "//components/privacy_sandbox:tracking_protection_settings",
    "//components/strings:components_branded_strings_grit",
    "//components/strings:components_strings_grit",
    "//components/sync_preferences:test_support",
    "//components/ukm/content",
    "//components/vector_icons",
    "//content/public/browser",
    "//services/device/public/cpp:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//ui/gfx",
    "//url",
  ]
  if (is_android) {
    deps += [ "//components/resources:android_resources" ]
  }
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "contexts/camera_pan_tilt_zoom_permission_context_unittest.cc",
    "contexts/geolocation_permission_context_unittest.cc",
    "contexts/midi_permission_context_unittest.cc",
    "contexts/midi_sysex_permission_context_unittest.cc",
    "contexts/nfc_permission_context_unittest.cc",
    "contexts/wake_lock_permission_context_unittest.cc",
    "object_permission_context_base_unittest.cc",
    "pepc_initiated_permission_request_unittest.cc",
    "permission_actions_history_unittest.cc",
    "permission_auditing_database_unittest.cc",
    "permission_auditing_service_unittest.cc",
    "permission_context_base_unittest.cc",
    "permission_decision_auto_blocker_unittest.cc",
    "permission_manager_unittest.cc",
    "permission_request_manager_unittest.cc",
    "permission_request_queue_unittest.cc",
    "permission_uma_util_unittest.cc",
  ]
  if (!is_android) {
    sources += [
      "bluetooth_chooser_controller_unittest.cc",
      "bluetooth_scanning_prompt_controller_unittest.cc",
    ]
  }
  if (is_android) {
    sources += [
      "android/bluetooth_chooser_android_unittest.cc",
      "android/bluetooth_scanning_prompt_android_unittest.cc",
      "android/permission_prompt/permission_dialog_delegate_unittest.cc",
      "android/permissions_reprompt_controller_android_unittest.cc",
    ]
  }
  deps = [
    ":permissions",
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//components/content_settings/browser",
    "//components/content_settings/browser:test_support",
    "//components/content_settings/core/browser",
    "//components/keyed_service/content",
    "//components/prefs:test_support",
    "//components/security_state/core",
    "//components/strings:components_strings_grit",
    "//components/sync_preferences:test_support",
    "//components/ukm:test_support",
    "//components/ukm/content",
    "//components/variations",
    "//components/webrtc",
    "//content/test:test_support",
    "//services/device/public/cpp:device_features",
    "//services/device/public/cpp:test_support",
    "//sql",
    "//sql:test_support",
    "//testing/gtest",
    "//url",
  ]
  if (is_android) {
    deps += [
      "//components/location/android:location_settings_dialog_enums_java",
      "//components/location/android:test_support",
      "//components/permissions/android:test_support",
      "//ui/android",
    ]
  }
}