#include "components/device_signals/test/signals_contract.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/test/bind.h"
#include "build/build_config.h"
#include "components/device_signals/core/browser/signals_types.h"
#include "components/device_signals/core/common/signals_constants.h"
namespace device_signals::test {
namespace {
bool VerifyOptionalString(const std::string& signal_name,
const base::Value::Dict& signals) { … }
bool VerifyIsString(const std::string& signal_name,
const base::Value::Dict& signals) { … }
bool VerifyIsBoolean(const std::string& signal_name,
const base::Value::Dict& signals) { … }
bool VerifyIsIntegerWithRange(const std::string& signal_name,
int32_t min_value,
int32_t max_value,
const base::Value::Dict& signals) { … }
bool VerifyIsSettingInteger(const std::string& signal_name,
const base::Value::Dict& signals) { … }
bool VerifyIsStringArray(const std::string& signal_name,
bool enforce_value,
const base::Value::Dict& signals) { … }
bool VerifyUnset(const std::string& signal_name,
const base::Value::Dict& signals) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
void ChangeContractForUnmanagedDevices(
base::flat_map<std::string,
base::RepeatingCallback<bool(const base::Value::Dict&)>>&
contract) {
contract[names::kDeviceAffiliationIds] =
base::BindRepeating(VerifyIsStringArray, names::kDeviceAffiliationIds,
false);
contract[names::kDisplayName] =
base::BindRepeating(VerifyUnset, names::kDisplayName);
contract[names::kSystemDnsServers] = base::BindRepeating(
base::BindRepeating(VerifyUnset, names::kSystemDnsServers));
contract[names::kSerialNumber] =
base::BindRepeating(VerifyUnset, names::kSerialNumber);
contract[names::kDeviceHostName] =
base::BindRepeating(VerifyUnset, names::kDeviceHostName);
contract[names::kMacAddresses] =
base::BindRepeating(VerifyUnset, names::kMacAddresses);
contract[names::kImei] = base::BindRepeating(VerifyUnset, names::kImei);
contract[names::kMeid] = base::BindRepeating(VerifyUnset, names::kMeid);
}
#endif
}
base::flat_map<std::string,
base::RepeatingCallback<bool(const base::Value::Dict&)>>
GetSignalsContract() { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
base::flat_map<std::string,
base::RepeatingCallback<bool(const base::Value::Dict&)>>
GetSignalsContractForUnmanagedDevices() {
base::flat_map<std::string,
base::RepeatingCallback<bool(const base::Value::Dict&)>>
contract = GetSignalsContract();
ChangeContractForUnmanagedDevices(contract);
return contract;
}
#endif
}