#ifndef ASH_SYSTEM_INPUT_DEVICE_SETTINGS_INPUT_DEVICE_SETTINGS_UTILS_H_
#define ASH_SYSTEM_INPUT_DEVICE_SETTINGS_INPUT_DEVICE_SETTINGS_UTILS_H_
#include <string_view>
#include "ash/ash_export.h"
#include "ash/public/mojom/input_device_settings.mojom-forward.h"
#include "base/export_template.h"
#include "base/values.h"
#include "ui/events/ash/mojom/extended_fkeys_modifier.mojom-shared.h"
#include "ui/events/devices/input_device.h"
class AccountId;
class PrefService;
namespace ash {
struct VendorProductId {
uint16_t vendor_id;
uint16_t product_id;
constexpr bool operator<(const VendorProductId& other) const {
return vendor_id == other.vendor_id ? product_id < other.product_id
: vendor_id < other.vendor_id;
}
bool operator==(const VendorProductId& other) const;
};
bool IsValidModifier(int val);
ASH_EXPORT std::string BuildDeviceKey(const ui::InputDevice& device);
ASH_EXPORT std::string BuildDeviceKey(uint16_t vendor_id, uint16_t product_id);
template <typename T>
bool ShouldPersistSetting(std::string_view setting_key,
T new_value,
T default_value,
bool force_persistence,
const ::base::Value::Dict* existing_settings_dict);
ASH_EXPORT bool ShouldPersistSetting(
const mojom::InputDeviceSettingsPolicyPtr& policy,
std::string_view setting_key,
bool new_value,
bool default_value,
bool force_persistence,
const base::Value::Dict* existing_settings_dict);
ASH_EXPORT bool ShouldPersistFkeySetting(
const mojom::InputDeviceSettingsFkeyPolicyPtr& policy,
std::string_view setting_key,
std::optional<ui::mojom::ExtendedFkeysModifier> new_value,
ui::mojom::ExtendedFkeysModifier default_value,
const base::Value::Dict* existing_settings_dict);
extern template EXPORT_TEMPLATE_DECLARE(ASH_EXPORT) bool ShouldPersistSetting(
std::string_view setting_key,
bool new_value,
bool default_value,
bool force_persistence,
const base::Value::Dict* existing_settings_dict);
extern template EXPORT_TEMPLATE_DECLARE(ASH_EXPORT) bool ShouldPersistSetting(
std::string_view setting_key,
int new_value,
int default_value,
bool force_persistence,
const base::Value::Dict* existing_settings_dict);
ASH_EXPORT const base::Value::Dict* GetLoginScreenSettingsDict(
PrefService* local_state,
AccountId account_id,
const std::string& pref_name);
ASH_EXPORT const base::Value::List* GetLoginScreenButtonRemappingList(
PrefService* local_state,
AccountId account_id,
const std::string& pref_name);
ASH_EXPORT base::Value::Dict ConvertButtonRemappingToDict(
const mojom::ButtonRemapping& remapping,
mojom::CustomizationRestriction customization_restriction,
bool redact_button_names = false);
ASH_EXPORT mojom::ButtonRemappingPtr ConvertDictToButtonRemapping(
const base::Value::Dict& dict,
mojom::CustomizationRestriction customization_restriction);
ASH_EXPORT base::Value::List ConvertButtonRemappingArrayToList(
const std::vector<mojom::ButtonRemappingPtr>& remappings,
mojom::CustomizationRestriction customization_restriction,
bool redact_button_names = false);
ASH_EXPORT std::vector<mojom::ButtonRemappingPtr>
ConvertListToButtonRemappingArray(
const base::Value::List& list,
mojom::CustomizationRestriction customization_restriction);
ASH_EXPORT bool IsChromeOSKeyboard(const mojom::Keyboard& keyboard);
ASH_EXPORT bool IsSplitModifierKeyboard(const mojom::Keyboard& keyboard);
ASH_EXPORT bool IsSplitModifierKeyboard(int keyboard_id);
ASH_EXPORT std::string GetDeviceKeyForMetadataRequest(
const std::string& device_key);
}
#endif