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 47856d71641dea74888e29e131c4e8624f653fc1..b8627b3630d230517867b36fce9dc602ed734156 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,20 @@ 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, g_browser_process->GetApplicationLocale()); |
+ std::string not_used; |
+ return ::i18n::addressinput::BuildComponents( |
+ country_code, localization, |
+ language_code == NULL ? ¬_used : language_code); |
+} |
DetailInput::Length LengthFromHint(AddressUiComponent::LengthHint hint) { |
if (hint == AddressUiComponent::HINT_SHORT) |
@@ -35,29 +48,24 @@ DetailInput::Length LengthFromHint(AddressUiComponent::LengthHint hint) { |
return DetailInput::LONG; |
} |
+ |
+ |
Evan Stade
2014/06/12 00:18:08
^H^H
please use gerrit instead
2014/06/13 19:22:09
Done.
|
} // namespace |
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 +101,8 @@ bool AddressHasCompleteAndVerifiedData(const AutofillProfile& profile, |
if (!profile.IsVerified()) |
return false; |
- if (!i18n::CreateAddressDataFromAutofillProfile(profile, app_locale)-> |
- HasAllRequiredFields()) { |
+ if (!HasAllRequiredFields(*i18n::CreateAddressDataFromAutofillProfile( |
Evan Stade
2014/06/12 00:18:08
HasAllRequiredFields probably should have a namesp
please use gerrit instead
2014/06/13 19:22:09
How about "addressinput" namespace?
Evan Stade
2014/06/13 20:07:08
ok
|
+ profile, app_locale))) { |
return false; |
} |
@@ -133,15 +141,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 +187,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) |
@@ -198,9 +199,8 @@ bool FieldForType(ServerFieldType server_type, |
bool CountryIsFullySupported(const std::string& country_code) { |
DCHECK_EQ(2U, country_code.size()); |
- std::vector< ::i18n::addressinput::AddressUiComponent> components = |
- ::i18n::addressinput::BuildComponents( |
- country_code, g_browser_process->GetApplicationLocale(), NULL); |
+ const std::vector<AddressUiComponent>& components( |
+ BuildComponents(country_code, NULL)); |
for (size_t i = 0; i < components.size(); ++i) { |
if (components[i].field == ::i18n::addressinput::DEPENDENT_LOCALITY) |
return false; |