Skip to content

Commit

Permalink
Erased structured_address namespace
Browse files Browse the repository at this point in the history
Also had to append "Node" suffix to what was originally in structured_address, to avoid name-collisions.

Change-Id: Iec10003ecfabbd78406ceb6bd06fca7e7d4b4a79
Bug: 1392693
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4047650
Reviewed-by: Matthias Körber <koerber@google.com>
Commit-Queue: Jihad Hanna <jihadghanna@google.com>
Reviewed-by: David Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1084943}
  • Loading branch information
Jihad Hanna authored and Chromium LUCI CQ committed Dec 19, 2022
1 parent a5f6d3f commit a54d06b
Show file tree
Hide file tree
Showing 76 changed files with 551 additions and 734 deletions.
Expand Up @@ -82,7 +82,7 @@ void MaybeSetRawInfoWithVerificationStatus(
if (value)
profile->SetRawInfoWithVerificationStatus(
type, ConvertJavaStringToUTF16(value),
static_cast<structured_address::VerificationStatus>(status));
static_cast<VerificationStatus>(status));
}

void MaybeSetInfoWithVerificationStatus(
Expand All @@ -94,7 +94,7 @@ void MaybeSetInfoWithVerificationStatus(
profile->SetInfoWithVerificationStatus(
type, ConvertJavaStringToUTF16(value),
g_browser_process->GetApplicationLocale(),
static_cast<structured_address::VerificationStatus>(status));
static_cast<VerificationStatus>(status));
}

// Self-deleting requester of full card details, including full PAN and the CVC
Expand Down
Expand Up @@ -48,14 +48,12 @@ class SaveUpdateAddressProfilePromptControllerTest : public testing::Test {
// Profile with verified data as it is returned from Java.
AutofillProfile GetFullProfileWithVerifiedData() {
AutofillProfile profile(base::GenerateGUID(), test::kEmptyOrigin);
profile.SetRawInfoWithVerificationStatus(
NAME_FULL, u"Mona J. Liza",
structured_address::VerificationStatus::kUserVerified);
profile.SetRawInfoWithVerificationStatus(NAME_FULL, u"Mona J. Liza",
VerificationStatus::kUserVerified);
test::SetProfileInfo(&profile, "", "", "", "email@example.com",
"Company Inc.", "33 Narrow Street", "Apt 42",
"Playa Vista", "LA", "12345", "US", "13105551234",
/*finalize=*/true,
structured_address::VerificationStatus::kUserVerified);
/*finalize=*/true, VerificationStatus::kUserVerified);
return profile;
}

Expand Down
Expand Up @@ -47,8 +47,7 @@ static const char kErrorDataUnavailable[] = "Autofill data unavailable.";

// Constant to assign a user-verified verification status to the autofill
// profile.
constexpr auto kUserVerified =
autofill::structured_address::VerificationStatus::kUserVerified;
constexpr auto kUserVerified = autofill::VerificationStatus::kUserVerified;

// Dictionary keys used for serializing AddressUiComponent. Those values
// are used as keys in JavaScript code and shouldn't be modified.
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/sync/test/integration/autofill_helper.cc
Expand Up @@ -319,7 +319,7 @@ void UpdateProfile(int profile,
const std::string& guid,
const AutofillType& type,
const std::u16string& value,
autofill::structured_address::VerificationStatus status) {
autofill::VerificationStatus status) {
std::vector<AutofillProfile> profiles;
for (AutofillProfile* p : GetAllAutoFillProfiles(profile)) {
profiles.push_back(*p);
Expand Down
13 changes: 6 additions & 7 deletions chrome/browser/sync/test/integration/autofill_helper.h
Expand Up @@ -73,13 +73,12 @@ void RemoveProfile(int profile, const std::string& guid);

// Updates the autofill profile with guid |guid| in sync profile |profile|
// to |type| and |value| with the verification status |status|.
void UpdateProfile(
int profile,
const std::string& guid,
const autofill::AutofillType& type,
const std::u16string& value,
autofill::structured_address::VerificationStatus status =
autofill::structured_address::VerificationStatus::kObserved);
void UpdateProfile(int profile,
const std::string& guid,
const autofill::AutofillType& type,
const std::u16string& value,
autofill::VerificationStatus status =
autofill::VerificationStatus::kObserved);

// Gets all the Autofill profiles in the PersonalDataManager of sync profile
// |profile|.
Expand Down
Expand Up @@ -337,14 +337,13 @@ IN_PROC_BROWSER_TEST_F(TwoClientAutofillProfileSyncTest,

AutofillProfile* profile = GetAllAutoFillProfiles(0)[0];
ASSERT_TRUE(profile);
UpdateProfile(
0, profile->guid(), AutofillType(autofill::NAME_FIRST),
profile->GetRawInfo(autofill::NAME_FIRST),
autofill::structured_address::VerificationStatus::kUserVerified);
UpdateProfile(0, profile->guid(), AutofillType(autofill::NAME_FIRST),
profile->GetRawInfo(autofill::NAME_FIRST),
autofill::VerificationStatus::kUserVerified);

// Make sure the change is propagated to the other client.
EXPECT_TRUE(AutofillProfileChecker(0, 1, /*expected_count=*/1U).Wait());
EXPECT_EQ(autofill::structured_address::VerificationStatus::kUserVerified,
EXPECT_EQ(autofill::VerificationStatus::kUserVerified,
GetAllAutoFillProfiles(1)[0]->GetVerificationStatus(
autofill::NAME_FIRST));
}
Expand Down
6 changes: 2 additions & 4 deletions chrome/browser/ui/autofill/address_editor_controller.cc
Expand Up @@ -108,14 +108,12 @@ void AddressEditorController::SetProfileInfo(autofill::ServerFieldType type,
// country codes.
if (type == autofill::ADDRESS_HOME_COUNTRY) {
profile_to_edit_.SetInfoWithVerificationStatus(
type, value, locale_,
autofill::structured_address::VerificationStatus::kUserVerified);
type, value, locale_, autofill::VerificationStatus::kUserVerified);
return;
}

profile_to_edit_.SetRawInfoWithVerificationStatus(
type, value,
autofill::structured_address::VerificationStatus::kUserVerified);
type, value, autofill::VerificationStatus::kUserVerified);
}

std::u16string AddressEditorController::GetProfileInfo(
Expand Down
Expand Up @@ -140,7 +140,7 @@ void ContactInfoEditorViewController::PopulateProfile(
profile->SetInfoWithVerificationStatus(
autofill::AutofillType(field.second.type), field.first->GetText(),
state()->GetApplicationLocale(),
autofill::structured_address::VerificationStatus::kUserVerified);
autofill::VerificationStatus::kUserVerified);
}
profile->set_origin(autofill::kSettingsOrigin);
}
Expand Down
Expand Up @@ -31,8 +31,6 @@ using UkmAddressProfileImportType =

using UserDecision = AutofillClient::SaveAddressProfileOfferUserDecision;

using structured_address::VerificationStatus;

// Names of histrogram used for metric collection.
constexpr char kProfileImportTypeHistogram[] =
"Autofill.ProfileImport.ProfileImportType";
Expand Down
Expand Up @@ -294,12 +294,10 @@ void ProfileImportProcess::SetUserDecision(
// fields in the edited profile are set to kUserVerified.
for (auto type : GetUserVisibleTypes()) {
std::u16string value = edited_profile->GetRawInfo(type);
if (!value.empty() &&
edited_profile->GetVerificationStatus(type) ==
structured_address::VerificationStatus::kNoStatus) {
if (!value.empty() && edited_profile->GetVerificationStatus(type) ==
VerificationStatus::kNoStatus) {
edited_profile->SetRawInfoWithVerificationStatus(
type, value,
structured_address::VerificationStatus::kUserVerified);
type, value, VerificationStatus::kUserVerified);
}
}

Expand Down
Expand Up @@ -19,8 +19,6 @@

namespace autofill {

using structured_address::VerificationStatus;

namespace {

class AutofillProfileImportProcessTest : public testing::Test {
Expand Down
Expand Up @@ -29,8 +29,6 @@ using syncer::EntityData;

namespace autofill {

using structured_address::VerificationStatus;

namespace {

// Converts the verification status representation used in the
Expand Down
Expand Up @@ -19,8 +19,6 @@
#include "testing/gtest/include/gtest/gtest.h"
namespace autofill {

using structured_address::VerificationStatus;

namespace {
using base::ASCIIToUTF16;
using base::UTF16ToUTF8;
Expand Down
Expand Up @@ -150,14 +150,13 @@ void AutofillSaveUpdateAddressProfileDelegateIOS::SetProfileInfo(
// Since the country field is a text field, we should use SetInfo() to make
// sure they get converted to country codes.
if (type == ADDRESS_HOME_COUNTRY) {
profile_.SetInfoWithVerificationStatus(
type, value, locale_,
structured_address::VerificationStatus::kUserVerified);
profile_.SetInfoWithVerificationStatus(type, value, locale_,
VerificationStatus::kUserVerified);
return;
}

profile_.SetRawInfoWithVerificationStatus(
type, value, structured_address::VerificationStatus::kUserVerified);
profile_.SetRawInfoWithVerificationStatus(type, value,
VerificationStatus::kUserVerified);
}

bool AutofillSaveUpdateAddressProfileDelegateIOS::Accept() {
Expand Down
9 changes: 4 additions & 5 deletions components/autofill/core/browser/autofill_test_utils.cc
Expand Up @@ -429,8 +429,7 @@ inline void check_and_set(
FormGroup* profile,
ServerFieldType type,
const char* value,
structured_address::VerificationStatus status =
structured_address::VerificationStatus::kObserved) {
VerificationStatus status = VerificationStatus::kObserved) {
if (value) {
profile->SetRawInfoWithVerificationStatus(type, base::UTF8ToUTF16(value),
status);
Expand Down Expand Up @@ -818,7 +817,7 @@ void SetProfileInfo(AutofillProfile* profile,
const char* country,
const char* phone,
bool finalize,
structured_address::VerificationStatus status) {
VerificationStatus status) {
check_and_set(profile, NAME_FIRST, first_name, status);
check_and_set(profile, NAME_MIDDLE, middle_name, status);
check_and_set(profile, NAME_LAST, last_name, status);
Expand Down Expand Up @@ -851,7 +850,7 @@ void SetProfileInfo(AutofillProfile* profile,
const char* country,
const char* phone,
bool finalize,
structured_address::VerificationStatus status) {
VerificationStatus status) {
check_and_set(profile, NAME_FIRST, first_name, status);
check_and_set(profile, NAME_MIDDLE, middle_name, status);
check_and_set(profile, NAME_LAST, last_name, status);
Expand Down Expand Up @@ -883,7 +882,7 @@ void SetProfileInfoWithGuid(AutofillProfile* profile,
const char* country,
const char* phone,
bool finalize,
structured_address::VerificationStatus status) {
VerificationStatus status) {
if (guid)
profile->set_guid(guid);
SetProfileInfo(profile, first_name, middle_name, last_name, email, company,
Expand Down
45 changes: 20 additions & 25 deletions components/autofill/core/browser/autofill_test_utils.h
Expand Up @@ -65,8 +65,7 @@ namespace test {
struct FormGroupValue {
ServerFieldType type;
std::string value;
structured_address::VerificationStatus verification_status =
structured_address::VerificationStatus::kNoStatus;
VerificationStatus verification_status = VerificationStatus::kNoStatus;
};

// Convenience declaration for multiple FormGroup values.
Expand Down Expand Up @@ -350,8 +349,7 @@ void SetProfileInfo(AutofillProfile* profile,
const char* country,
const char* phone,
bool finalize = true,
structured_address::VerificationStatus =
structured_address::VerificationStatus::kObserved);
VerificationStatus status = VerificationStatus::kObserved);

// This one doesn't require the |dependent_locality|.
void SetProfileInfo(AutofillProfile* profile,
Expand All @@ -368,27 +366,24 @@ void SetProfileInfo(AutofillProfile* profile,
const char* country,
const char* phone,
bool finalize = true,
structured_address::VerificationStatus =
structured_address::VerificationStatus::kObserved);

void SetProfileInfoWithGuid(
AutofillProfile* profile,
const char* guid,
const char* first_name,
const char* middle_name,
const char* last_name,
const char* email,
const char* company,
const char* address1,
const char* address2,
const char* city,
const char* state,
const char* zipcode,
const char* country,
const char* phone,
bool finalize = true,
structured_address::VerificationStatus =
structured_address::VerificationStatus::kObserved);
VerificationStatus status = VerificationStatus::kObserved);

void SetProfileInfoWithGuid(AutofillProfile* profile,
const char* guid,
const char* first_name,
const char* middle_name,
const char* last_name,
const char* email,
const char* company,
const char* address1,
const char* address2,
const char* city,
const char* state,
const char* zipcode,
const char* country,
const char* phone,
bool finalize = true,
VerificationStatus = VerificationStatus::kObserved);

// A unit testing utility that is common to a number of the Autofill unit
// tests. |SetCreditCardInfo| provides a quick way to populate a credit card
Expand Down
1 change: 0 additions & 1 deletion components/autofill/core/browser/contact_info_sync_util.cc
Expand Up @@ -13,7 +13,6 @@ namespace autofill {

namespace {

using structured_address::VerificationStatus;
using sync_pb::ContactInfoSpecifics;

// Converts the verification status representation used in AutofillProfile to
Expand Down
Expand Up @@ -13,7 +13,6 @@ namespace autofill {

namespace {

using structured_address::VerificationStatus;
using sync_pb::ContactInfoSpecifics;

const char kGuid[] = "00000000-0000-0000-0000-000000000001";
Expand Down
6 changes: 2 additions & 4 deletions components/autofill/core/browser/data_model/address.cc
Expand Up @@ -29,8 +29,6 @@

namespace autofill {

using structured_address::VerificationStatus;

Address::Address() = default;

Address::Address(const Address& address) = default;
Expand Down Expand Up @@ -78,7 +76,7 @@ bool Address::IsStructuredAddressMergeable(const Address& newer) const {
newer.GetStructuredAddress());
}

const structured_address::Address& Address::GetStructuredAddress() const {
const AddressNode& Address::GetStructuredAddress() const {
return structured_address_;
}

Expand All @@ -99,7 +97,7 @@ void Address::SetRawInfoWithVerificationStatus(ServerFieldType type,
const std::u16string current_value =
structured_address_.GetValueForType(type);
if (!current_value.empty()) {
bool token_equivalent = structured_address::AreStringTokenEquivalent(
bool token_equivalent = AreStringTokenEquivalent(
value, structured_address_.GetValueForType(type));
structured_address_.SetValueForTypeIfPossible(
ADDRESS_HOME_STREET_ADDRESS, value, status,
Expand Down
22 changes: 10 additions & 12 deletions components/autofill/core/browser/data_model/address.h
Expand Up @@ -28,10 +28,9 @@ class Address : public FormGroup {

// FormGroup:
std::u16string GetRawInfo(ServerFieldType type) const override;
void SetRawInfoWithVerificationStatus(
ServerFieldType type,
const std::u16string& value,
structured_address::VerificationStatus status) override;
void SetRawInfoWithVerificationStatus(ServerFieldType type,
const std::u16string& value,
VerificationStatus status) override;
void GetMatchingTypes(const std::u16string& text,
const std::string& locale,
ServerFieldTypeSet* matching_types) const override;
Expand Down Expand Up @@ -60,26 +59,25 @@ class Address : public FormGroup {
bool IsStructuredAddressMergeable(const Address& newer) const;

// Returns a constant reference to |structured_address_|.
const structured_address::Address& GetStructuredAddress() const;
const AddressNode& GetStructuredAddress() const;

private:
// FormGroup:
void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override;
std::u16string GetInfoImpl(const AutofillType& type,
const std::string& locale) const override;
bool SetInfoWithVerificationStatusImpl(
const AutofillType& type,
const std::u16string& value,
const std::string& locale,
structured_address::VerificationStatus status) override;
bool SetInfoWithVerificationStatusImpl(const AutofillType& type,
const std::u16string& value,
const std::string& locale,
VerificationStatus status) override;

// Return the verification status of a structured name value.
structured_address::VerificationStatus GetVerificationStatusImpl(
VerificationStatus GetVerificationStatusImpl(
ServerFieldType type) const override;

// This data structure holds the address information if the structured address
// feature is enabled.
structured_address::Address structured_address_;
AddressNode structured_address_;
};

} // namespace autofill
Expand Down

0 comments on commit a54d06b

Please sign in to comment.