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

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: self review 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..5bb36c3aaf7350c1296547158dec10819890cf4d 100644
--- a/components/autofill/core/browser/autofill_profile.cc
+++ b/components/autofill/core/browser/autofill_profile.cc
@@ -16,6 +16,7 @@
#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,6 +26,7 @@
#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"
using base::ASCIIToUTF16;
@@ -293,6 +295,17 @@ 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::CreateAddressDataFromAutofillProfile(*this, app_locale);
+ if (!address_data->HasAllRequiredFields())
+ return base::string16();
+
+ 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();
« no previous file with comments | « components/autofill/core/browser/address_i18n.cc ('k') | components/autofill/core/browser/autofill_profile_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698