Chromium Code Reviews| Index: components/autofill/core/browser/personal_data_manager.cc |
| diff --git a/components/autofill/core/browser/personal_data_manager.cc b/components/autofill/core/browser/personal_data_manager.cc |
| index 42f896db1dc83f8a78b1326e464c74a20284834b..cf1980a5d19b3b2265a1038370329c7855cd359c 100644 |
| --- a/components/autofill/core/browser/personal_data_manager.cc |
| +++ b/components/autofill/core/browser/personal_data_manager.cc |
| @@ -15,6 +15,7 @@ |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| +#include "components/autofill/core/browser/address_i18n.h" |
| #include "components/autofill/core/browser/autofill-inl.h" |
| #include "components/autofill/core/browser/autofill_country.h" |
| #include "components/autofill/core/browser/autofill_field.h" |
| @@ -24,11 +25,16 @@ |
| #include "components/autofill/core/browser/phone_number_i18n.h" |
| #include "components/autofill/core/browser/validation.h" |
| #include "components/autofill/core/common/autofill_pref_names.h" |
| +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_data.h" |
| #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_formatter.h" |
| namespace autofill { |
| namespace { |
| +using ::i18n::addressinput::AddressField; |
| +using ::i18n::addressinput::GetStreetAddressLinesAsSingleLine; |
| +using ::i18n::addressinput::STREET_ADDRESS; |
| + |
| const base::string16::value_type kCreditCardPrefix[] = {'*', 0}; |
| template<typename T> |
| @@ -567,18 +573,23 @@ void PersonalDataManager::GetProfileSuggestions( |
| std::vector<base::string16> multi_values; |
| profile->GetMultiInfo(type, app_locale_, &multi_values); |
|
Evan Stade
2014/07/14 17:47:40
I don't really see a huge advantage to this CL, bu
please use gerrit instead
2014/07/14 19:07:09
Done.
|
| - // Names need to be in vertically compact form - i.e. a single line. Join |
| - // multi-line addresses into a single line, using a separator. |
| - // The separator is locale-specific. |
| - base::string16 compact_separator = |
| - base::UTF8ToUTF16(::i18n::addressinput::GetLineSeparatorForLanguage( |
| - profile->language_code())); |
| + AddressField field; |
| + if (!multi_values.empty() && |
| + i18n::FieldForType(type.GetStorableType(), &field) && |
| + field == STREET_ADDRESS) { |
| + // Street address should have a single value. |
| + DCHECK_EQ(1U, multi_values.size()); |
| + std::string line; |
| + GetStreetAddressLinesAsSingleLine( |
| + *i18n::CreateAddressDataFromAutofillProfile(*profile, app_locale_), |
| + &line); |
| + multi_values[0] = base::UTF8ToUTF16(line); |
| + } |
| + |
| for (size_t i = 0; i < multi_values.size(); ++i) { |
| - // Create vertically compact form. |
| - base::ReplaceChars(multi_values[i], |
| - base::ASCIIToUTF16("\n"), |
| - compact_separator, |
| - &multi_values[i]); |
| + // Only street address can have newlines, but it was collapsed into a |
| + // single line above. |
| + DCHECK(multi_values[i].find('\n') == std::string::npos); |
| if (!field_is_autofilled) { |
| // Suggest data that starts with what the user has typed. |
| if (!multi_values[i].empty() && |