Index: components/autofill/core/browser/autofill_profile.cc |
diff --git a/components/autofill/core/browser/autofill_profile.cc b/components/autofill/core/browser/autofill_profile.cc |
index fc3f39ef259b0e1c54be6dda1f67e2a2c2851ca5..da9416c3dc257ea2aaf97f4f1a07e16556cd2897 100644 |
--- a/components/autofill/core/browser/autofill_profile.cc |
+++ b/components/autofill/core/browser/autofill_profile.cc |
@@ -26,11 +26,16 @@ |
#include "components/autofill/core/browser/validation.h" |
#include "components/autofill/core/common/form_field_data.h" |
#include "grit/components_strings.h" |
-#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h" |
+#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_data.h" |
+#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_field.h" |
+#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_formatter.h" |
+#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_metadata.h" |
#include "ui/base/l10n/l10n_util.h" |
using base::ASCIIToUTF16; |
using base::UTF16ToUTF8; |
+using ::i18n::addressinput::AddressData; |
+using ::i18n::addressinput::AddressField; |
namespace autofill { |
namespace { |
@@ -296,13 +301,33 @@ void AutofillProfile::SetRawInfo(ServerFieldType type, |
base::string16 AutofillProfile::GetInfo(const AutofillType& type, |
const std::string& app_locale) const { |
if (type.html_type() == HTML_TYPE_FULL_ADDRESS) { |
- scoped_ptr< ::i18n::addressinput::AddressData> address_data = |
+ scoped_ptr<AddressData> address = |
i18n::CreateAddressDataFromAutofillProfile(*this, app_locale); |
- if (!address_data->HasAllRequiredFields()) |
please use gerrit instead
2014/06/05 22:22:48
To reduce reviewer burden: Use the has_all_require
please use gerrit instead
2014/06/09 23:28:16
Done.
|
- return base::string16(); |
+ |
+ // TODO: Think about whether it makes sense to do this special check here in |
+ // Chromium, instead of just using the regular address validation feature of |
+ // libaddressinput. |
+ static const AddressField kFields[] = { |
+ ::i18n::addressinput::COUNTRY, |
+ ::i18n::addressinput::ADMIN_AREA, |
+ ::i18n::addressinput::LOCALITY, |
+ ::i18n::addressinput::DEPENDENT_LOCALITY, |
+ ::i18n::addressinput::SORTING_CODE, |
+ ::i18n::addressinput::POSTAL_CODE, |
+ ::i18n::addressinput::STREET_ADDRESS, |
+ ::i18n::addressinput::RECIPIENT |
+ }; |
+ |
+ for (size_t i = 0; i < arraysize(kFields); ++i) { |
+ AddressField field = kFields[i]; |
+ if (address->IsFieldEmpty(field) && |
+ ::i18n::addressinput::IsFieldRequired(field, address->region_code)) { |
+ return base::string16(); |
+ } |
+ } |
std::vector<std::string> lines; |
- address_data->FormatForDisplay(&lines); |
+ ::i18n::addressinput::GetFormattedNationalAddress(*address, &lines); |
return base::UTF8ToUTF16(JoinString(lines, '\n')); |
} |