Commit 9c06d18f authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[Web Payment] Require name in address, country selector on top.

Before this patch, the address editor on desktop would not require the
full name. However, Payment Request shipping addresses cannot be empty,
which is checked in several other places in the code. So the saved
address would immediately have a "Name required" error next to it in the
address selection screen.

In addition, desktop address editor placed the country selector between
the name and the rest of the address fields, whereas Android placed the
country on top, which makes sense, since changing the country can change
all fields, including the position of the name field.

This patch makes the name always required in the address editor on
desktop and places the country selector on top.

Bug: 992081
Change-Id: I028c296289e4635c9c5c12dc10c59102d321fa30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1743094Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685375}
parent 9280ed76
...@@ -435,6 +435,14 @@ void ShippingAddressEditorViewController::UpdateEditorFields() { ...@@ -435,6 +435,14 @@ void ShippingAddressEditorViewController::UpdateEditorFields() {
autofill::GetAddressComponents(chosen_country_code, autofill::GetAddressComponents(chosen_country_code,
state()->GetApplicationLocale(), state()->GetApplicationLocale(),
components.get(), &language_code_); components.get(), &language_code_);
// Insert the Country combobox at the top.
editor_fields_.emplace_back(
autofill::ADDRESS_HOME_COUNTRY,
l10n_util::GetStringUTF16(IDS_LIBADDRESSINPUT_COUNTRY_OR_REGION_LABEL),
EditorField::LengthHint::HINT_SHORT, /*required=*/true,
EditorField::ControlType::COMBOBOX);
for (size_t line_index = 0; line_index < components->GetSize(); for (size_t line_index = 0; line_index < components->GetSize();
++line_index) { ++line_index) {
const base::ListValue* line = nullptr; const base::ListValue* line = nullptr;
...@@ -482,17 +490,9 @@ void ShippingAddressEditorViewController::UpdateEditorFields() { ...@@ -482,17 +490,9 @@ void ShippingAddressEditorViewController::UpdateEditorFields() {
editor_fields_.emplace_back(server_field_type, editor_fields_.emplace_back(server_field_type,
base::UTF8ToUTF16(field_name), length_hint, base::UTF8ToUTF16(field_name), length_hint,
autofill::i18n::IsFieldRequired( autofill::i18n::IsFieldRequired(
server_field_type, chosen_country_code), server_field_type, chosen_country_code) ||
server_field_type == autofill::NAME_FULL,
control_type); control_type);
// Insert the Country combobox right after NAME_FULL.
if (server_field_type == autofill::NAME_FULL) {
editor_fields_.emplace_back(
autofill::ADDRESS_HOME_COUNTRY,
l10n_util::GetStringUTF16(
IDS_LIBADDRESSINPUT_COUNTRY_OR_REGION_LABEL),
EditorField::LengthHint::HINT_SHORT, /*required=*/true,
EditorField::ControlType::COMBOBOX);
}
} }
} }
// Always add phone number at the end. // Always add phone number at the end.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment