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

Unified Diff: components/autofill/core/browser/contact_info.cc

Issue 347183005: autofill names - dont parse when calling SetRawInfo(FULL_NAME) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android test expectation Created 6 years, 5 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/contact_info.cc
diff --git a/components/autofill/core/browser/contact_info.cc b/components/autofill/core/browser/contact_info.cc
index 7571e5f2e37d4ee04b517d029904e6f84bb5eed9..ab79419e7fe6966c78881f05158fa1cf74313ee1 100644
--- a/components/autofill/core/browser/contact_info.cc
+++ b/components/autofill/core/browser/contact_info.cc
@@ -159,7 +159,7 @@ NameInfo& NameInfo::operator=(const NameInfo& info) {
return *this;
}
-bool NameInfo::EqualsIgnoreCase(const NameInfo& info) {
+bool NameInfo::ParsedNamesAreEqual(const NameInfo& info) {
return (StringToLowerASCII(given_) == StringToLowerASCII(info.given_) &&
StringToLowerASCII(middle_) == StringToLowerASCII(info.middle_) &&
StringToLowerASCII(family_) == StringToLowerASCII(info.family_));
@@ -189,7 +189,7 @@ base::string16 NameInfo::GetRawInfo(ServerFieldType type) const {
return MiddleInitial();
case NAME_FULL:
- return FullName();
+ return full_;
default:
return base::string16();
@@ -199,10 +199,6 @@ base::string16 NameInfo::GetRawInfo(ServerFieldType type) const {
void NameInfo::SetRawInfo(ServerFieldType type, const base::string16& value) {
DCHECK_EQ(NAME, AutofillType(type).group());
- // Always clear out the full name if we're making a change.
- if (value != GetRawInfo(type))
- full_.clear();
-
switch (type) {
case NAME_FIRST:
given_ = value;
@@ -218,9 +214,7 @@ void NameInfo::SetRawInfo(ServerFieldType type, const base::string16& value) {
break;
case NAME_FULL:
- // TODO(estade): this should just set |full_|; only SetInfo should attempt
- // to be smart. http://crbug.com/384640
- SetFullName(value);
+ full_ = value;
break;
default:
@@ -228,6 +222,29 @@ void NameInfo::SetRawInfo(ServerFieldType type, const base::string16& value) {
}
}
+base::string16 NameInfo::GetInfo(const AutofillType& type,
+ const std::string& app_locale) const {
+ if (type.GetStorableType() == NAME_FULL)
+ return FullName();
+
+ return GetRawInfo(type.GetStorableType());
+}
+
+bool NameInfo::SetInfo(const AutofillType& type,
+ const base::string16& value,
+ const std::string& app_locale) {
+ // Always clear out the full name if we're making a change.
+ if (value != GetInfo(type, app_locale))
+ full_.clear();
+
+ if (type.GetStorableType() == NAME_FULL) {
+ SetFullName(value);
+ return true;
+ }
+
+ return FormGroup::SetInfo(type, value, app_locale);
+}
+
base::string16 NameInfo::FullName() const {
if (!full_.empty())
return full_;
@@ -256,14 +273,6 @@ base::string16 NameInfo::MiddleInitial() const {
}
void NameInfo::SetFullName(const base::string16& full) {
- // Hack: don't do anything if this wouldn't change the full, concatenated
- // name. Otherwise when unpickling data from the database, "First|Middle|"
- // will get parsed as "First||Middle".
- // TODO(estade): we should be able to remove this when fixing the TODO in
- // SetRawInfo. http://crbug.com/384640
- if (FullName() == full)
- return;
-
full_ = full;
// If |full| is empty, leave the other name parts alone. This might occur
« no previous file with comments | « components/autofill/core/browser/contact_info.h ('k') | components/autofill/core/browser/contact_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698