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

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_i18n_input.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: 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 5dc33e3ca7fcaa7ac0e893d1fb92cb964ab64a4e..be42221c8d3e6501e0d971a9c341f9a3c8ae76a6 100644
--- a/chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc
+++ b/chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc
@@ -7,6 +7,7 @@
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
+#include "components/autofill/core/browser/address_i18n.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/field_types.h"
@@ -87,22 +88,14 @@ bool CardHasCompleteAndVerifiedData(const CreditCard& card) {
return true;
}
-bool AddressHasCompleteAndVerifiedData(const AutofillProfile& profile) {
+bool AddressHasCompleteAndVerifiedData(const AutofillProfile& profile,
+ const std::string& app_locale) {
if (!profile.IsVerified())
return false;
- base::string16 country_code = profile.GetRawInfo(ADDRESS_HOME_COUNTRY);
- if (country_code.empty())
+ if (!i18n::CreateAddressDataFromAutofillProfile(profile, app_locale)->
+ HasAllRequiredFields()) {
return false;
-
- std::vector<AddressField> required_fields =
- ::i18n::addressinput::GetRequiredFields(base::UTF16ToUTF8(country_code));
-
- for (size_t i = 0; i < required_fields.size(); ++i) {
- ServerFieldType type =
- TypeForField(required_fields[i], common::ADDRESS_TYPE_SHIPPING);
- if (profile.GetRawInfo(type).empty())
- return false;
}
const ServerFieldType more_required_fields[] = {
@@ -203,29 +196,6 @@ bool FieldForType(ServerFieldType server_type,
}
}
-void CreateAddressData(
- const base::Callback<base::string16(const AutofillType&)>& get_info,
- AddressData* address_data) {
- 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)));
- DCHECK_EQ(2U, address_data->country_code.size());
- 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',
- &address_data->address_lines);
-}
-
bool CountryIsFullySupported(const std::string& country_code) {
DCHECK_EQ(2U, country_code.size());
std::vector< ::i18n::addressinput::AddressUiComponent> components =
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_i18n_input.h ('k') | chrome/browser/ui/autofill/data_model_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698