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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc

Issue 389733002: Reland "Use upstream libaddressinput in Chrome." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix GN build. 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: 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 b077905304ed23a0f0a91a527a96aa079e1693f0..083b32dcfe246abfd9368aaab20f253032b80cd1 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 ? &not_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);
}
@@ -136,8 +145,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:

Powered by Google App Engine
This is Rietveld 408576698