#include "device/vr/public/cpp/features.h"
#include "base/feature_list.h"
#include "device/vr/buildflags/buildflags.h"
#if BUILDFLAG(ENABLE_OPENXR) && BUILDFLAG(IS_ANDROID)
#include "base/android/jni_android.h"
#include "device/vr/public/jni_headers/XrFeatureStatus_jni.h"
#endif
namespace device::features {
BASE_FEATURE(kWebXRWebGPUBinding, base::FEATURE_DISABLED_BY_DEFAULT);
BASE_FEATURE(kWebXRIncubations, base::FEATURE_DISABLED_BY_DEFAULT);
BASE_FEATURE(kWebXrInternals, base::FEATURE_DISABLED_BY_DEFAULT);
BASE_FEATURE(kWebXRLayers, base::FEATURE_DISABLED_BY_DEFAULT);
BASE_FEATURE(kWebXROrientationSensorDevice,
#if BUILDFLAG(IS_ANDROID)
base::FEATURE_ENABLED_BY_DEFAULT
#else
base::FEATURE_DISABLED_BY_DEFAULT
#endif
);
BASE_FEATURE(kWebXrVisibleBlurred, base::FEATURE_ENABLED_BY_DEFAULT);
#if BUILDFLAG(ENABLE_OPENXR)
BASE_FEATURE(kOpenXR,
BUILDFLAG(IS_WIN) ? base::FEATURE_ENABLED_BY_DEFAULT
: base::FEATURE_DISABLED_BY_DEFAULT);
BASE_FEATURE(kOpenXrExtendedFeatureSupport, base::FEATURE_ENABLED_BY_DEFAULT);
BASE_FEATURE(kOpenXrSpatialEntities, base::FEATURE_DISABLED_BY_DEFAULT);
BASE_FEATURE(kSpatialEntitesDepthHitTest, base::FEATURE_DISABLED_BY_DEFAULT);
#if BUILDFLAG(IS_ANDROID)
BASE_FEATURE(kOpenXrAndroidSmoothDepth, base::FEATURE_DISABLED_BY_DEFAULT);
#endif
bool IsXrFeatureEnabled(const base::Feature& base_feature) {
static bool feature_enabled = base::FeatureList::IsEnabled(base_feature);
static bool is_xr_device = IsXrDevice();
return feature_enabled || is_xr_device;
}
bool IsOpenXrEnabled() {
return IsXrFeatureEnabled(kOpenXR);
}
bool IsOpenXrArEnabled() {
return IsOpenXrEnabled() && IsXrFeatureEnabled(kOpenXrExtendedFeatureSupport);
}
#endif
bool IsXrDevice() {
#if BUILDFLAG(IS_ANDROID) && BUILDFLAG(ENABLE_OPENXR)
return device::Java_XrFeatureStatus_isXrDevice(
base::android::AttachCurrentThread());
#else
return false;
#endif
}
bool IsHandTrackingEnabled() {
#if BUILDFLAG(ENABLE_OPENXR)
return IsOpenXrEnabled();
#else
return false;
#endif
}
}
#if BUILDFLAG(ENABLE_OPENXR) && BUILDFLAG(IS_ANDROID)
DEFINE_JNI(XrFeatureStatus)
#endif