Skip to content

Commit

Permalink
Add back organization field for autofill settings.
Browse files Browse the repository at this point in the history
BUG=402207

Review URL: https://codereview.chromium.org/490373002

Cr-Commit-Position: refs/heads/master@{#291599}
  • Loading branch information
rsolomakhin authored and Commit bot committed Aug 23, 2014
1 parent be073e5 commit a4da60b
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 41 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ vars = {
'boringssl_git': 'https://boringssl.googlesource.com',
# After changing nacl_revision, run 'glient sync' and check native_client/DEPS
# to update other nacl_*_revision's.
'libaddressinput_revision': '5e0f1290b83e59c0b3b0b3d23c060f1b134a1364',
'libaddressinput_revision': 'b52a2aeb63a28914850f3ed81cd7fd26ecdd4cdc', # from svn revision 333
'libvpx_revision': 'ace65784417788374f0b19ce5a8abd06c9ccd007',
'sfntly_revision': '1bdaae8fc788a5ac8936d68bf24f37d977a13dac',
'skia_revision': '3e42a4638559d71481ba598857f2d0c715c8d4b3',
Expand Down
1 change: 1 addition & 0 deletions build/ios/grit_whitelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ IDS_LIBADDRESSINPUT_MISSING_REQUIRED_POSTAL_CODE_EXAMPLE_AND_URL
IDS_LIBADDRESSINPUT_MISSING_REQUIRED_ZIP_CODE_EXAMPLE
IDS_LIBADDRESSINPUT_MISSING_REQUIRED_ZIP_CODE_EXAMPLE_AND_URL
IDS_LIBADDRESSINPUT_OBLAST
IDS_LIBADDRESSINPUT_ORGANIZATION_LABEL
IDS_LIBADDRESSINPUT_PARISH
IDS_LIBADDRESSINPUT_POSTAL_CODE_LABEL
IDS_LIBADDRESSINPUT_PO_BOX_FORBIDDEN_VALUE
Expand Down
7 changes: 7 additions & 0 deletions chrome/app/address_input_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ limitations under the License.
desc="Administrative Area for certain countries (e.g., US' California).">
State
</message>
<message
name="IDS_LIBADDRESSINPUT_ORGANIZATION_LABEL"
desc="Label for the field of organization, firm, company, or institution
in an address. Examples of values in this field: Google,
Department of Transportation, University of Cambridge.">
Organization
</message>
<message
name="IDS_LIBADDRESSINPUT_RECIPIENT_LABEL"
desc="Label for the field for a person's name in an address.">
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ void BuildAddressInputs(common::AddressType address_type,

for (size_t i = 0; i < components.size(); ++i) {
const AddressUiComponent& component = components[i];
// Interactive autofill dialog does not display organization.
if (component.field == ::i18n::addressinput::ORGANIZATION)
continue;
ServerFieldType server_type = i18n::TypeForField(component.field, billing);
DetailInput::Length length = LengthFromHint(component.length_hint);
base::string16 placeholder = base::UTF8ToUTF16(component.name);
Expand Down
2 changes: 2 additions & 0 deletions chrome/browser/ui/autofill/data_model_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ bool DataModelWrapper::GetDisplayText(
i18n::CreateAddressData(
base::Bind(&DataModelWrapper::GetInfo, base::Unretained(this)));
address_data->language_code = GetLanguageCode();
// Interactive autofill dialog does not display organization field.
address_data->organization.clear();
std::vector<std::string> lines;
::i18n::addressinput::GetFormattedNationalAddress(*address_data, &lines);

Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/ui/webui/options/autofill_options_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ void GetAddressComponents(const std::string& country_code,
case i18n::addressinput::STREET_ADDRESS:
component->SetString(kField, kAddressLineField);
break;
case i18n::addressinput::ORGANIZATION:
component->SetString(kField, kCompanyNameField);
break;
case i18n::addressinput::RECIPIENT:
component->SetString(kField, kFullNameField);
component->SetString(
Expand Down
8 changes: 8 additions & 0 deletions components/autofill/core/browser/address_i18n.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ scoped_ptr<AddressData> CreateAddressData(
scoped_ptr<AddressData> address_data(new AddressData());
address_data->recipient = base::UTF16ToUTF8(
get_info.Run(AutofillType(NAME_FULL)));
address_data->organization = base::UTF16ToUTF8(
get_info.Run(AutofillType(COMPANY_NAME)));
address_data->region_code = base::UTF16ToUTF8(
get_info.Run(AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE)));
address_data->administrative_area = base::UTF16ToUTF8(
Expand Down Expand Up @@ -81,6 +83,8 @@ ServerFieldType TypeForField(AddressField address_field, bool billing) {
case ::i18n::addressinput::STREET_ADDRESS:
return billing ? ADDRESS_BILLING_STREET_ADDRESS
: ADDRESS_HOME_STREET_ADDRESS;
case ::i18n::addressinput::ORGANIZATION:
return COMPANY_NAME;
case ::i18n::addressinput::RECIPIENT:
return billing ? NAME_BILLING_FULL : NAME_FULL;
}
Expand Down Expand Up @@ -129,6 +133,10 @@ bool FieldForType(ServerFieldType server_type, AddressField* field) {
if (field)
*field = ::i18n::addressinput::STREET_ADDRESS;
return true;
case COMPANY_NAME:
if (field)
*field = ::i18n::addressinput::ORGANIZATION;
return true;
case NAME_BILLING_FULL:
case NAME_FULL:
if (field)
Expand Down
4 changes: 4 additions & 0 deletions components/autofill/core/browser/address_i18n_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ using ::i18n::addressinput::ADMIN_AREA;
using ::i18n::addressinput::COUNTRY;
using ::i18n::addressinput::DEPENDENT_LOCALITY;
using ::i18n::addressinput::LOCALITY;
using ::i18n::addressinput::ORGANIZATION;
using ::i18n::addressinput::POSTAL_CODE;
using ::i18n::addressinput::RECIPIENT;
using ::i18n::addressinput::SORTING_CODE;
Expand All @@ -44,6 +45,7 @@ TEST(AddressI18nTest, FieldTypeMirrorConversions) {
{true, ADDRESS_BILLING_SORTING_CODE, SORTING_CODE},
{true, ADDRESS_BILLING_ZIP, POSTAL_CODE},
{true, ADDRESS_BILLING_STREET_ADDRESS, STREET_ADDRESS},
{true, COMPANY_NAME, ORGANIZATION},
{true, NAME_BILLING_FULL, RECIPIENT},
{false, ADDRESS_HOME_COUNTRY, COUNTRY},
{false, ADDRESS_HOME_STATE, ADMIN_AREA},
Expand All @@ -52,6 +54,7 @@ TEST(AddressI18nTest, FieldTypeMirrorConversions) {
{false, ADDRESS_HOME_SORTING_CODE, SORTING_CODE},
{false, ADDRESS_HOME_ZIP, POSTAL_CODE},
{false, ADDRESS_HOME_STREET_ADDRESS, STREET_ADDRESS},
{false, COMPANY_NAME, ORGANIZATION},
{false, NAME_FULL, RECIPIENT},
};

Expand Down Expand Up @@ -115,6 +118,7 @@ TEST(AddressI18nTest, CreateAddressDataFromAutofillProfile) {
expected.locality = "Elysium";
expected.postal_code = "91111";
expected.language_code = "en";
expected.organization = "Underworld";
expected.recipient = "John H. Doe";

EXPECT_EQ(expected, *actual);
Expand Down
78 changes: 41 additions & 37 deletions components/autofill/core/browser/autofill_profile_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,13 @@ TEST(AutofillProfileTest, CreateInferredLabelsI18n_CH) {
"H. R. Giger, Brandschenkestrasse 110",
"H. R. Giger, Brandschenkestrasse 110, Zurich",
"H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich",
"H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich, Switzerland",
"H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich, Switzerland, "
"hrgiger@beispiel.com",
"H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich, Switzerland, "
"hrgiger@beispiel.com, +41446681800",
"H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich, Switzerland, "
"hrgiger@beispiel.com, +41446681800, Beispiel Inc",
"Beispiel Inc, H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich",
"Beispiel Inc, H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich, "
"Switzerland",
"Beispiel Inc, H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich, "
"Switzerland, hrgiger@beispiel.com",
"Beispiel Inc, H. R. Giger, Brandschenkestrasse 110, CH-8002 Zurich, "
"Switzerland, hrgiger@beispiel.com, +41446681800",
};

std::vector<base::string16> labels;
Expand Down Expand Up @@ -410,13 +410,16 @@ TEST(AutofillProfileTest, CreateInferredLabelsI18n_FR) {
"Antoine de Saint-Exupéry, 8 Rue de Londres, Paris",
"Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris",
"Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris CEDEX",
"Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris CEDEX, France",
"Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris CEDEX, France, "
"antoine@exemple.com",
"Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris CEDEX, France, "
"antoine@exemple.com, +33142685300",
"Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris CEDEX, France, "
"antoine@exemple.com, +33142685300, Exemple Inc",
"Exemple Inc, Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris "
"CEDEX",
"Exemple Inc, Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris "
"CEDEX, France",
"Exemple Inc, Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris "
"CEDEX, France, antoine@exemple.com",
"Exemple Inc, Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris "
"CEDEX, France, antoine@exemple.com, +33142685300",
"Exemple Inc, Antoine de Saint-Exupéry, 8 Rue de Londres, 75009 Paris "
"CEDEX, France, antoine@exemple.com, +33142685300",
};

std::vector<base::string16> labels;
Expand Down Expand Up @@ -460,16 +463,16 @@ TEST(AutofillProfileTest, CreateInferredLabelsI18n_KR) {
"Gangnam-Gu, Seoul",
"Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, "
"Gangnam-Gu, Seoul, 135-984",
"Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, "
"Gangnam-Gu, Seoul, 135-984, South Korea",
"Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, "
"Gangnam-Gu, Seoul, 135-984, South Korea, park@yeleul.com",
"Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, "
"Gangnam-Gu, Seoul, 135-984, South Korea, park@yeleul.com, "
"+8225319000",
"Park Jae-sang, Gangnam Finance Center, 152 Teheran-ro, Yeoksam-Dong, "
"Gangnam-Gu, Seoul, 135-984, South Korea, park@yeleul.com, "
"+8225319000, Yeleul Inc",
"Park Jae-sang, Yeleul Inc, Gangnam Finance Center, 152 Teheran-ro, "
"Yeoksam-Dong, Gangnam-Gu, Seoul, 135-984",
"Park Jae-sang, Yeleul Inc, Gangnam Finance Center, 152 Teheran-ro, "
"Yeoksam-Dong, Gangnam-Gu, Seoul, 135-984, South Korea",
"Park Jae-sang, Yeleul Inc, Gangnam Finance Center, 152 Teheran-ro, "
"Yeoksam-Dong, Gangnam-Gu, Seoul, 135-984, South Korea, "
"park@yeleul.com",
"Park Jae-sang, Yeleul Inc, Gangnam Finance Center, 152 Teheran-ro, "
"Yeoksam-Dong, Gangnam-Gu, Seoul, 135-984, South Korea, "
"park@yeleul.com, +8225319000",
};

std::vector<base::string16> labels;
Expand Down Expand Up @@ -508,14 +511,14 @@ TEST(AutofillProfileTest, CreateInferredLabelsI18n_JP_Latn) {
"Tokyo",
"Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku, "
"Tokyo, 106-6126",
"Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku, "
"Tokyo, 106-6126, Japan",
"Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku, "
"Tokyo, 106-6126, Japan, miku@rei.com",
"Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku, "
"Tokyo, 106-6126, Japan, miku@rei.com, +81363849000",
"Miku Hatsune, Roppongi Hills Mori Tower, 6-10-1 Roppongi, Minato-ku, "
"Tokyo, 106-6126, Japan, miku@rei.com, +81363849000, Rei Inc",
"Miku Hatsune, Rei Inc, Roppongi Hills Mori Tower, 6-10-1 Roppongi, "
"Minato-ku, Tokyo, 106-6126",
"Miku Hatsune, Rei Inc, Roppongi Hills Mori Tower, 6-10-1 Roppongi, "
"Minato-ku, Tokyo, 106-6126, Japan",
"Miku Hatsune, Rei Inc, Roppongi Hills Mori Tower, 6-10-1 Roppongi, "
"Minato-ku, Tokyo, 106-6126, Japan, miku@rei.com",
"Miku Hatsune, Rei Inc, Roppongi Hills Mori Tower, 6-10-1 Roppongi, "
"Minato-ku, Tokyo, 106-6126, Japan, miku@rei.com, +81363849000",
};

std::vector<base::string16> labels;
Expand Down Expand Up @@ -552,13 +555,12 @@ TEST(AutofillProfileTest, CreateInferredLabelsI18n_JP_ja) {
"港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音",
"東京都港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音",
"〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音",
"〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音, Japan",
"〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音, Japan, "
"〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1例ミク 初音",
"〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1例ミク 初音, Japan",
"〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1例ミク 初音, Japan, "
"miku@rei.com",
"〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音, Japan, "
"〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1例ミク 初音, Japan, "
"miku@rei.com, 0363849000",
"〒106-6126東京都港区六本木ヒルズ森タワー六本木 6-10-1ミク 初音, Japan, "
"miku@rei.com, 0363849000, 例",
};

std::vector<base::string16> labels;
Expand Down Expand Up @@ -1193,6 +1195,7 @@ TEST(AutofillProfileTest, FullAddress) {
AutofillType full_address(HTML_TYPE_FULL_ADDRESS, HTML_MODE_NONE);
base::string16 formatted_address(ASCIIToUTF16(
"Marion Mitchell Morrison\n"
"Fox\n"
"123 Zoo St.\n"
"unit 5\n"
"Hollywood, CA 91601"));
Expand All @@ -1209,6 +1212,7 @@ TEST(AutofillProfileTest, FullAddress) {
base::string16(),
"en-US");
EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison\n"
"Fox\n"
"123 Zoo St.\n"
"Hollywood, CA 91601"),
profile.GetInfo(full_address, "en-US"));
Expand Down
4 changes: 2 additions & 2 deletions third_party/libaddressinput/README.chromium
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Name: The library to input, validate, and display addresses.
Short Name: libaddressinput
URL: https://code.google.com/p/libaddressinput/
Version: 0
Date: 10 August 2014
Revision: 327
Date: 21 August 2014
Revision: 333
License: Apache 2.0
License File: LICENSE
Security Critical: no
Expand Down
4 changes: 3 additions & 1 deletion third_party/libaddressinput/chromium/addressinput_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ void ValidateRequiredFields(
::i18n::addressinput::SORTING_CODE,
::i18n::addressinput::POSTAL_CODE,
::i18n::addressinput::STREET_ADDRESS,
::i18n::addressinput::RECIPIENT};
// ORGANIZATION is never required.
::i18n::addressinput::RECIPIENT
};

for (size_t i = 0; i < arraysize(kFields); ++i) {
AddressField field = kFields[i];
Expand Down

0 comments on commit a4da60b

Please sign in to comment.