# Copyright 2016 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/features.gni")
import("//build/config/ui.gni")
if (is_android) {
import("//build/config/android/rules.gni")
import("//third_party/jni_zero/jni_zero.gni")
}
source_set("power_save_blocker") {
visibility = [
# Crosapi power API needs to directly use the Ash PowerSaveBlocker.
"//chrome/browser/ash/crosapi",
# Exo Wayland idle inhibit protocol needs to directly use the Ash
# PowerSaveBlocker.
"//components/exo/wayland",
# //remoting runs in a separate process which is outside of the context of
# the ServiceManager-based world. Instead of embedding a Service Manager
# environment and Device Service in it, we allow the power save blocker to
# be visible to //remoting and directly used. See crbug.com/689423
"//remoting/host:*",
"//remoting/host/win:*",
"//services/device/wake_lock:*",
# Scan Service in Ash needs to directly use the PowerSaveBlocker.
"//chrome/browser/ash/scanning",
]
sources = [ "power_save_blocker.h" ]
configs += [ "//build/config/compiler:wexit_time_destructors" ]
public_deps = [ "//services/device/public/mojom" ]
deps = [ "//base" ]
if (use_dbus) {
deps += [ "//dbus" ]
}
if (is_android) {
sources += [ "power_save_blocker_android.cc" ]
deps += [ ":jni_headers" ]
public_deps += [ "//ui/android" ]
} else if (is_chromeos_ash) {
sources += [ "power_save_blocker_ash.cc" ]
deps += [
"//chromeos/dbus/power",
"//chromeos/dbus/power:power_manager_proto",
]
} else if ((is_linux || is_chromeos) && use_dbus) {
if (is_chromeos_lacros) {
sources += [ "power_save_blocker_lacros.cc" ]
deps += [
"//chromeos/crosapi/mojom",
"//chromeos/lacros",
]
} else {
sources += [ "power_save_blocker_linux.cc" ]
deps += [ "//ui/display" ]
}
deps += [
"//dbus",
"//ui/gfx",
]
} else if (is_mac) {
sources += [ "power_save_blocker_mac.cc" ]
frameworks = [
"CoreFoundation.framework",
"IOKit.framework",
]
} else if (is_win) {
sources += [ "power_save_blocker_win.cc" ]
} else {
# Fuchsia and non-DBus Linux.
sources += [ "power_save_blocker_stub.cc" ]
}
}
if (is_android) {
java_sources_needing_jni = [ "android/java/src/org/chromium/device/power_save_blocker/PowerSaveBlocker.java" ]
generate_jni("jni_headers") {
visibility = [ ":power_save_blocker" ]
sources = java_sources_needing_jni
}
android_library("java") {
# Conceptually, this should be visible only to //services/device:java.
# However, various generated targets also need to see this target as a
# result of //services/device:java depending on it.
visibility = [
"//services:*",
"//services/device:*",
]
sources = java_sources_needing_jni
deps = [ "//third_party/jni_zero:jni_zero_java" ]
}
}