#include "components/autofill/core/browser/webdata/addresses/address_autofill_table.h"
#include <stdint.h>
#include <memory>
#include <optional>
#include <ranges>
#include <string_view>
#include <vector>
#include "base/notreached.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "base/uuid.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/field_type_utils.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/browser/webdata/autofill_table_utils.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/webdata/common/web_database.h"
#include "sql/statement.h"
#include "sql/transaction.h"
namespace autofill {
namespace {
constexpr std::string_view kAddressesTable = …;
constexpr std::string_view kGuid = …;
constexpr std::string_view kRecordType = …;
constexpr std::string_view kUseCount = …;
constexpr std::string_view kUseDate = …;
constexpr std::string_view kUseDate2 = …;
constexpr std::string_view kUseDate3 = …;
constexpr std::string_view kDateModified = …;
constexpr std::string_view kLanguageCode = …;
constexpr std::string_view kLabel = …;
constexpr std::string_view kInitialCreatorId = …;
constexpr std::string_view kLastModifierId = …;
constexpr std::string_view kAddressTypeTokensTable = …;
constexpr std::string_view kType = …;
constexpr std::string_view kValue = …;
constexpr std::string_view kVerificationStatus = …;
constexpr std::string_view kObservations = …;
constexpr std::string_view kContactInfoTable = …;
constexpr std::string_view kLocalAddressesTable = …;
constexpr std::string_view kContactInfoTypeTokensTable = …;
constexpr std::string_view kLocalAddressesTypeTokensTable = …;
constexpr std::string_view kAutofillProfilesTable = …;
constexpr std::string_view kCompanyName = …;
constexpr std::string_view kStreetAddress = …;
constexpr std::string_view kDependentLocality = …;
constexpr std::string_view kCity = …;
constexpr std::string_view kState = …;
constexpr std::string_view kZipcode = …;
constexpr std::string_view kSortingCode = …;
constexpr std::string_view kCountryCode = …;
constexpr std::string_view kDisallowSettingsVisibleUpdates = …;
constexpr std::string_view kAutofillProfileAddressesTable = …;
constexpr std::string_view kStreetName = …;
constexpr std::string_view kDependentStreetName = …;
constexpr std::string_view kHouseNumber = …;
constexpr std::string_view kSubpremise = …;
constexpr std::string_view kZipCode = …;
constexpr std::string_view kApartmentNumber = …;
constexpr std::string_view kFloor = …;
constexpr std::string_view kStreetAddressStatus = …;
constexpr std::string_view kStreetNameStatus = …;
constexpr std::string_view kDependentStreetNameStatus = …;
constexpr std::string_view kHouseNumberStatus = …;
constexpr std::string_view kSubpremiseStatus = …;
constexpr std::string_view kDependentLocalityStatus = …;
constexpr std::string_view kCityStatus = …;
constexpr std::string_view kStateStatus = …;
constexpr std::string_view kZipCodeStatus = …;
constexpr std::string_view kCountryCodeStatus = …;
constexpr std::string_view kSortingCodeStatus = …;
constexpr std::string_view kApartmentNumberStatus = …;
constexpr std::string_view kFloorStatus = …;
constexpr std::string_view kAutofillProfileNamesTable = …;
constexpr std::string_view kFirstName = …;
constexpr std::string_view kMiddleName = …;
constexpr std::string_view kLastName = …;
constexpr std::string_view kFirstLastName = …;
constexpr std::string_view kConjunctionLastName = …;
constexpr std::string_view kSecondLastName = …;
constexpr std::string_view kFullName = …;
constexpr std::string_view kFirstNameStatus = …;
constexpr std::string_view kMiddleNameStatus = …;
constexpr std::string_view kLastNameStatus = …;
constexpr std::string_view kFirstLastNameStatus = …;
constexpr std::string_view kConjunctionLastNameStatus = …;
constexpr std::string_view kSecondLastNameStatus = …;
constexpr std::string_view kFullNameStatus = …;
constexpr std::string_view kAutofillProfileEmailsTable = …;
constexpr std::string_view kEmail = …;
constexpr std::string_view kAutofillProfilePhonesTable = …;
constexpr std::string_view kNumber = …;
constexpr std::string_view kAutofillProfileBirthdatesTable = …;
constexpr std::string_view kDay = …;
constexpr std::string_view kMonth = …;
constexpr std::string_view kYear = …;
void AddLegacyAutofillProfileDetailsFromStatement(sql::Statement& s,
AutofillProfile* profile) { … }
bool AddLegacyAutofillProfileNamesToProfile(sql::Database* db,
AutofillProfile* profile) { … }
bool AddLegacyAutofillProfileAddressesToProfile(sql::Database* db,
AutofillProfile* profile) { … }
bool AddLegacyAutofillProfileEmailsToProfile(sql::Database* db,
AutofillProfile* profile) { … }
bool AddLegacyAutofillProfilePhonesToProfile(sql::Database* db,
AutofillProfile* profile) { … }
WebDatabaseTable::TypeKey GetKey() { … }
time_t GetEndTime(base::Time end) { … }
std::string_view GetLegacyProfileMetadataTable(
AutofillProfile::RecordType record_type) { … }
std::string_view GetLegacyProfileTypeTokensTable(
AutofillProfile::RecordType record_type) { … }
bool AddProfileMetadataToTable(sql::Database* db,
const AutofillProfile& profile) { … }
bool AddProfileTypeTokensToTable(sql::Database* db,
const AutofillProfile& profile) { … }
bool AddAutofillProfileToTableVersion113(sql::Database* db,
const AutofillProfile& profile) { … }
std::optional<AutofillProfile> GetProfileFromTypeTokensTable(
sql::Database* db,
const std::string& guid,
AutofillProfile::RecordType record_type) { … }
bool ReadProfileMetadata(sql::Database* db, AutofillProfile& profile) { … }
}
AddressAutofillTable::AddressAutofillTable() = default;
AddressAutofillTable::~AddressAutofillTable() = default;
AddressAutofillTable* AddressAutofillTable::FromWebDatabase(WebDatabase* db) { … }
WebDatabaseTable::TypeKey AddressAutofillTable::GetTypeKey() const { … }
bool AddressAutofillTable::CreateTablesIfNecessary() { … }
bool AddressAutofillTable::MigrateToVersion(int version,
bool* update_compatible_version) { … }
bool AddressAutofillTable::AddAutofillProfile(const AutofillProfile& profile) { … }
bool AddressAutofillTable::UpdateAutofillProfile(
const AutofillProfile& profile) { … }
bool AddressAutofillTable::RemoveAutofillProfile(
const std::string& guid,
AutofillProfile::RecordType record_type) { … }
bool AddressAutofillTable::RemoveAllAutofillProfiles(
AutofillProfile::RecordType record_type) { … }
std::optional<AutofillProfile> AddressAutofillTable::GetAutofillProfile(
const std::string& guid,
AutofillProfile::RecordType record_type) const { … }
bool AddressAutofillTable::GetAutofillProfiles(
AutofillProfile::RecordType record_type,
std::vector<AutofillProfile>& profiles) const { … }
std::optional<AutofillProfile>
AddressAutofillTable::GetAutofillProfileFromLegacyTable(
const std::string& guid) const { … }
bool AddressAutofillTable::GetAutofillProfilesFromLegacyTable(
std::vector<AutofillProfile>& profiles) const { … }
bool AddressAutofillTable::RemoveAutofillDataModifiedBetween(
base::Time delete_begin,
base::Time delete_end,
std::vector<AutofillProfile>& profiles) { … }
bool AddressAutofillTable::MigrateToVersion88AddNewNameColumns() { … }
bool AddressAutofillTable::MigrateToVersion92AddNewPrefixedNameColumn() { … }
bool AddressAutofillTable::MigrateToVersion90AddNewStructuredAddressColumns() { … }
bool AddressAutofillTable::MigrateToVersion91AddMoreStructuredAddressColumns() { … }
bool AddressAutofillTable::MigrateToVersion93AddAutofillProfileLabelColumn() { … }
bool AddressAutofillTable::
MigrateToVersion96AddAutofillProfileDisallowConfirmableMergesColumn() { … }
bool AddressAutofillTable::
MigrateToVersion99RemoveAutofillProfilesTrashTable() { … }
bool AddressAutofillTable::
MigrateToVersion100RemoveProfileValidityBitfieldColumn() { … }
bool AddressAutofillTable::MigrateToVersion102AddAutofillBirthdatesTable() { … }
bool AddressAutofillTable::MigrateToVersion107AddContactInfoTables() { … }
bool AddressAutofillTable::
MigrateToVersion110AddInitialCreatorIdAndLastModifierId() { … }
bool AddressAutofillTable::
MigrateToVersion113MigrateLocalAddressProfilesToNewTable() { … }
bool AddressAutofillTable::MigrateToVersion114DropLegacyAddressTables() { … }
bool AddressAutofillTable::MigrateToVersion117AddProfileObservationColumn() { … }
bool AddressAutofillTable::MigrateToVersion121DropServerAddressTables() { … }
bool AddressAutofillTable::
MigrateToVersion132AddAdditionalLastUseDateColumns() { … }
bool AddressAutofillTable::
MigrateToVersion134UnifyLocalAndAccountAddressStorage() { … }
bool AddressAutofillTable::InitLegacyProfileAddressesTable() { … }
bool AddressAutofillTable::InitAddressesTable() { … }
bool AddressAutofillTable::InitAddressTypeTokensTable() { … }
}