1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_API_AUTOFILL_PRIVATE_AUTOFILL_AI_UTIL_H_
#define CHROME_BROWSER_EXTENSIONS_API_AUTOFILL_PRIVATE_AUTOFILL_AI_UTIL_H_
#include <optional>
#include "chrome/common/extensions/api/autofill_private.h"
#include "components/autofill/core/browser/data_model/autofill_ai/entity_type.h"
namespace autofill {
class EntityInstance;
} // namespace autofill
namespace extensions::autofill_ai_util {
// Returns the i18n string representation of "Add <entity type>". For example,
// for a passport for "en-US", this function should return "Add passport".
std::string GetAddEntityTypeStringForI18n(autofill::EntityType entity_type);
// Returns the i18n string representation of "Edit <entity type>". For example,
// for a passport for "en-US", this function should return "Edit passport".
std::string GetEditEntityTypeStringForI18n(autofill::EntityType entity_type);
// Returns the i18n string representation of "Delete <entity type>". For
// example, for a passport for "en-US", this function should return "Delete
// passport".
std::string GetDeleteEntityTypeStringForI18n(autofill::EntityType entity_type);
// Converts an `autofill::AttributeType::DataType` enum entry to an
// `api::autofill_private::AttributeTypeDataType` enum entry.
api::autofill_private::AttributeTypeDataType
AttributeTypeDataTypeToPrivateApiAttributeTypeDataType(
autofill::AttributeType::DataType data_type);
// Converts an `api::autofill_private::EntityInstance` object to an
// `autofill::EntityInstance` object, according to a given `app_locale`. Returns
// `std::nullopt` if one of the attribute types or entity types are out of
// bounds of the enum, or if the date value is used incorrectly.
std::optional<autofill::EntityInstance>
PrivateApiEntityInstanceToEntityInstance(
const api::autofill_private::EntityInstance& private_api_entity_instance,
const std::string& app_locale);
// Converts an `autofill::EntityInstance` object to an
// `api::autofill_private::EntityInstance` object, according to a given
// `app_locale`.
api::autofill_private::EntityInstance EntityInstanceToPrivateApiEntityInstance(
const autofill::EntityInstance& entity_instance,
const std::string& app_locale);
// Converts `autofill::EntityInstance`s to
// `api::autofill_private::EntityInstanceWithLabels`s according to a given
// `app_locale`.
std::vector<api::autofill_private::EntityInstanceWithLabels>
EntityInstancesToPrivateApiEntityInstancesWithLabels(
base::span<const autofill::EntityInstance> entity_instances,
const std::string& app_locale);
} // namespace extensions::autofill_ai_util
#endif // CHROME_BROWSER_EXTENSIONS_API_AUTOFILL_PRIVATE_AUTOFILL_AI_UTIL_H_
|