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

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

Issue 148273010: rAc: fix international address formatting (mostly) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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/data_model_wrapper.cc
diff --git a/chrome/browser/ui/autofill/data_model_wrapper.cc b/chrome/browser/ui/autofill/data_model_wrapper.cc
index a61a32b71687e5eb6aa9c0bc9361aa8cbb38f564..5b5ae7be237d0f176fdc4db206e58453d14bbf9a 100644
--- a/chrome/browser/ui/autofill/data_model_wrapper.cc
+++ b/chrome/browser/ui/autofill/data_model_wrapper.cc
@@ -56,12 +56,18 @@ gfx::Image DataModelWrapper::GetIcon() {
bool DataModelWrapper::GetDisplayText(
base::string16* vertically_compact,
base::string16* horizontally_compact) {
+ base::string16 phone =
+ GetInfoForDisplay(AutofillType(PHONE_HOME_WHOLE_NUMBER));
+ if (phone.empty())
+ return false;
Dan Beam 2014/01/29 04:15:09 ^ but out of curiosity, why return false for only
+
// Format the address.
::i18n::addressinput::AddressData address_data;
address_data.recipient = UTF16ToUTF8(
GetInfoForDisplay(AutofillType(NAME_FULL)));
- address_data.country_code = UTF16ToUTF8(
- GetInfoForDisplay(AutofillType(ADDRESS_HOME_COUNTRY)));
+ address_data.country_code = UTF16ToASCII(
+ GetInfoForDisplay(AutofillType(HTML_TYPE_COUNTRY_CODE,
+ HTML_MODE_SHIPPING)));
Dan Beam 2014/01/29 03:26:59 ^ what's the effective difference here?
Evan Stade 2014/01/29 04:11:00 returns country code instead of human-readable nam
Dan Beam 2014/01/29 07:14:45 not lgtm -- this breaks FieldMapWrapper (which ass
address_data.administrative_area = UTF16ToUTF8(
GetInfoForDisplay(AutofillType(ADDRESS_HOME_STATE)));
address_data.locality = UTF16ToUTF8(
@@ -88,8 +94,7 @@ bool DataModelWrapper::GetDisplayText(
if (!email.empty())
non_address_info += ASCIIToUTF16("\n") + email;
- non_address_info += ASCIIToUTF16("\n") +
- GetInfoForDisplay(AutofillType(PHONE_HOME_WHOLE_NUMBER));
+ non_address_info += ASCIIToUTF16("\n") + phone;
// The separator is locale-specific.
std::string compact_separator =
@@ -276,10 +281,8 @@ base::string16 WalletAddressWrapper::GetInfoForDisplay(const AutofillType& type)
bool WalletAddressWrapper::GetDisplayText(
base::string16* vertically_compact,
base::string16* horizontally_compact) {
- if (!address_->is_complete_address() ||
- GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER)).empty()) {
+ if (!address_->is_complete_address())
return false;
- }
return DataModelWrapper::GetDisplayText(vertically_compact,
horizontally_compact);
@@ -324,12 +327,15 @@ bool WalletInstrumentWrapper::GetDisplayText(
base::string16* horizontally_compact) {
// TODO(dbeam): handle other instrument statuses? http://crbug.com/233048
if (instrument_->status() == wallet::WalletItems::MaskedInstrument::EXPIRED ||
- !instrument_->address().is_complete_address() ||
- GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER)).empty()) {
+ !instrument_->address().is_complete_address()) {
+ return false;
+ }
+
+ if (!DataModelWrapper::GetDisplayText(vertically_compact,
+ horizontally_compact)) {
return false;
}
- DataModelWrapper::GetDisplayText(vertically_compact, horizontally_compact);
// TODO(estade): descriptive_name() is user-provided. Should we use it or
// just type + last 4 digits?
base::string16 line1 = instrument_->descriptive_name() + ASCIIToUTF16("\n");

Powered by Google App Engine
This is Rietveld 408576698