# Copyright 2017 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")
if (is_android) {
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
import("//third_party/jni_zero/jni_zero.gni")
}
source_set("geolocation") {
visibility = [
":*",
"//services/device:*",
]
sources = [
"geolocation_config.cc",
"geolocation_config.h",
"geolocation_context.cc",
"geolocation_context.h",
"geolocation_impl.cc",
"geolocation_impl.h",
"geolocation_provider.h",
"geolocation_provider_impl.cc",
"geolocation_provider_impl.h",
"location_provider_manager.cc",
"location_provider_manager.h",
"network_location_request.cc",
"network_location_request.h",
"position_cache.h",
"position_cache_impl.cc",
"position_cache_impl.h",
"public_ip_address_geolocation_provider.cc",
"public_ip_address_geolocation_provider.h",
"public_ip_address_geolocator.cc",
"public_ip_address_geolocator.h",
"public_ip_address_location_notifier.cc",
"public_ip_address_location_notifier.h",
"wifi_data.cc",
"wifi_data.h",
"wifi_data_provider.cc",
"wifi_data_provider.h",
"wifi_data_provider_handle.cc",
"wifi_data_provider_handle.h",
"wifi_polling_policy.cc",
"wifi_polling_policy.h",
]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
deps = [
"//base",
"//components/device_event_log",
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/system",
"//net",
"//services/device/public/cpp:device_features",
"//services/device/public/mojom:geolocation_internals",
"//ui/gfx",
]
public_deps = [
"//services/device/public/cpp/geolocation",
"//services/device/public/mojom",
"//services/network/public/cpp",
]
if (is_android) {
sources += [
"location_api_adapter_android.cc",
"location_api_adapter_android.h",
"location_provider_android.cc",
"location_provider_android.h",
]
deps += [ ":geolocation_jni_headers" ]
} else {
sources += [
"network_location_provider.cc",
"network_location_provider.h",
"wifi_data_provider_common.cc",
"wifi_data_provider_common.h",
]
}
if (is_apple) {
frameworks = [ "Security.framework" ]
sources += [
"core_location_provider.cc",
"core_location_provider.h",
]
}
if (is_win) {
sources += [
"win/location_provider_winrt.cc",
"win/location_provider_winrt.h",
]
deps += [ "//services/device/public/cpp:device_features" ]
}
# Platform-specific WifiDataProvider implementations.
if (is_chromeos_ash) {
sources += [
"wifi_data_provider_chromeos.cc",
"wifi_data_provider_chromeos.h",
]
deps += [ "//chromeos/ash/components/network" ]
} else if (is_linux && use_dbus) {
sources += [
"wifi_data_provider_linux.cc",
"wifi_data_provider_linux.h",
]
deps += [ "//dbus" ]
} else if (is_chromeos_lacros) {
sources += [
"wifi_data_provider_lacros.cc",
"wifi_data_provider_lacros.h",
]
deps += [
"//chromeos/crosapi/mojom",
"//chromeos/lacros",
]
} else if (is_mac) {
frameworks += [
"CoreWLAN.framework",
"Foundation.framework",
]
sources += [
"wifi_data_provider_mac.h",
"wifi_data_provider_mac.mm",
]
} else if (is_win) {
sources += [
"wifi_data_provider_common_win.cc",
"wifi_data_provider_common_win.h",
"wifi_data_provider_win.cc",
"wifi_data_provider_win.h",
]
} else {
# WifiDataProviderHandle declares a static factory method that is defined
# by the platform implementation. Platforms with no Wi-Fi data provider must
# include EmptyWifiDataProvider to provide this definition.
sources += [
"empty_wifi_data_provider.cc",
"empty_wifi_data_provider.h",
]
}
}
if (is_android) {
generate_jni("geolocation_jni_headers") {
sources = [
"android/java/src/org/chromium/device/geolocation/LocationProviderAdapter.java",
"android/java/src/org/chromium/device/geolocation/LocationProviderFactory.java",
]
}
android_library("geolocation_java") {
srcjar_deps = [ ":geolocation_jni_headers" ]
sources = [
"android/java/src/org/chromium/device/geolocation/LocationProviderAdapter.java",
"android/java/src/org/chromium/device/geolocation/LocationProviderAndroid.java",
"android/java/src/org/chromium/device/geolocation/LocationProviderFactory.java",
"android/java/src/org/chromium/device/geolocation/LocationProviderGmsCore.java",
]
deps = [
":geolocation_jni_headers",
"$google_play_services_package:google_play_services_base_java",
"$google_play_services_package:google_play_services_basement_java",
"$google_play_services_package:google_play_services_location_java",
"$google_play_services_package:google_play_services_tasks_java",
"//base:base_java",
"//build/android:build_java",
"//components/location/android:location_java",
"//services/device/public/java:geolocation_java",
"//third_party/android_deps:chromium_play_services_availability_java",
"//third_party/androidx:androidx_annotation_annotation_java",
"//third_party/jni_zero:jni_zero_java",
]
}
}
source_set("test_support") {
testonly = true
sources = [
"fake_location_provider.cc",
"fake_location_provider.h",
"fake_position_cache.cc",
"fake_position_cache.h",
"mock_wifi_data_provider.cc",
"mock_wifi_data_provider.h",
"position_cache_test_util.cc",
"position_cache_test_util.h",
]
public_deps = [ ":geolocation" ]
deps = [
"//services/device/public/cpp/geolocation",
"//services/device/public/mojom:geolocation_internals",
"//testing/gmock",
"//testing/gtest",
]
if (is_chromeos_ash) {
deps += [ "//chromeos/ash/components/dbus/shill" ]
}
}