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

Unified Diff: components/autofill/core/browser/address_i18n.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/address_i18n.cc
diff --git a/components/autofill/core/browser/address_i18n.cc b/components/autofill/core/browser/address_i18n.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7e23a33269bfadec2f81b602181146724a7fc255
--- /dev/null
+++ b/components/autofill/core/browser/address_i18n.cc
@@ -0,0 +1,43 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/autofill/core/browser/address_i18n.h"
+
+#include "base/logging.h"
+#include "base/strings/string_split.h"
+#include "base/strings/utf_string_conversions.h"
+#include "components/autofill/core/browser/autofill_type.h"
+#include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_data.h"
+
+namespace autofill {
+namespace i18n {
+
+using ::i18n::addressinput::AddressData;
+
+scoped_ptr<AddressData> CreateAddressData(
+ const base::Callback<base::string16(const AutofillType&)>& get_info) {
+ scoped_ptr<AddressData> address_data(new AddressData());
+ address_data->recipient = UTF16ToUTF8(get_info.Run(AutofillType(NAME_FULL)));
+ address_data->country_code = UTF16ToUTF8(
+ get_info.Run(AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_SHIPPING)));
Ilya Sherman 2014/05/07 01:19:19 nit: Why SHIPPING as opposed to NONE?
Evan Stade 2014/05/09 22:14:59 Done.
+ DCHECK_EQ(2U, address_data->country_code.size());
Ilya Sherman 2014/05/07 01:19:19 What if the country code is unspecified?
Evan Stade 2014/05/09 22:14:59 added a testcase
+ address_data->administrative_area = UTF16ToUTF8(
+ get_info.Run(AutofillType(ADDRESS_HOME_STATE)));
+ address_data->locality = UTF16ToUTF8(
+ get_info.Run(AutofillType(ADDRESS_HOME_CITY)));
+ address_data->dependent_locality = UTF16ToUTF8(
+ get_info.Run(AutofillType(ADDRESS_HOME_DEPENDENT_LOCALITY)));
+ address_data->sorting_code = UTF16ToUTF8(
+ get_info.Run(AutofillType(ADDRESS_HOME_SORTING_CODE)));
+ address_data->postal_code = UTF16ToUTF8(
+ get_info.Run(AutofillType(ADDRESS_HOME_ZIP)));
+ base::SplitString(
+ UTF16ToUTF8(get_info.Run(AutofillType(ADDRESS_HOME_STREET_ADDRESS))),
+ '\n',
Ilya Sherman 2014/05/07 01:19:19 Not all addresses are joined with newlines, right?
Evan Stade 2014/05/09 22:14:59 Yes, all addresses are joined with newlines in the
+ &address_data->address_lines);
+ return address_data.Pass();
+}
+
+} // namespace i18n
+} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698