diff options
Diffstat (limited to 'chrome')
15 files changed, 144 insertions, 114 deletions
diff --git a/chrome/browser/ui/autofill/DEPS b/chrome/browser/ui/autofill/DEPS index 63d3f1d..f3e1593 100644 --- a/chrome/browser/ui/autofill/DEPS +++ b/chrome/browser/ui/autofill/DEPS @@ -1,6 +1,8 @@ include_rules = [ '+third_party/libaddressinput/chromium/addressinput_util.h', + '+third_party/libaddressinput/chromium/chrome_address_validator.h', '+third_party/libaddressinput/chromium/chrome_downloader_impl.h', '+third_party/libaddressinput/chromium/chrome_storage_impl.h', - '+third_party/libaddressinput/chromium/cpp/include/libaddressinput', + '+third_party/libaddressinput/messages.h', + '+third_party/libaddressinput/src/cpp/include/libaddressinput', ] diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc index c9fc9cb..6547bfe 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc @@ -81,7 +81,6 @@ namespace { using testing::Return; using testing::_; -using ::i18n::addressinput::AddressValidator; void MockCallback(AutofillClient::RequestAutocompleteResult, const base::string16& message, diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc index 5bb45d1..0fd243e 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc @@ -80,14 +80,16 @@ #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/chromium/cpp/include/libaddressinput/address_data.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_problem.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 "ui/base/base_window.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/combobox_model.h" @@ -99,9 +101,12 @@ 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::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; namespace autofill { @@ -867,12 +872,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<Downloader>( + new autofill::ChromeDownloaderImpl(profile_->GetRequestContext())), ValidationRulesStorageFactory::CreateStorage(), - this); + this)); SuggestionsUpdated(); SubmitButtonDelayBegin(); @@ -1944,14 +1949,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; @@ -1983,7 +1988,7 @@ base::string16 AutofillDialogControllerImpl::InputValidityMessage( } return value.empty() ? l10n_util::GetStringUTF16( - IDS_LIBADDRESSINPUT_I18N_MISSING_REQUIRED_FIELD) : + IDS_LIBADDRESSINPUT_MISSING_REQUIRED_FIELD) : base::string16(); } @@ -2004,17 +2009,19 @@ ValidityMessages AutofillDialogControllerImpl::InputsAreValid( profile, g_browser_process->GetApplicationLocale()); address_data->language_code = AddressLanguageCodeForSection(section); - AddressProblems problems; - status = GetValidator()->ValidateAddress(*address_data, - AddressProblemFilter(), - &problems); + Localization localization; + localization.SetGetter(l10n_util::GetStringUTF8); + 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), + + 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), ValidityMessage(text, sure)); } } @@ -3431,9 +3438,7 @@ void AutofillDialogControllerImpl::GetI18nValidatorSuggestions( // region of the suggested address: // ADMIN_AREA > LOCALITY > DEPENDENT_LOCALITY popup_labels->push_back(base::string16()); - for (int field = ::i18n::addressinput::DEPENDENT_LOCALITY; - field >= ::i18n::addressinput::ADMIN_AREA; - --field) { + for (int field = DEPENDENT_LOCALITY; field >= ADMIN_AREA; --field) { const std::string& field_value = i18n_validator_suggestions_[i].GetFieldValue( static_cast<AddressField>(field)); @@ -3616,7 +3621,7 @@ bool AutofillDialogControllerImpl::RulesAreLoaded(DialogSection section) { AddressData address_data; address_data.region_code = CountryCodeForSection(section); AddressValidator::Status status = GetValidator()->ValidateAddress( - address_data, AddressProblemFilter(), NULL); + address_data, NULL, NULL); return status == AddressValidator::SUCCESS; } @@ -3668,10 +3673,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(); } diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h index 690df26..561fb6b 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h @@ -35,8 +35,7 @@ #include "content/public/browser/notification_registrar.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/common/ssl_status.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_validator.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/load_rules_delegate.h" +#include "third_party/libaddressinput/chromium/chrome_address_validator.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/base/models/simple_menu_model.h" #include "ui/base/ui_base_types.h" @@ -50,6 +49,12 @@ namespace content { class WebContents; } +namespace i18n { +namespace addressinput { +struct AddressData; +} +} + namespace autofill { class AutofillDataModel; @@ -79,7 +84,7 @@ class AutofillDialogControllerImpl public PersonalDataManagerObserver, public AccountChooserModelDelegate, public gfx::AnimationDelegate, - public ::i18n::addressinput::LoadRulesDelegate { + public LoadRulesListener { public: virtual ~AutofillDialogControllerImpl(); @@ -218,7 +223,7 @@ class AutofillDialogControllerImpl virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; - // ::i18n::addressinput::LoadRulesDelegate implementation. + // LoadRulesListener implementation. virtual void OnAddressValidationRulesLoaded(const std::string& country_code, bool success) OVERRIDE; @@ -249,7 +254,7 @@ class AutofillDialogControllerImpl virtual PersonalDataManager* GetManager() const; // Returns an address validation helper. May be NULL during tests. - virtual ::i18n::addressinput::AddressValidator* GetValidator(); + virtual AddressValidator* GetValidator(); // Returns the WalletClient* this class uses to talk to Online Wallet. Exposed // for testing. @@ -655,7 +660,7 @@ class AutofillDialogControllerImpl wallet::WalletClient wallet_client_; // A helper to validate international address input. - scoped_ptr< ::i18n::addressinput::AddressValidator> validator_; + scoped_ptr<AddressValidator> validator_; // True if |this| has ever called GetWalletItems(). bool wallet_items_requested_; diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc index 23bdc30..cc1de74 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc @@ -3,7 +3,9 @@ // found in the LICENSE file. #include <map> +#include <utility> +#include "base/basictypes.h" #include "base/bind.h" #include "base/bind_helpers.h" #include "base/callback.h" @@ -55,8 +57,9 @@ #include "grit/generated_resources.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_validator.h" +#include "third_party/libaddressinput/chromium/chrome_address_validator.h" +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_field.h" +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_problem.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" @@ -71,11 +74,7 @@ namespace autofill { namespace { -using ::i18n::addressinput::AddressData; -using ::i18n::addressinput::AddressProblemFilter; -using ::i18n::addressinput::AddressProblem; -using ::i18n::addressinput::AddressProblems; -using ::i18n::addressinput::AddressValidator; +using ::i18n::addressinput::FieldProblemMap; using testing::AtLeast; using testing::DoAll; using testing::Return; @@ -1021,11 +1020,9 @@ TEST_F(AutofillDialogControllerTest, AutofillProfilesPopInvalidIntoEdit) { // Now make up a problem and make sure the profile isn't in the list. Reset(); SwitchToAutofill(); - AddressProblems problems; - problems.push_back( - AddressProblem(::i18n::addressinput::POSTAL_CODE, - AddressProblem::MISMATCHING_VALUE, - IDS_LEARN_MORE)); + FieldProblemMap problems; + problems.insert(std::make_pair(::i18n::addressinput::POSTAL_CODE, + ::i18n::addressinput::MISMATCHING_VALUE)); EXPECT_CALL(*controller()->GetMockValidator(), ValidateAddress(CountryCodeMatcher("US"), _, _)). WillRepeatedly(DoAll(SetArgPointee<2>(problems), @@ -1053,11 +1050,9 @@ TEST_F(AutofillDialogControllerTest, AutofillProfilesRevalidateAfterRulesLoad) { EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_SHIPPING)); EXPECT_FALSE(controller()->IsManuallyEditingSection(SECTION_BILLING)); - AddressProblems problems; - problems.push_back( - AddressProblem(::i18n::addressinput::POSTAL_CODE, - AddressProblem::MISMATCHING_VALUE, - IDS_LEARN_MORE)); + FieldProblemMap problems; + problems.insert(std::make_pair(::i18n::addressinput::POSTAL_CODE, + ::i18n::addressinput::MISMATCHING_VALUE)); EXPECT_CALL(*controller()->GetMockValidator(), ValidateAddress(CountryCodeMatcher("US"), _, _)). WillRepeatedly(DoAll(SetArgPointee<2>(problems), diff --git a/chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc b/chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc index 5452503..f53cd5d 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc @@ -13,10 +13,11 @@ #include "components/autofill/core/browser/field_types.h" #include "grit/components_strings.h" #include "third_party/libaddressinput/chromium/addressinput_util.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_field.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_ui.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_ui_component.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_ui.h" +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui_component.h" +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/localization.h" #include "ui/base/l10n/l10n_util.h" namespace autofill { @@ -25,9 +26,19 @@ namespace i18ninput { namespace { using base::UTF16ToUTF8; -using ::i18n::addressinput::AddressData; using ::i18n::addressinput::AddressField; using ::i18n::addressinput::AddressUiComponent; +using ::i18n::addressinput::Localization; + +std::vector<AddressUiComponent> BuildComponents(const std::string& country_code, + std::string* language_code) { + Localization localization; + localization.SetGetter(l10n_util::GetStringUTF8); + std::string not_used; + return ::i18n::addressinput::BuildComponents( + country_code, localization, g_browser_process->GetApplicationLocale(), + language_code == NULL ? ¬_used : language_code); +} DetailInput::Length LengthFromHint(AddressUiComponent::LengthHint hint) { if (hint == AddressUiComponent::HINT_SHORT) @@ -42,10 +53,8 @@ void BuildAddressInputs(common::AddressType address_type, const std::string& country_code, DetailInputs* inputs, std::string* language_code) { - std::vector<AddressUiComponent> components( - ::i18n::addressinput::BuildComponents( - country_code, g_browser_process->GetApplicationLocale(), - language_code)); + const std::vector<AddressUiComponent>& components( + BuildComponents(country_code, language_code)); const bool billing = address_type == common::ADDRESS_TYPE_BILLING; @@ -53,7 +62,7 @@ void BuildAddressInputs(common::AddressType address_type, const AddressUiComponent& component = components[i]; ServerFieldType server_type = TypeForField(component.field, address_type); DetailInput::Length length = LengthFromHint(component.length_hint); - base::string16 placeholder = l10n_util::GetStringUTF16(component.name_id); + base::string16 placeholder = base::UTF8ToUTF16(component.name); DetailInput input = { length, server_type, placeholder }; inputs->push_back(input); } @@ -134,8 +143,7 @@ ServerFieldType TypeForField(AddressField address_field, return UNKNOWN_TYPE; } -bool FieldForType(ServerFieldType server_type, - ::i18n::addressinput::AddressField* field) { +bool FieldForType(ServerFieldType server_type, AddressField* field) { switch (server_type) { case ADDRESS_BILLING_COUNTRY: case ADDRESS_HOME_COUNTRY: diff --git a/chrome/browser/ui/autofill/autofill_dialog_i18n_input.h b/chrome/browser/ui/autofill/autofill_dialog_i18n_input.h index 67b8728..89be251 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_i18n_input.h +++ b/chrome/browser/ui/autofill/autofill_dialog_i18n_input.h @@ -12,13 +12,7 @@ #include "chrome/browser/ui/autofill/autofill_dialog_common.h" #include "chrome/browser/ui/autofill/autofill_dialog_types.h" #include "components/autofill/core/browser/autofill_type.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_field.h" - -namespace i18n { -namespace addressinput { -struct AddressData; -} -} +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_field.h" namespace autofill { diff --git a/chrome/browser/ui/autofill/autofill_dialog_i18n_input_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_i18n_input_unittest.cc index a9e0bd6..d8ea9dd 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_i18n_input_unittest.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_i18n_input_unittest.cc @@ -6,7 +6,7 @@ #include "components/autofill/core/browser/field_types.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_ui.h" +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui.h" namespace autofill { namespace i18ninput { diff --git a/chrome/browser/ui/autofill/country_combobox_model.cc b/chrome/browser/ui/autofill/country_combobox_model.cc index a5d9f62..fda64cb4 100644 --- a/chrome/browser/ui/autofill/country_combobox_model.cc +++ b/chrome/browser/ui/autofill/country_combobox_model.cc @@ -4,6 +4,9 @@ #include "chrome/browser/ui/autofill/country_combobox_model.h" +#include <algorithm> +#include <iterator> + #include "base/logging.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process.h" @@ -14,7 +17,7 @@ // TODO(rouslan): Remove this check. http://crbug.com/337587 #if defined(ENABLE_AUTOFILL_DIALOG) -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_ui.h" +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui.h" #endif namespace autofill { @@ -41,12 +44,22 @@ void CountryComboboxModel::SetCountries( } // The sorted list of countries. -#if defined(ENABLE_AUTOFILL_DIALOG) - const std::vector<std::string>& available_countries = - ::i18n::addressinput::GetRegionCodes(); -#else std::vector<std::string> available_countries; AutofillCountry::GetAvailableCountries(&available_countries); + +#if defined(ENABLE_AUTOFILL_DIALOG) + // Filter out the countries that do not have rules for address input and + // validation. + const std::vector<std::string>& addressinput_countries = + ::i18n::addressinput::GetRegionCodes(); + std::vector<std::string> filtered_countries; + filtered_countries.reserve(available_countries.size()); + std::set_intersection(available_countries.begin(), + available_countries.end(), + addressinput_countries.begin(), + addressinput_countries.end(), + std::back_inserter(filtered_countries)); + available_countries.swap(filtered_countries); #endif std::vector<AutofillCountry*> sorted_countries; diff --git a/chrome/browser/ui/autofill/country_combobox_model_unittest.cc b/chrome/browser/ui/autofill/country_combobox_model_unittest.cc index 4fef855..c243d8e 100644 --- a/chrome/browser/ui/autofill/country_combobox_model_unittest.cc +++ b/chrome/browser/ui/autofill/country_combobox_model_unittest.cc @@ -10,8 +10,9 @@ #include "components/autofill/core/browser/autofill_country.h" #include "components/autofill/core/browser/test_personal_data_manager.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_ui.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_ui_component.h" +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui.h" +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui_component.h" +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/localization.h" namespace autofill { @@ -44,6 +45,8 @@ TEST_F(CountryComboboxModelTest, DefaultCountryCode) { } TEST_F(CountryComboboxModelTest, AllCountriesHaveComponents) { + ::i18n::addressinput::Localization localization; + std::string unused; for (int i = 0; i < model()->GetItemCount(); ++i) { if (model()->IsItemSeparatorAt(i)) continue; @@ -51,7 +54,7 @@ TEST_F(CountryComboboxModelTest, AllCountriesHaveComponents) { std::string country_code = model()->countries()[i]->country_code(); std::vector< ::i18n::addressinput::AddressUiComponent> components = ::i18n::addressinput::BuildComponents( - country_code, std::string(), NULL); + country_code, localization, std::string(), &unused); EXPECT_FALSE(components.empty()); } } diff --git a/chrome/browser/ui/autofill/data_model_wrapper.cc b/chrome/browser/ui/autofill/data_model_wrapper.cc index 92b5fc1..de9b8b7 100644 --- a/chrome/browser/ui/autofill/data_model_wrapper.cc +++ b/chrome/browser/ui/autofill/data_model_wrapper.cc @@ -22,8 +22,9 @@ #include "components/autofill/core/browser/autofill_type.h" #include "components/autofill/core/browser/credit_card.h" #include "components/autofill/core/browser/form_structure.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_formatter.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 "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" @@ -63,6 +64,10 @@ bool DataModelWrapper::GetDisplayText( std::vector<std::string> lines; ::i18n::addressinput::GetFormattedNationalAddress(*address_data, &lines); + std::string single_line; + ::i18n::addressinput::GetFormattedNationalAddressLine( + *address_data, &single_line); + // Email and phone number aren't part of address formatting. base::string16 non_address_info; base::string16 email = GetInfoForDisplay(AutofillType(EMAIL_ADDRESS)); @@ -71,12 +76,9 @@ bool DataModelWrapper::GetDisplayText( non_address_info += base::ASCIIToUTF16("\n") + phone; - std::string line_address; - ::i18n::addressinput::GetFormattedNationalAddressLine(*address_data, - &line_address); - *vertically_compact = base::UTF8ToUTF16(line_address) + non_address_info; - *horizontally_compact = - base::UTF8ToUTF16(JoinString(lines, "\n")) + non_address_info; + *vertically_compact = base::UTF8ToUTF16(single_line) + non_address_info; + *horizontally_compact = base::UTF8ToUTF16(JoinString(lines, "\n")) + + non_address_info; return true; } diff --git a/chrome/browser/ui/autofill/mock_address_validator.h b/chrome/browser/ui/autofill/mock_address_validator.h index b80bddb..f2052d4 100644 --- a/chrome/browser/ui/autofill/mock_address_validator.h +++ b/chrome/browser/ui/autofill/mock_address_validator.h @@ -7,8 +7,8 @@ #include "base/basictypes.h" #include "testing/gmock/include/gmock/gmock.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_validator.h" +#include "third_party/libaddressinput/chromium/chrome_address_validator.h" +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_data.h" namespace autofill { @@ -17,7 +17,7 @@ MATCHER_P(CountryCodeMatcher, country_code, "Checks an AddressData's country") { return arg.region_code == country_code; } -class MockAddressValidator : public ::i18n::addressinput::AddressValidator { +class MockAddressValidator : public AddressValidator { public: MockAddressValidator(); virtual ~MockAddressValidator(); @@ -25,13 +25,13 @@ class MockAddressValidator : public ::i18n::addressinput::AddressValidator { MOCK_METHOD1(LoadRules, void(const std::string& country_code)); MOCK_CONST_METHOD3(ValidateAddress, - ::i18n::addressinput::AddressValidator::Status( + AddressValidator::Status( const ::i18n::addressinput::AddressData& address, - const ::i18n::addressinput::AddressProblemFilter& filter, - ::i18n::addressinput::AddressProblems* problems)); + const ::i18n::addressinput::FieldProblemMap* filter, + ::i18n::addressinput::FieldProblemMap* problems)); MOCK_CONST_METHOD4(GetSuggestions, - ::i18n::addressinput::AddressValidator::Status( + AddressValidator::Status( const ::i18n::addressinput::AddressData& user_input, ::i18n::addressinput::AddressField focused_field, size_t suggestions_limit, diff --git a/chrome/browser/ui/webui/DEPS b/chrome/browser/ui/webui/DEPS index f24772a..acfa06d 100644 --- a/chrome/browser/ui/webui/DEPS +++ b/chrome/browser/ui/webui/DEPS @@ -13,7 +13,7 @@ include_rules = [ "+device/nfc", "+third_party/angle", # For ANGLE version. "+third_party/zlib/zlib.h", # For compression level constants. - "+third_party/libaddressinput/chromium/cpp/include", # For i18n address input. + "+third_party/libaddressinput", # For i18n address input. # DOM Distiller. "+components/dom_distiller/core", diff --git a/chrome/browser/ui/webui/options/autofill_options_handler.cc b/chrome/browser/ui/webui/options/autofill_options_handler.cc index cfe09e4..e1ff4c6 100644 --- a/chrome/browser/ui/webui/options/autofill_options_handler.cc +++ b/chrome/browser/ui/webui/options/autofill_options_handler.cc @@ -28,9 +28,10 @@ #include "content/public/browser/web_ui.h" #include "grit/components_strings.h" #include "grit/generated_resources.h" -#include "grit/libaddressinput_strings.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_ui.h" -#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_ui_component.h" +#include "third_party/libaddressinput/messages.h" +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui.h" +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui_component.h" +#include "third_party/libaddressinput/src/cpp/include/libaddressinput/localization.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/webui/web_ui_util.h" @@ -69,13 +70,24 @@ void GetAddressComponents(const std::string& country_code, std::string* components_language_code) { DCHECK(address_components); + i18n::addressinput::Localization localization; + localization.SetGetter(l10n_util::GetStringUTF8); + std::string not_used; std::vector<AddressUiComponent> components = i18n::addressinput::BuildComponents( - country_code, ui_language_code, components_language_code); + country_code, + localization, + ui_language_code, + components_language_code == NULL ? + ¬_used : components_language_code); if (components.empty()) { static const char kDefaultCountryCode[] = "US"; components = i18n::addressinput::BuildComponents( - kDefaultCountryCode, ui_language_code, components_language_code); + kDefaultCountryCode, + localization, + ui_language_code, + components_language_code == NULL ? + ¬_used : components_language_code); } DCHECK(!components.empty()); @@ -91,8 +103,7 @@ void GetAddressComponents(const std::string& country_code, } scoped_ptr<base::DictionaryValue> component(new base::DictionaryValue); - component->SetString( - "name", l10n_util::GetStringUTF16(components[i].name_id)); + component->SetString("name", components[i].name); switch (components[i].field) { case i18n::addressinput::COUNTRY: @@ -376,7 +387,7 @@ void AutofillOptionsHandler::SetAddressOverlayStrings( localized_strings->SetString("autofillEditAddressTitle", l10n_util::GetStringUTF16(IDS_AUTOFILL_EDIT_ADDRESS_CAPTION)); localized_strings->SetString("autofillCountryLabel", - l10n_util::GetStringUTF16(IDS_LIBADDRESSINPUT_I18N_COUNTRY_LABEL)); + l10n_util::GetStringUTF16(IDS_LIBADDRESSINPUT_COUNTRY_OR_REGION_LABEL)); localized_strings->SetString("autofillPhoneLabel", l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_PHONE)); localized_strings->SetString("autofillEmailLabel", diff --git a/chrome/tools/build/repack_locales.py b/chrome/tools/build/repack_locales.py index f837d2a..832d0be 100755 --- a/chrome/tools/build/repack_locales.py +++ b/chrome/tools/build/repack_locales.py @@ -111,13 +111,8 @@ def calc_inputs(locale): if ENABLE_AUTOFILL_DIALOG and OS != 'ios' and OS != 'android': #e.g. '<(SHARED_INTERMEDIATE_DIR)/third_party/libaddressinput/ - # libaddressinput_strings_da.pak', - inputs.append(os.path.join(SHARE_INT_DIR, 'third_party', 'libaddressinput', - 'libaddressinput_strings_%s.pak' % locale)) - - #e.g. '<(SHARED_INTERMEDIATE_DIR)/grit/libaddressinput/ # address_input_strings_da.pak', - inputs.append(os.path.join(SHARE_INT_DIR, 'grit', 'libaddressinput', + inputs.append(os.path.join(SHARE_INT_DIR, 'third_party', 'libaddressinput', 'address_input_strings_%s.pak' % locale)) #e.g. '<(grit_out_dir)/google_chrome_strings_da.pak' |