Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(554)

Unified Diff: trunk/src/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc

Issue 388613002: Revert 282408 "Use upstream libaddressinput in Chrome." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: trunk/src/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc
===================================================================
--- trunk/src/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc (revision 282425)
+++ trunk/src/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc (working copy)
@@ -80,16 +80,14 @@
#include "grit/component_scaled_resources.h"
#include "grit/components_strings.h"
#include "grit/generated_resources.h"
+#include "grit/libaddressinput_strings.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/messages.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 "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h"
+#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_problem.h"
#include "ui/base/base_window.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/combobox_model.h"
@@ -101,12 +99,9 @@
using ::i18n::addressinput::AddressData;
using ::i18n::addressinput::AddressField;
using ::i18n::addressinput::AddressProblem;
-using ::i18n::addressinput::ADMIN_AREA;
-using ::i18n::addressinput::DEPENDENT_LOCALITY;
-using ::i18n::addressinput::Downloader;
-using ::i18n::addressinput::FieldProblemMap;
-using ::i18n::addressinput::Localization;
-using ::i18n::addressinput::MISSING_REQUIRED_FIELD;
+using ::i18n::addressinput::AddressProblemFilter;
+using ::i18n::addressinput::AddressProblems;
+using ::i18n::addressinput::AddressValidator;
namespace autofill {
@@ -872,12 +867,12 @@
if (account_chooser_model_->WalletIsSelected())
FetchWalletCookie();
- validator_.reset(new AddressValidator(
- I18N_ADDRESS_VALIDATION_DATA_URL,
- scoped_ptr<Downloader>(
- new autofill::ChromeDownloaderImpl(profile_->GetRequestContext())),
+ scoped_ptr< ::i18n::addressinput::Downloader> downloader(
+ new autofill::ChromeDownloaderImpl(profile_->GetRequestContext()));
+ validator_ = AddressValidator::Build(
+ downloader.Pass(),
ValidationRulesStorageFactory::CreateStorage(),
- this));
+ this);
SuggestionsUpdated();
SubmitButtonDelayBegin();
@@ -1949,14 +1944,14 @@
case CREDIT_CARD_EXP_MONTH:
if (!InputWasEdited(CREDIT_CARD_EXP_MONTH, value)) {
return l10n_util::GetStringUTF16(
- IDS_LIBADDRESSINPUT_MISSING_REQUIRED_FIELD);
+ IDS_LIBADDRESSINPUT_I18N_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_MISSING_REQUIRED_FIELD);
+ IDS_LIBADDRESSINPUT_I18N_MISSING_REQUIRED_FIELD);
}
break;
@@ -1988,7 +1983,7 @@
}
return value.empty() ? l10n_util::GetStringUTF16(
- IDS_LIBADDRESSINPUT_MISSING_REQUIRED_FIELD) :
+ IDS_LIBADDRESSINPUT_I18N_MISSING_REQUIRED_FIELD) :
base::string16();
}
@@ -2009,19 +2004,17 @@
profile, g_browser_process->GetApplicationLocale());
address_data->language_code = AddressLanguageCodeForSection(section);
- Localization localization;
- localization.SetGetter(l10n_util::GetStringUTF8);
- FieldProblemMap problems;
- status = GetValidator()->ValidateAddress(*address_data, NULL, &problems);
+ AddressProblems problems;
+ status = GetValidator()->ValidateAddress(*address_data,
+ AddressProblemFilter(),
+ &problems);
common::AddressType address_type = section == SECTION_SHIPPING ?
common::ADDRESS_TYPE_SHIPPING : common::ADDRESS_TYPE_BILLING;
-
- for (FieldProblemMap::const_iterator iter = problems.begin();
- iter != problems.end(); ++iter) {
- bool sure = iter->second != MISSING_REQUIRED_FIELD;
- base::string16 text = base::UTF8ToUTF16(localization.GetErrorMessage(
- *address_data, iter->first, iter->second, true, false));
- messages.Set(i18ninput::TypeForField(iter->first, address_type),
+ 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),
ValidityMessage(text, sure));
}
}
@@ -3438,7 +3431,9 @@
// region of the suggested address:
// ADMIN_AREA > LOCALITY > DEPENDENT_LOCALITY
popup_labels->push_back(base::string16());
- for (int field = DEPENDENT_LOCALITY; field >= ADMIN_AREA; --field) {
+ for (int field = ::i18n::addressinput::DEPENDENT_LOCALITY;
+ field >= ::i18n::addressinput::ADMIN_AREA;
+ --field) {
const std::string& field_value =
i18n_validator_suggestions_[i].GetFieldValue(
static_cast<AddressField>(field));
@@ -3621,7 +3616,7 @@
AddressData address_data;
address_data.region_code = CountryCodeForSection(section);
AddressValidator::Status status = GetValidator()->ValidateAddress(
- address_data, NULL, NULL);
+ address_data, AddressProblemFilter(), NULL);
return status == AddressValidator::SUCCESS;
}
@@ -3673,8 +3668,10 @@
i18n::CreateAddressDataFromAutofillProfile(
profile, g_browser_process->GetApplicationLocale());
- FieldProblemMap problems;
- GetValidator()->ValidateAddress(*address_data, NULL, &problems);
+ AddressProblems problems;
+ GetValidator()->ValidateAddress(*address_data,
+ AddressProblemFilter(),
+ &problems);
return !problems.empty();
}

Powered by Google App Engine
This is Rietveld 408576698