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

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

Issue 24538008: rAc: phone number cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixme Created 7 years, 3 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 366b22d9ae7af7ba2bc5171c5b9b28b2a4b09ef8..bed8f2e1dae4fc981252d47cfc25c31a6952fb2e 100644
--- a/chrome/browser/ui/autofill/data_model_wrapper.cc
+++ b/chrome/browser/ui/autofill/data_model_wrapper.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/autofill/data_model_wrapper.h"
#include "base/callback.h"
+#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/ui/autofill/autofill_dialog_models.h"
@@ -30,6 +31,11 @@ void DataModelWrapper::FillInputs(DetailInputs* inputs) {
}
}
+base::string16 DataModelWrapper::GetInfoForDisplay(const AutofillType& type)
+ const {
+ return GetInfo(type);
+}
+
gfx::Image DataModelWrapper::GetIcon() {
return gfx::Image();
}
@@ -71,23 +77,23 @@ void DataModelWrapper::FillFormField(AutofillField* field) const {
base::string16 DataModelWrapper::GetAddressDisplayText(
const base::string16& separator) {
- base::string16 address = GetInfo(AutofillType(NAME_FULL)) + separator +
- GetInfo(AutofillType(ADDRESS_HOME_LINE1));
- base::string16 address2 = GetInfo(AutofillType(ADDRESS_HOME_LINE2));
+ base::string16 address = GetInfoForDisplay(AutofillType(NAME_FULL)) +
+ separator + GetInfoForDisplay(AutofillType(ADDRESS_HOME_LINE1));
+ base::string16 address2 = GetInfoForDisplay(AutofillType(ADDRESS_HOME_LINE2));
if (!address2.empty())
address += separator + address2;
base::string16 comma = ASCIIToUTF16(", ");
base::string16 newline = ASCIIToUTF16("\n");
address += separator +
- GetInfo(AutofillType(ADDRESS_HOME_CITY)) + comma +
- GetInfo(AutofillType(ADDRESS_HOME_STATE)) + ASCIIToUTF16(" ") +
- GetInfo(AutofillType(ADDRESS_HOME_ZIP));
+ GetInfoForDisplay(AutofillType(ADDRESS_HOME_CITY)) + comma +
+ GetInfoForDisplay(AutofillType(ADDRESS_HOME_STATE)) + ASCIIToUTF16(" ") +
+ GetInfoForDisplay(AutofillType(ADDRESS_HOME_ZIP));
- base::string16 email = GetInfo(AutofillType(EMAIL_ADDRESS));
+ base::string16 email = GetInfoForDisplay(AutofillType(EMAIL_ADDRESS));
if (!email.empty())
address += newline + email;
- address += newline + GetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER));
+ address += newline + GetInfoForDisplay(AutofillType(PHONE_HOME_WHOLE_NUMBER));
return address;
}
@@ -128,6 +134,27 @@ base::string16 AutofillProfileWrapper::GetInfo(const AutofillType& type)
return values[GetVariantForType(type)];
}
+base::string16 AutofillProfileWrapper::GetInfoForDisplay(
+ const AutofillType& type) const {
+ // We display the "raw" phone number which contains user-defined formatting.
+ if (type.GetStorableType() == PHONE_HOME_WHOLE_NUMBER) {
+ std::vector<base::string16> values;
+ profile_->GetRawMultiInfo(type.GetStorableType(), &values);
+ base::string16 phone_number = values[GetVariantForType(type)];
Ilya Sherman 2013/09/26 22:01:06 Optional nit: const-ref?
Evan Stade 2013/09/27 00:29:17 Done.
+
+ if (ContainsOnlyChars(phone_number, ASCIIToUTF16("0123456789"))) {
Ilya Sherman 2013/09/26 22:01:06 nit: Please add a comment describing what this blo
Evan Stade 2013/09/27 00:29:17 Done.
+ std::string region = UTF16ToASCII(
+ GetInfo(AutofillType(HTML_TYPE_COUNTRY_CODE, HTML_MODE_NONE)));
+ i18n::PhoneObject phone(phone_number, region);
+ phone_number = phone.GetFormattedNumber();
+ }
+
+ return phone_number;
+ }
+
+ return GetInfo(type);
Ilya Sherman 2013/09/26 22:01:06 Optional nit: Perhaps this should call DataModelWr
Evan Stade 2013/09/27 00:29:17 Done.
+}
+
void AutofillProfileWrapper::FillFormField(AutofillField* field) const {
if (field->Type().GetStorableType() == CREDIT_CARD_NAME) {
// Cache the field's true type.
@@ -229,6 +256,14 @@ base::string16 WalletAddressWrapper::GetInfo(const AutofillType& type) const {
return address_->GetInfo(type, g_browser_process->GetApplicationLocale());
}
+base::string16 WalletAddressWrapper::GetInfoForDisplay(const AutofillType& type)
+ const {
+ if (type.GetStorableType() == PHONE_HOME_WHOLE_NUMBER)
+ return address_->DisplayPhoneNumber();
+
+ return GetInfo(type);
+}
+
bool WalletAddressWrapper::GetDisplayText(
base::string16* vertically_compact,
base::string16* horizontally_compact) {
@@ -261,6 +296,14 @@ base::string16 WalletInstrumentWrapper::GetInfo(const AutofillType& type)
return instrument_->GetInfo(type, g_browser_process->GetApplicationLocale());
}
+base::string16 WalletInstrumentWrapper::GetInfoForDisplay(
+ const AutofillType& type) const {
+ if (type.GetStorableType() == PHONE_HOME_WHOLE_NUMBER)
+ return instrument_->address().DisplayPhoneNumber();
+
+ return GetInfo(type);
+}
+
gfx::Image WalletInstrumentWrapper::GetIcon() {
return instrument_->CardIcon();
}

Powered by Google App Engine
This is Rietveld 408576698