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

Unified Diff: components/autofill/core/browser/autofill_profile.cc

Issue 261013010: autocomplete: add ability to get full address (hidden behind a flag). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: GCC weirdness Created 6 years, 7 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: components/autofill/core/browser/autofill_profile.cc
diff --git a/components/autofill/core/browser/autofill_profile.cc b/components/autofill/core/browser/autofill_profile.cc
index 02d6197e8176a0128b5d24ea78b932e329d3c1ef..9d4410a312bffdb003f7890b6a2e9f734f99fa04 100644
--- a/components/autofill/core/browser/autofill_profile.cc
+++ b/components/autofill/core/browser/autofill_profile.cc
@@ -11,11 +11,13 @@
#include <set>
#include "base/basictypes.h"
+#include "base/bind.h"
#include "base/guid.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/address.h"
+#include "components/autofill/core/browser/address_i18n.h"
#include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/autofill_type.h"
@@ -25,8 +27,10 @@
#include "components/autofill/core/browser/validation.h"
#include "components/autofill/core/common/form_field_data.h"
#include "grit/component_strings.h"
+#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h"
#include "ui/base/l10n/l10n_util.h"
+
Ilya Sherman 2014/05/07 01:19:19 nit: Spurious newline.
Evan Stade 2014/05/09 22:14:59 Done.
using base::ASCIIToUTF16;
using base::UTF16ToUTF8;
@@ -221,6 +225,12 @@ struct CaseInsensitiveStringEquals
}
};
+base::string16 GetInfoHelper(const AutofillProfile* profile,
Ilya Sherman 2014/05/07 01:19:19 nit: Why not const-ref?
Evan Stade 2014/05/09 22:14:59 Done.
+ const std::string& app_locale,
+ const AutofillType& type) {
+ return profile->GetInfo(type, app_locale);
+}
+
} // namespace
AutofillProfile::AutofillProfile(const std::string& guid,
@@ -293,6 +303,15 @@ void AutofillProfile::SetRawInfo(ServerFieldType type,
base::string16 AutofillProfile::GetInfo(const AutofillType& type,
const std::string& app_locale) const {
+ if (type.html_type() == HTML_TYPE_FULL_ADDRESS) {
+ scoped_ptr<::i18n::addressinput::AddressData> address_data =
+ i18n::CreateAddressData(base::Bind(&GetInfoHelper, this, app_locale));
+ address_data->language_code = language_code();
+ std::vector<std::string> lines;
+ address_data->FormatForDisplay(&lines);
+ return base::UTF8ToUTF16(JoinString(lines, '\n'));
+ }
+
const FormGroup* form_group = FormGroupForType(type);
if (!form_group)
return base::string16();

Powered by Google App Engine
This is Rietveld 408576698