// Generated by the proto_extras plugin. DO NOT EDIT!
// source: third_party/metrics_proto/system_profile.proto

#include "third_party/metrics_proto/system_profile.to_value.h"



#include "base/base64.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "components/proto_extras/proto_extras_lib.h"
#include "third_party/metrics_proto/extension_install.pb.h"
#include "third_party/metrics_proto/extension_install.to_value.h"
#include "third_party/metrics_proto/system_profile.pb.h"


namespace metrics {
void MaybeToValue(const std::optional<SystemProfileProto>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_build_timestamp()) {
    dict.Set("build_timestamp", ::proto_extras::ToNumericTypeForValue(message.build_timestamp()));
  }
  if (message.has_app_version()) {
    dict.Set("app_version", (message.app_version()));
  }
  if (message.has_log_written_by_app_version()) {
    dict.Set("log_written_by_app_version", (message.log_written_by_app_version()));
  }
  if (message.has_brand_code()) {
    dict.Set("brand_code", (message.brand_code()));
  }
  if (message.has_channel()) {
    dict.Set("channel", ::metrics::SystemProfileProto_Channel_Name(message.channel()));
  }
  if (message.has_is_extended_stable_channel()) {
    dict.Set("is_extended_stable_channel", static_cast<bool>(message.is_extended_stable_channel()));
  }
  if (message.has_is_instrumented_build()) {
    dict.Set("is_instrumented_build", static_cast<bool>(message.is_instrumented_build()));
  }
  if (message.has_uma_enabled_date()) {
    dict.Set("uma_enabled_date", ::proto_extras::ToNumericTypeForValue(message.uma_enabled_date()));
  }
  if (message.has_install_date()) {
    dict.Set("install_date", ::proto_extras::ToNumericTypeForValue(message.install_date()));
  }
  if (message.has_cloned_install_info()) {
    dict.Set("cloned_install_info", ::metrics::ToValue(message.cloned_install_info()));
  }
  if (message.has_low_entropy_source()) {
    dict.Set("low_entropy_source", (message.low_entropy_source()));
  }
  if (message.has_old_low_entropy_source()) {
    dict.Set("old_low_entropy_source", (message.old_low_entropy_source()));
  }
  if (message.has_pseudo_low_entropy_source()) {
    dict.Set("pseudo_low_entropy_source", (message.pseudo_low_entropy_source()));
  }
  if (message.has_application_locale()) {
    dict.Set("application_locale", (message.application_locale()));
  }
  if (!message.command_line_key_hash().empty()) {
    base::ListValue list;
    for (const auto& value : message.command_line_key_hash()) {
      list.Append(::proto_extras::ToNumericTypeForValue(value));
    }
    dict.Set("command_line_key_hash", std::move(list));
  }
  if (message.has_os()) {
    dict.Set("os", ::metrics::ToValue(message.os()));
  }
  if (message.has_hardware()) {
    dict.Set("hardware", ::metrics::ToValue(message.hardware()));
  }
  if (message.has_network()) {
    dict.Set("network", ::metrics::ToValue(message.network()));
  }
  if (message.has_google_update()) {
    dict.Set("google_update", ::metrics::ToValue(message.google_update()));
  }
  if (message.has_stability()) {
    dict.Set("stability", ::metrics::ToValue(message.stability()));
  }
  if (!message.field_trial().empty()) {
    base::ListValue list;
    for (const auto& value : message.field_trial()) {
      list.Append(::metrics::ToValue(value));
    }
    dict.Set("field_trial", std::move(list));
  }
  if (message.has_variations_seed_version()) {
    dict.Set("variations_seed_version", (message.variations_seed_version()));
  }
  if (message.has_seed_has_active_limited_layer()) {
    dict.Set("seed_has_active_limited_layer", static_cast<bool>(message.seed_has_active_limited_layer()));
  }
  if (message.has_client_id_was_used_for_trial_assignment()) {
    dict.Set("client_id_was_used_for_trial_assignment", static_cast<bool>(message.client_id_was_used_for_trial_assignment()));
  }
  if (message.has_client_uuid()) {
    dict.Set("client_uuid", (message.client_uuid()));
  }
  if (message.has_session_hash()) {
    dict.Set("session_hash", ::proto_extras::ToNumericTypeForValue(message.session_hash()));
  }
  if (message.has_fg_bg_id()) {
    dict.Set("fg_bg_id", (message.fg_bg_id()));
  }
  if (!message.external_audio_video_device().empty()) {
    base::ListValue list;
    for (const auto& value : message.external_audio_video_device()) {
      list.Append(::metrics::ToValue(value));
    }
    dict.Set("external_audio_video_device", std::move(list));
  }
  if (message.has_external_access_point()) {
    dict.Set("external_access_point", ::metrics::ToValue(message.external_access_point()));
  }
  if (message.has_multi_profile_user_count()) {
    dict.Set("multi_profile_user_count", ::proto_extras::ToNumericTypeForValue(message.multi_profile_user_count()));
  }
  if (!message.occupied_extension_bucket().empty()) {
    base::ListValue list;
    for (const auto& value : message.occupied_extension_bucket()) {
      list.Append((value));
    }
    dict.Set("occupied_extension_bucket", std::move(list));
  }
  if (message.has_offstore_extensions_state()) {
    dict.Set("offstore_extensions_state", ::metrics::SystemProfileProto_ExtensionsState_Name(message.offstore_extensions_state()));
  }
  if (message.has_uma_default_state()) {
    dict.Set("uma_default_state", ::metrics::SystemProfileProto_UmaDefaultState_Name(message.uma_default_state()));
  }
  if (!message.antivirus_product().empty()) {
    base::ListValue list;
    for (const auto& value : message.antivirus_product()) {
      list.Append(::metrics::ToValue(value));
    }
    dict.Set("antivirus_product", std::move(list));
  }
  if (!message.chrome_component().empty()) {
    base::ListValue list;
    for (const auto& value : message.chrome_component()) {
      list.Append(::metrics::ToValue(value));
    }
    dict.Set("chrome_component", std::move(list));
  }
  if (!message.extension_install().empty()) {
    base::ListValue list;
    for (const auto& value : message.extension_install()) {
      list.Append(::metrics::ToValue(value));
    }
    dict.Set("extension_install", std::move(list));
  }
  if (message.has_app_package_name()) {
    dict.Set("app_package_name", (message.app_package_name()));
  }
  if (message.has_app_package_name_allowlist_filter()) {
    dict.Set("app_package_name_allowlist_filter", ::metrics::SystemProfileProto_AppPackageNameAllowlistFilter_Name(message.app_package_name_allowlist_filter()));
  }
  if (message.has_client_side_sampling_status()) {
    dict.Set("client_side_sampling_status", ::metrics::SystemProfileProto_ClientSideSamplingStatus_Name(message.client_side_sampling_status()));
  }
  if (message.has_metrics_filtering_status()) {
    dict.Set("metrics_filtering_status", ::metrics::SystemProfileProto_MetricsFilteringStatus_Name(message.metrics_filtering_status()));
  }
  if (message.has_installer_package()) {
    dict.Set("installer_package", ::metrics::SystemProfileProto_InstallerPackage_Name(message.installer_package()));
  }
  if (message.has_linked_android_phone_data()) {
    dict.Set("linked_android_phone_data", ::metrics::ToValue(message.linked_android_phone_data()));
  }
  if (message.has_demo_mode_dimensions()) {
    dict.Set("demo_mode_dimensions", ::metrics::ToValue(message.demo_mode_dimensions()));
  }
  if (message.has_lts_channel()) {
    dict.Set("lts_channel", ::metrics::SystemProfileProto_LTSChannel_Name(message.lts_channel()));
  }
  if (message.has_tpm_identifier()) {
    dict.Set("tpm_identifier", ::metrics::ToValue(message.tpm_identifier()));
  }
  if (message.has_accessibility_state()) {
    dict.Set("accessibility_state", ::metrics::ToValue(message.accessibility_state()));
  }
  if (message.has_enterprise_management()) {
    dict.Set("enterprise_management", ::metrics::ToValue(message.enterprise_management()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_ClonedInstallInfo>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_ClonedInstallInfo& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_last_timestamp()) {
    dict.Set("last_timestamp", ::proto_extras::ToNumericTypeForValue(message.last_timestamp()));
  }
  if (message.has_cloned_from_client_id()) {
    dict.Set("cloned_from_client_id", ::proto_extras::ToNumericTypeForValue(message.cloned_from_client_id()));
  }
  if (message.has_first_timestamp()) {
    dict.Set("first_timestamp", ::proto_extras::ToNumericTypeForValue(message.first_timestamp()));
  }
  if (message.has_count()) {
    dict.Set("count", (message.count()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_OS>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_OS& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_name()) {
    dict.Set("name", (message.name()));
  }
  if (message.has_version()) {
    dict.Set("version", (message.version()));
  }
  if (message.has_build_fingerprint()) {
    dict.Set("build_fingerprint", (message.build_fingerprint()));
  }
  if (message.has_build_number()) {
    dict.Set("build_number", (message.build_number()));
  }
  if (message.has_kernel_version()) {
    dict.Set("kernel_version", (message.kernel_version()));
  }
  if (message.has_arc()) {
    dict.Set("arc", ::metrics::ToValue(message.arc()));
  }
  if (message.has_dark_mode_state()) {
    dict.Set("dark_mode_state", ::metrics::SystemProfileProto_OS_DarkModeState_Name(message.dark_mode_state()));
  }
  if (message.has_xdg_session_type()) {
    dict.Set("xdg_session_type", ::metrics::SystemProfileProto_OS_XdgSessionType_Name(message.xdg_session_type()));
  }
  if (message.has_xdg_current_desktop()) {
    dict.Set("xdg_current_desktop", ::metrics::SystemProfileProto_OS_XdgCurrentDesktop_Name(message.xdg_current_desktop()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_OS_Arc>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_OS_Arc& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_release()) {
    dict.Set("release", (message.release()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_Hardware>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_Hardware& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_cpu_architecture()) {
    dict.Set("cpu_architecture", (message.cpu_architecture()));
  }
  if (message.has_app_cpu_architecture()) {
    dict.Set("app_cpu_architecture", (message.app_cpu_architecture()));
  }
  if (message.has_system_ram_mb()) {
    dict.Set("system_ram_mb", ::proto_extras::ToNumericTypeForValue(message.system_ram_mb()));
  }
  if (message.has_dll_base()) {
    dict.Set("dll_base", ::proto_extras::ToNumericTypeForValue(message.dll_base()));
  }
  if (message.has_hardware_class()) {
    dict.Set("hardware_class", (message.hardware_class()));
  }
  if (message.has_full_hardware_class()) {
    dict.Set("full_hardware_class", (message.full_hardware_class()));
  }
  if (message.has_updated_hardware_class()) {
    dict.Set("updated_hardware_class", (message.updated_hardware_class()));
  }
  if (message.has_cellular_device_variant()) {
    dict.Set("cellular_device_variant", (message.cellular_device_variant()));
  }
  if (message.has_screen_count()) {
    dict.Set("screen_count", (message.screen_count()));
  }
  if (message.has_primary_screen_width()) {
    dict.Set("primary_screen_width", (message.primary_screen_width()));
  }
  if (message.has_primary_screen_height()) {
    dict.Set("primary_screen_height", (message.primary_screen_height()));
  }
  if (message.has_primary_screen_scale_factor()) {
    dict.Set("primary_screen_scale_factor", static_cast<double>(message.primary_screen_scale_factor()));
  }
  if (message.has_max_dpi_x()) {
    dict.Set("max_dpi_x", static_cast<double>(message.max_dpi_x()));
  }
  if (message.has_max_dpi_y()) {
    dict.Set("max_dpi_y", static_cast<double>(message.max_dpi_y()));
  }
  if (message.has_form_factor()) {
    dict.Set("form_factor", ::metrics::SystemProfileProto_Hardware_FormFactor_Name(message.form_factor()));
  }
  if (message.has_cpu()) {
    dict.Set("cpu", ::metrics::ToValue(message.cpu()));
  }
  if (message.has_motherboard()) {
    dict.Set("motherboard", ::metrics::ToValue(message.motherboard()));
  }
  if (message.has_gpu()) {
    dict.Set("gpu", ::metrics::ToValue(message.gpu()));
  }
  if (message.has_internal_display_supports_touch()) {
    dict.Set("internal_display_supports_touch", static_cast<bool>(message.internal_display_supports_touch()));
  }
  if (!message.internal_storage_devices().empty()) {
    base::ListValue list;
    for (const auto& value : message.internal_storage_devices()) {
      list.Append(::metrics::ToValue(value));
    }
    dict.Set("internal_storage_devices", std::move(list));
  }
  if (message.has_app_drive()) {
    dict.Set("app_drive", ::metrics::ToValue(message.app_drive()));
  }
  if (message.has_user_data_drive()) {
    dict.Set("user_data_drive", ::metrics::ToValue(message.user_data_drive()));
  }
  if (message.has_tpm_type()) {
    dict.Set("tpm_type", ::metrics::SystemProfileProto_Hardware_TpmType_Name(message.tpm_type()));
  }
  if (message.has_tpm_firmware_version()) {
    dict.Set("tpm_firmware_version", ::proto_extras::ToNumericTypeForValue(message.tpm_firmware_version()));
  }
  if (message.has_tpm_rw_firmware_version()) {
    dict.Set("tpm_rw_firmware_version", (message.tpm_rw_firmware_version()));
  }
  if (message.has_manufacturer()) {
    dict.Set("manufacturer", (message.manufacturer()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_Hardware_CPU>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_Hardware_CPU& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_vendor_name()) {
    dict.Set("vendor_name", (message.vendor_name()));
  }
  if (message.has_signature()) {
    dict.Set("signature", ::proto_extras::ToNumericTypeForValue(message.signature()));
  }
  if (message.has_num_cores()) {
    dict.Set("num_cores", ::proto_extras::ToNumericTypeForValue(message.num_cores()));
  }
  if (message.has_num_efficient_cores()) {
    dict.Set("num_efficient_cores", ::proto_extras::ToNumericTypeForValue(message.num_efficient_cores()));
  }
  if (message.has_is_hypervisor()) {
    dict.Set("is_hypervisor", static_cast<bool>(message.is_hypervisor()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_Hardware_Motherboard>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_Hardware_Motherboard& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_manufacturer()) {
    dict.Set("manufacturer", (message.manufacturer()));
  }
  if (message.has_model()) {
    dict.Set("model", (message.model()));
  }
  if (message.has_bios_manufacturer()) {
    dict.Set("bios_manufacturer", (message.bios_manufacturer()));
  }
  if (message.has_bios_version()) {
    dict.Set("bios_version", (message.bios_version()));
  }
  if (message.has_bios_type()) {
    dict.Set("bios_type", ::metrics::SystemProfileProto_Hardware_BiosType_Name(message.bios_type()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_Hardware_Graphics>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_Hardware_Graphics& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_vendor_id()) {
    dict.Set("vendor_id", ::proto_extras::ToNumericTypeForValue(message.vendor_id()));
  }
  if (message.has_device_id()) {
    dict.Set("device_id", ::proto_extras::ToNumericTypeForValue(message.device_id()));
  }
  if (message.has_driver_version()) {
    dict.Set("driver_version", (message.driver_version()));
  }
  if (message.has_gl_vendor()) {
    dict.Set("gl_vendor", (message.gl_vendor()));
  }
  if (message.has_gl_renderer()) {
    dict.Set("gl_renderer", (message.gl_renderer()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_Hardware_InternalStorageDevice>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_Hardware_InternalStorageDevice& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_vendor_id()) {
    dict.Set("vendor_id", ::proto_extras::ToNumericTypeForValue(message.vendor_id()));
  }
  if (message.has_product_id()) {
    dict.Set("product_id", ::proto_extras::ToNumericTypeForValue(message.product_id()));
  }
  if (message.has_revision()) {
    dict.Set("revision", ::proto_extras::ToNumericTypeForValue(message.revision()));
  }
  if (message.has_model()) {
    dict.Set("model", (message.model()));
  }
  if (message.has_size_mb()) {
    dict.Set("size_mb", ::proto_extras::ToNumericTypeForValue(message.size_mb()));
  }
  if (message.has_firmware_version()) {
    dict.Set("firmware_version", ::proto_extras::ToNumericTypeForValue(message.firmware_version()));
  }
  if (message.has_type()) {
    dict.Set("type", ::metrics::SystemProfileProto_Hardware_InternalStorageDevice_Type_Name(message.type()));
  }
  if (message.has_purpose()) {
    dict.Set("purpose", ::metrics::SystemProfileProto_Hardware_InternalStorageDevice_Purpose_Name(message.purpose()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_Hardware_Drive>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_Hardware_Drive& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_has_seek_penalty()) {
    dict.Set("has_seek_penalty", static_cast<bool>(message.has_seek_penalty()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_Network>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_Network& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_connection_type_is_ambiguous()) {
    dict.Set("connection_type_is_ambiguous", static_cast<bool>(message.connection_type_is_ambiguous()));
  }
  if (message.has_connection_type()) {
    dict.Set("connection_type", ::metrics::SystemProfileProto_Network_ConnectionType_Name(message.connection_type()));
  }
  if (message.has_min_effective_connection_type()) {
    dict.Set("min_effective_connection_type", ::metrics::SystemProfileProto_Network_EffectiveConnectionType_Name(message.min_effective_connection_type()));
  }
  if (message.has_max_effective_connection_type()) {
    dict.Set("max_effective_connection_type", ::metrics::SystemProfileProto_Network_EffectiveConnectionType_Name(message.max_effective_connection_type()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_GoogleUpdate>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_GoogleUpdate& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_is_system_install()) {
    dict.Set("is_system_install", static_cast<bool>(message.is_system_install()));
  }
  if (message.has_last_automatic_start_timestamp()) {
    dict.Set("last_automatic_start_timestamp", ::proto_extras::ToNumericTypeForValue(message.last_automatic_start_timestamp()));
  }
  if (message.has_last_update_check_timestamp()) {
    dict.Set("last_update_check_timestamp", ::proto_extras::ToNumericTypeForValue(message.last_update_check_timestamp()));
  }
  if (message.has_google_update_status()) {
    dict.Set("google_update_status", ::metrics::ToValue(message.google_update_status()));
  }
  if (message.has_client_status()) {
    dict.Set("client_status", ::metrics::ToValue(message.client_status()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_GoogleUpdate_ProductInfo>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_GoogleUpdate_ProductInfo& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_version()) {
    dict.Set("version", (message.version()));
  }
  if (message.has_last_update_success_timestamp()) {
    dict.Set("last_update_success_timestamp", ::proto_extras::ToNumericTypeForValue(message.last_update_success_timestamp()));
  }
  if (message.has_last_result()) {
    dict.Set("last_result", ::metrics::SystemProfileProto_GoogleUpdate_ProductInfo_InstallResult_Name(message.last_result()));
  }
  if (message.has_last_error()) {
    dict.Set("last_error", (message.last_error()));
  }
  if (message.has_last_extra_error()) {
    dict.Set("last_extra_error", (message.last_extra_error()));
  }
  if (message.has_cohort_hash()) {
    dict.Set("cohort_hash", ::proto_extras::ToNumericTypeForValue(message.cohort_hash()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_Stability>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_Stability& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_page_load_count()) {
    dict.Set("page_load_count", (message.page_load_count()));
  }
  if (message.has_renderer_launch_count()) {
    dict.Set("renderer_launch_count", (message.renderer_launch_count()));
  }
  if (message.has_other_user_crash_count()) {
    dict.Set("other_user_crash_count", (message.other_user_crash_count()));
  }
  if (message.has_kernel_crash_count()) {
    dict.Set("kernel_crash_count", (message.kernel_crash_count()));
  }
  if (message.has_unclean_system_shutdown_count()) {
    dict.Set("unclean_system_shutdown_count", (message.unclean_system_shutdown_count()));
  }
  if (message.has_launch_count()) {
    dict.Set("launch_count", (message.launch_count()));
  }
  if (message.has_crash_count_due_to_gms_core_update()) {
    dict.Set("crash_count_due_to_gms_core_update", (message.crash_count_due_to_gms_core_update()));
  }
  if (message.has_from_previous_run()) {
    dict.Set("from_previous_run", static_cast<bool>(message.from_previous_run()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_FieldTrial>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_FieldTrial& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_name_id()) {
    dict.Set("name_id", ::proto_extras::ToNumericTypeForValue(message.name_id()));
  }
  if (message.has_group_id()) {
    dict.Set("group_id", ::proto_extras::ToNumericTypeForValue(message.group_id()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_ExternalAudioVideoDevice>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_ExternalAudioVideoDevice& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_manufacturer_name()) {
    dict.Set("manufacturer_name", (message.manufacturer_name()));
  }
  if (message.has_model_name()) {
    dict.Set("model_name", (message.model_name()));
  }
  if (message.has_product_code()) {
    dict.Set("product_code", (message.product_code()));
  }
  if (!message.av_device_type().empty()) {
    base::ListValue list;
    for (const auto& value : message.av_device_type()) {
      list.Append(::metrics::SystemProfileProto_ExternalAudioVideoDevice_AVDeviceType_Name(value));
    }
    dict.Set("av_device_type", std::move(list));
  }
  if (message.has_manufacture_year()) {
    dict.Set("manufacture_year", (message.manufacture_year()));
  }
  if (message.has_manufacture_week()) {
    dict.Set("manufacture_week", (message.manufacture_week()));
  }
  if (message.has_horizontal_resolution()) {
    dict.Set("horizontal_resolution", (message.horizontal_resolution()));
  }
  if (message.has_vertical_resolution()) {
    dict.Set("vertical_resolution", (message.vertical_resolution()));
  }
  if (!message.audio_description().empty()) {
    base::ListValue list;
    for (const auto& value : message.audio_description()) {
      list.Append(::metrics::ToValue(value));
    }
    dict.Set("audio_description", std::move(list));
  }
  if (message.has_position_in_setup()) {
    dict.Set("position_in_setup", (message.position_in_setup()));
  }
  if (message.has_is_in_path_to_tv()) {
    dict.Set("is_in_path_to_tv", static_cast<bool>(message.is_in_path_to_tv()));
  }
  if (message.has_cec_version()) {
    dict.Set("cec_version", (message.cec_version()));
  }
  if (!message.cec_command().empty()) {
    base::ListValue list;
    for (const auto& value : message.cec_command()) {
      list.Append(::metrics::ToValue(value));
    }
    dict.Set("cec_command", std::move(list));
  }
  if (message.has_frame_rate()) {
    dict.Set("frame_rate", (message.frame_rate()));
  }
  if (message.has_color_encoding()) {
    dict.Set("color_encoding", ::metrics::SystemProfileProto_ExternalAudioVideoDevice_ColorEncoding_Name(message.color_encoding()));
  }
  if (message.has_bit_depth()) {
    dict.Set("bit_depth", (message.bit_depth()));
  }
  if (message.has_tmds()) {
    dict.Set("tmds", (message.tmds()));
  }
  if (message.has_hdr10_support()) {
    dict.Set("hdr10_support", static_cast<bool>(message.hdr10_support()));
  }
  if (message.has_dolby_vision_support()) {
    dict.Set("dolby_vision_support", static_cast<bool>(message.dolby_vision_support()));
  }
  if (message.has_eotf_support()) {
    dict.Set("eotf_support", (message.eotf_support()));
  }
  if (message.has_yuv_support()) {
    dict.Set("yuv_support", static_cast<bool>(message.yuv_support()));
  }
  if (message.has_yuv_420_support()) {
    dict.Set("yuv_420_support", static_cast<bool>(message.yuv_420_support()));
  }
  if (message.has_maximum_supported_hdcp_version()) {
    dict.Set("maximum_supported_hdcp_version", (message.maximum_supported_hdcp_version()));
  }
  if (message.has_current_hdcp_version()) {
    dict.Set("current_hdcp_version", (message.current_hdcp_version()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_ExternalAudioVideoDevice_AudioDescription>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_ExternalAudioVideoDevice_AudioDescription& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_audio_format()) {
    dict.Set("audio_format", ::metrics::SystemProfileProto_ExternalAudioVideoDevice_AudioDescription_AudioFormat_Name(message.audio_format()));
  }
  if (message.has_num_channels()) {
    dict.Set("num_channels", (message.num_channels()));
  }
  if (!message.sample_frequency_hz().empty()) {
    base::ListValue list;
    for (const auto& value : message.sample_frequency_hz()) {
      list.Append((value));
    }
    dict.Set("sample_frequency_hz", std::move(list));
  }
  if (message.has_max_bit_rate_per_second()) {
    dict.Set("max_bit_rate_per_second", (message.max_bit_rate_per_second()));
  }
  if (message.has_bit_depth()) {
    dict.Set("bit_depth", (message.bit_depth()));
  }
  if (message.has_output_mode()) {
    dict.Set("output_mode", ::metrics::SystemProfileProto_ExternalAudioVideoDevice_AudioDescription_OutputMode_Name(message.output_mode()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_ExternalAudioVideoDevice_CECCommand>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_ExternalAudioVideoDevice_CECCommand& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_opcode()) {
    dict.Set("opcode", (message.opcode()));
  }
  if (message.has_num_received_direct()) {
    dict.Set("num_received_direct", (message.num_received_direct()));
  }
  if (message.has_num_received_broadcast()) {
    dict.Set("num_received_broadcast", (message.num_received_broadcast()));
  }
  if (message.has_num_sent_direct()) {
    dict.Set("num_sent_direct", (message.num_sent_direct()));
  }
  if (message.has_num_sent_broadcast()) {
    dict.Set("num_sent_broadcast", (message.num_sent_broadcast()));
  }
  if (message.has_num_aborted_unknown_reason()) {
    dict.Set("num_aborted_unknown_reason", (message.num_aborted_unknown_reason()));
  }
  if (message.has_num_aborted_unrecognized()) {
    dict.Set("num_aborted_unrecognized", (message.num_aborted_unrecognized()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_ExternalAccessPoint>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_ExternalAccessPoint& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_manufacturer()) {
    dict.Set("manufacturer", (message.manufacturer()));
  }
  if (message.has_model_name()) {
    dict.Set("model_name", (message.model_name()));
  }
  if (message.has_model_number()) {
    dict.Set("model_number", (message.model_number()));
  }
  if (message.has_device_name()) {
    dict.Set("device_name", (message.device_name()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_AntiVirusProduct>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_AntiVirusProduct& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_product_name()) {
    dict.Set("product_name", (message.product_name()));
  }
  if (message.has_product_name_hash()) {
    dict.Set("product_name_hash", ::proto_extras::ToNumericTypeForValue(message.product_name_hash()));
  }
  if (message.has_product_version()) {
    dict.Set("product_version", (message.product_version()));
  }
  if (message.has_product_version_hash()) {
    dict.Set("product_version_hash", ::proto_extras::ToNumericTypeForValue(message.product_version_hash()));
  }
  if (message.has_product_state()) {
    dict.Set("product_state", ::metrics::SystemProfileProto_AntiVirusState_Name(message.product_state()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_ChromeComponent>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_ChromeComponent& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_component_id()) {
    dict.Set("component_id", ::metrics::SystemProfileProto_ComponentId_Name(message.component_id()));
  }
  if (message.has_version()) {
    dict.Set("version", (message.version()));
  }
  if (message.has_omaha_fingerprint()) {
    dict.Set("omaha_fingerprint", ::proto_extras::ToNumericTypeForValue(message.omaha_fingerprint()));
  }
  if (message.has_cohort_hash()) {
    dict.Set("cohort_hash", ::proto_extras::ToNumericTypeForValue(message.cohort_hash()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_LinkedAndroidPhoneData>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_LinkedAndroidPhoneData& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_phone_model_name_hash()) {
    dict.Set("phone_model_name_hash", ::proto_extras::ToNumericTypeForValue(message.phone_model_name_hash()));
  }
  if (message.has_is_smartlock_enabled()) {
    dict.Set("is_smartlock_enabled", static_cast<bool>(message.is_smartlock_enabled()));
  }
  if (message.has_is_instant_tethering_enabled()) {
    dict.Set("is_instant_tethering_enabled", static_cast<bool>(message.is_instant_tethering_enabled()));
  }
  if (message.has_is_messages_enabled()) {
    dict.Set("is_messages_enabled", static_cast<bool>(message.is_messages_enabled()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_DemoModeDimensions>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_DemoModeDimensions& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_country()) {
    dict.Set("country", (message.country()));
  }
  if (message.has_retailer()) {
    dict.Set("retailer", ::metrics::ToValue(message.retailer()));
  }
  if (!message.customization_facet().empty()) {
    base::ListValue list;
    for (const auto& value : message.customization_facet()) {
      list.Append(::metrics::SystemProfileProto_DemoModeDimensions_CustomizationFacet_Name(value));
    }
    dict.Set("customization_facet", std::move(list));
  }
  if (message.has_app_version()) {
    dict.Set("app_version", (message.app_version()));
  }
  if (message.has_resources_version()) {
    dict.Set("resources_version", (message.resources_version()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_DemoModeDimensions_Retailer>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_DemoModeDimensions_Retailer& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_retailer_id()) {
    dict.Set("retailer_id", (message.retailer_id()));
  }
  if (message.has_store_id()) {
    dict.Set("store_id", (message.store_id()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_TpmIdentifier>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_TpmIdentifier& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (message.has_manufacturer_id()) {
    dict.Set("manufacturer_id", ::proto_extras::ToNumericTypeForValue(message.manufacturer_id()));
  }
  if (message.has_manufacturer_version()) {
    dict.Set("manufacturer_version", (message.manufacturer_version()));
  }
  if (message.has_manufacturer_version_hash()) {
    dict.Set("manufacturer_version_hash", ::proto_extras::ToNumericTypeForValue(message.manufacturer_version_hash()));
  }
  if (message.has_manufacturer_version_info()) {
    dict.Set("manufacturer_version_info", (message.manufacturer_version_info()));
  }
  if (message.has_manufacturer_version_info_hash()) {
    dict.Set("manufacturer_version_info_hash", ::proto_extras::ToNumericTypeForValue(message.manufacturer_version_info_hash()));
  }
  if (message.has_tpm_specific_version()) {
    dict.Set("tpm_specific_version", (message.tpm_specific_version()));
  }
  if (message.has_tpm_specific_version_hash()) {
    dict.Set("tpm_specific_version_hash", ::proto_extras::ToNumericTypeForValue(message.tpm_specific_version_hash()));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_AccessibilityState>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_AccessibilityState& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (!message.enabled_modes().empty()) {
    base::ListValue list;
    for (const auto& value : message.enabled_modes()) {
      list.Append(::metrics::SystemProfileProto_AccessibilityState_AXMode_Name(value));
    }
    dict.Set("enabled_modes", std::move(list));
  }
  return base::Value(std::move(dict));
}
void MaybeToValue(const std::optional<SystemProfileProto_EnterpriseManagement>& opt_message,
                    std::string_view name,
                    base::DictValue& output_dictionary) {
  if (!opt_message.has_value()) {
    return;
  }
  output_dictionary.Set(name, ToValue(*opt_message));
}
base::Value ToValue(const SystemProfileProto_EnterpriseManagement& message) {
  base::DictValue dict;
  ::proto_extras::SerializeUnknownFields(message, dict);
  if (!message.platform_status().empty()) {
    base::ListValue list;
    for (const auto& value : message.platform_status()) {
      list.Append(::metrics::SystemProfileProto_EnterpriseManagement_PlatformStatus_Name(value));
    }
    dict.Set("platform_status", std::move(list));
  }
  if (!message.browser_status().empty()) {
    base::ListValue list;
    for (const auto& value : message.browser_status()) {
      list.Append(::metrics::SystemProfileProto_EnterpriseManagement_BrowserStatus_Name(value));
    }
    dict.Set("browser_status", std::move(list));
  }
  return base::Value(std::move(dict));
}
}  // namespace metrics

