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

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 further mathp 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..4eb7447fe043e874655acda93a869eec1d2bce6d 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 {
@@ -30,6 +31,9 @@ const char* const family_name_prefixes[] = {"d'", "de", "del", "der", "di",
"la", "le", "mc", "san", "st",
"ter", "van", "von"};
+const base::string16 kSpace = base::ASCIIToUTF16(" ");
Mathieu 2016/04/15 16:59:40 nit: can you move this into ProfileMatchesFullName
tmartino 2016/04/16 20:06:53 Done.
+const base::string16 kPeriodSpace = base::ASCIIToUTF16(". ");
+
// Returns true if |set| contains |element|, modulo a final period.
bool ContainsString(const char* const set[],
size_t set_size,
@@ -128,5 +132,41 @@ NameParts SplitName(const base::string16& name) {
return parts;
}
+bool ProfileMatchesFullName(const base::string16 full_name,
+ const autofill::AutofillProfile& profile) {
+ // 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