| Index: chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc
|
| diff --git a/chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc b/chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc
|
| index 56d9988fdffb21c3adcf2d6c93fa1fcc2b4ba07a..2738952674f8b5eb4c6d4d2a9e1fdbf191405a81 100644
|
| --- a/chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc
|
| +++ b/chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc
|
| @@ -12,10 +12,12 @@
|
| #include "components/autofill/core/browser/credit_card.h"
|
| #include "components/autofill/core/browser/field_types.h"
|
| #include "grit/components_strings.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/chromium/has_all_required_fields.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 {
|
| @@ -24,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)
|
| @@ -41,23 +53,16 @@ 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;
|
|
|
| for (size_t i = 0; i < components.size(); ++i) {
|
| const AddressUiComponent& component = components[i];
|
| - if (component.field == ::i18n::addressinput::ORGANIZATION) {
|
| - // TODO(dbeam): figure out when we actually need this.
|
| - continue;
|
| - }
|
| -
|
| 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);
|
| }
|
| @@ -93,8 +98,8 @@ bool AddressHasCompleteAndVerifiedData(const AutofillProfile& profile,
|
| if (!profile.IsVerified())
|
| return false;
|
|
|
| - if (!i18n::CreateAddressDataFromAutofillProfile(profile, app_locale)->
|
| - HasAllRequiredFields()) {
|
| + if (!addressinput::HasAllRequiredFields(
|
| + *i18n::CreateAddressDataFromAutofillProfile(profile, app_locale))) {
|
| return false;
|
| }
|
|
|
| @@ -133,15 +138,12 @@ ServerFieldType TypeForField(AddressField address_field,
|
| ADDRESS_HOME_STREET_ADDRESS;
|
| case ::i18n::addressinput::RECIPIENT:
|
| return billing ? NAME_BILLING_FULL : NAME_FULL;
|
| - case ::i18n::addressinput::ORGANIZATION:
|
| - return COMPANY_NAME;
|
| }
|
| NOTREACHED();
|
| 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:
|
| @@ -182,10 +184,6 @@ bool FieldForType(ServerFieldType server_type,
|
| if (field)
|
| *field = ::i18n::addressinput::STREET_ADDRESS;
|
| return true;
|
| - case COMPANY_NAME:
|
| - if (field)
|
| - *field = ::i18n::addressinput::ORGANIZATION;
|
| - return true;
|
| case NAME_BILLING_FULL:
|
| case NAME_FULL:
|
| if (field)
|
|
|