| Index: chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
|
| diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
|
| index ce0e728bd95a8ad6daa31d6a165fcf9538c7403d..e2d8927961a6c1e920c16047a8777e91d20aab66 100644
|
| --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
|
| +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
|
| @@ -79,14 +79,17 @@
|
| #include "grit/component_scaled_resources.h"
|
| #include "grit/components_strings.h"
|
| #include "grit/generated_resources.h"
|
| -#include "grit/libaddressinput_strings.h"
|
| +#include "grit/libaddressinput/messages.h"
|
| #include "grit/platform_locale_settings.h"
|
| #include "grit/theme_resources.h"
|
| #include "net/cert/cert_status_flags.h"
|
| #include "third_party/libaddressinput/chromium/chrome_downloader_impl.h"
|
| #include "third_party/libaddressinput/chromium/chrome_storage_impl.h"
|
| -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h"
|
| -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_problem.h"
|
| +#include "third_party/libaddressinput/chromium/preload_address_validator.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_problem.h"
|
| +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/localization.h"
|
| #include "ui/base/base_window.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/base/models/combobox_model.h"
|
| @@ -98,9 +101,7 @@
|
| using ::i18n::addressinput::AddressData;
|
| using ::i18n::addressinput::AddressField;
|
| using ::i18n::addressinput::AddressProblem;
|
| -using ::i18n::addressinput::AddressProblemFilter;
|
| -using ::i18n::addressinput::AddressProblems;
|
| -using ::i18n::addressinput::AddressValidator;
|
| +using ::i18n::addressinput::FieldProblemMap;
|
|
|
| namespace autofill {
|
|
|
| @@ -824,12 +825,12 @@ void AutofillDialogControllerImpl::Show() {
|
| if (account_chooser_model_->WalletIsSelected())
|
| FetchWalletCookie();
|
|
|
| - scoped_ptr< ::i18n::addressinput::Downloader> downloader(
|
| - new autofill::ChromeDownloaderImpl(profile_->GetRequestContext()));
|
| - validator_ = AddressValidator::Build(
|
| - downloader.Pass(),
|
| + validator_.reset(new AddressValidator(
|
| + I18N_ADDRESS_VALIDATION_DATA_URL,
|
| + scoped_ptr< ::i18n::addressinput::Downloader>(
|
| + new autofill::ChromeDownloaderImpl(profile_->GetRequestContext())),
|
| ValidationRulesStorageFactory::CreateStorage(),
|
| - this);
|
| + this));
|
|
|
| SuggestionsUpdated();
|
| SubmitButtonDelayBegin();
|
| @@ -1901,14 +1902,14 @@ base::string16 AutofillDialogControllerImpl::InputValidityMessage(
|
| case CREDIT_CARD_EXP_MONTH:
|
| if (!InputWasEdited(CREDIT_CARD_EXP_MONTH, value)) {
|
| return l10n_util::GetStringUTF16(
|
| - IDS_LIBADDRESSINPUT_I18N_MISSING_REQUIRED_FIELD);
|
| + IDS_LIBADDRESSINPUT_MISSING_REQUIRED_FIELD);
|
| }
|
| break;
|
|
|
| case CREDIT_CARD_EXP_4_DIGIT_YEAR:
|
| if (!InputWasEdited(CREDIT_CARD_EXP_4_DIGIT_YEAR, value)) {
|
| return l10n_util::GetStringUTF16(
|
| - IDS_LIBADDRESSINPUT_I18N_MISSING_REQUIRED_FIELD);
|
| + IDS_LIBADDRESSINPUT_MISSING_REQUIRED_FIELD);
|
| }
|
| break;
|
|
|
| @@ -1940,7 +1941,7 @@ base::string16 AutofillDialogControllerImpl::InputValidityMessage(
|
| }
|
|
|
| return value.empty() ? l10n_util::GetStringUTF16(
|
| - IDS_LIBADDRESSINPUT_I18N_MISSING_REQUIRED_FIELD) :
|
| + IDS_LIBADDRESSINPUT_MISSING_REQUIRED_FIELD) :
|
| base::string16();
|
| }
|
|
|
| @@ -1961,17 +1962,24 @@ ValidityMessages AutofillDialogControllerImpl::InputsAreValid(
|
| profile, g_browser_process->GetApplicationLocale());
|
| address_data->language_code = AddressLanguageCodeForSection(section);
|
|
|
| - AddressProblems problems;
|
| - status = GetValidator()->ValidateAddress(*address_data,
|
| - AddressProblemFilter(),
|
| - &problems);
|
| + ::i18n::addressinput::Localization localization;
|
| + localization.SetGetter(
|
| + l10n_util::GetStringUTF8, g_browser_process->GetApplicationLocale());
|
| +
|
| + FieldProblemMap problems;
|
| + status = GetValidator()->ValidateAddress(*address_data, NULL, &problems);
|
| common::AddressType address_type = section == SECTION_SHIPPING ?
|
| common::ADDRESS_TYPE_SHIPPING : common::ADDRESS_TYPE_BILLING;
|
| - for (size_t i = 0; i < problems.size(); ++i) {
|
| - const AddressProblem& problem = problems[i];
|
| - bool sure = problem.type != AddressProblem::MISSING_REQUIRED_FIELD;
|
| - base::string16 text = l10n_util::GetStringUTF16(problem.description_id);
|
| - messages.Set(i18ninput::TypeForField(problem.field, address_type),
|
| +
|
| + static const bool kEnableExamples = true;
|
| + static const bool kEnableLinks = false;
|
| + for (FieldProblemMap::const_iterator iter = problems.begin();
|
| + iter != problems.end(); ++iter) {
|
| + bool sure = iter->second != ::i18n::addressinput::MISSING_REQUIRED_FIELD;
|
| + base::string16 text = base::UTF8ToUTF16(
|
| + localization.GetErrorMessage(*address_data, iter->first, iter->second,
|
| + kEnableExamples, kEnableLinks));
|
| + messages.Set(i18ninput::TypeForField(iter->first, address_type),
|
| ValidityMessage(text, sure));
|
| }
|
| }
|
| @@ -3546,9 +3554,9 @@ bool AutofillDialogControllerImpl::SectionIsValid(
|
|
|
| bool AutofillDialogControllerImpl::RulesAreLoaded(DialogSection section) {
|
| AddressData address_data;
|
| - address_data.country_code = CountryCodeForSection(section);
|
| + address_data.region_code = CountryCodeForSection(section);
|
| AddressValidator::Status status = GetValidator()->ValidateAddress(
|
| - address_data, AddressProblemFilter(), NULL);
|
| + address_data, NULL, NULL);
|
| return status == AddressValidator::SUCCESS;
|
| }
|
|
|
| @@ -3600,10 +3608,8 @@ bool AutofillDialogControllerImpl::HasInvalidAddress(
|
| i18n::CreateAddressDataFromAutofillProfile(
|
| profile, g_browser_process->GetApplicationLocale());
|
|
|
| - AddressProblems problems;
|
| - GetValidator()->ValidateAddress(*address_data,
|
| - AddressProblemFilter(),
|
| - &problems);
|
| + FieldProblemMap problems;
|
| + GetValidator()->ValidateAddress(*address_data, NULL, &problems);
|
| return !problems.empty();
|
| }
|
|
|
|
|