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

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

Issue 1868003003: Preserving first/middle/last names when an Autofill profile is submitted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing stevenjb nits Created 4 years, 8 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/autofill_data_util.cc
diff --git a/components/autofill/core/browser/autofill_data_util.cc b/components/autofill/core/browser/autofill_data_util.cc
index 63dc48213a01f9e4e7d1b95df2df7717d69696f7..7387ed737ee06a4c2928a891cda050d0f829e724 100644
--- a/components/autofill/core/browser/autofill_data_util.cc
+++ b/components/autofill/core/browser/autofill_data_util.cc
@@ -9,6 +9,7 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "components/autofill/core/browser/field_types.h"
namespace autofill {
namespace data_util {
@@ -128,5 +129,44 @@ NameParts SplitName(const base::string16& name) {
return parts;
}
+bool ProfileMatchesFullName(const base::string16 full_name,
+ const autofill::AutofillProfile& profile) {
+ const base::string16 kSpace = base::ASCIIToUTF16(" ");
+ const base::string16 kPeriodSpace = base::ASCIIToUTF16(". ");
+
+ // First Last
+ base::string16 candidate = profile.GetRawInfo(autofill::NAME_FIRST) + kSpace +
+ profile.GetRawInfo(autofill::NAME_LAST);
+ if (!full_name.compare(candidate)) {
+ return true;
+ }
+
+ // First Middle Last
+ candidate = profile.GetRawInfo(autofill::NAME_FIRST) + kSpace +
+ profile.GetRawInfo(autofill::NAME_MIDDLE) + kSpace +
+ profile.GetRawInfo(autofill::NAME_LAST);
+ if (!full_name.compare(candidate)) {
+ return true;
+ }
+
+ // First M Last
+ candidate = profile.GetRawInfo(autofill::NAME_FIRST) + kSpace +
+ profile.GetRawInfo(autofill::NAME_MIDDLE_INITIAL) + kSpace +
+ profile.GetRawInfo(autofill::NAME_LAST);
+ if (!full_name.compare(candidate)) {
+ return true;
+ }
+
+ // First M. Last
+ candidate = profile.GetRawInfo(autofill::NAME_FIRST) + kSpace +
+ profile.GetRawInfo(autofill::NAME_MIDDLE_INITIAL) + kPeriodSpace +
+ profile.GetRawInfo(autofill::NAME_LAST);
+ if (!full_name.compare(candidate)) {
+ return true;
+ }
+
+ return false;
+}
+
} // namespace data_util
} // namespace autofill
« no previous file with comments | « components/autofill/core/browser/autofill_data_util.h ('k') | components/autofill/core/browser/autofill_data_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698