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

Unified Diff: chrome/browser/autofill/autofill_profile.cc

Issue 7649001: Autofill: Use case-insensitive comparison when merging values in multi-valued fields. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/autofill/personal_data_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/autofill_profile.cc
diff --git a/chrome/browser/autofill/autofill_profile.cc b/chrome/browser/autofill/autofill_profile.cc
index 45122b1d6d204856343537e8368d14caaed55536..bdeab8370d66091795e05a20be96190330243b81 100644
--- a/chrome/browser/autofill/autofill_profile.cc
+++ b/chrome/browser/autofill/autofill_profile.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/autofill/autofill_profile.h"
#include <algorithm>
+#include <functional>
#include <map>
#include <set>
@@ -537,6 +538,16 @@ const string16 AutofillProfile::PrimaryValue() const {
GetInfo(ADDRESS_HOME_CITY);
}
+// Functor used to check for case-insensitive equality of two strings.
+struct CaseInsensitiveStringEquals
+ : public std::binary_function<string16, string16, bool>
+{
+ bool operator()(const string16& x, const string16& y) const {
+ return std::equal(x.begin(), x.end(), y.begin(),
+ base::CaseInsensitiveCompare<string16::value_type>());
+ }
+};
+
void AutofillProfile::OverwriteWithOrAddTo(const AutofillProfile& profile) {
FieldTypeSet field_types;
profile.GetNonEmptyTypes(&field_types);
@@ -560,10 +571,11 @@ void AutofillProfile::OverwriteWithOrAddTo(const AutofillProfile& profile) {
group == AutofillType::PHONE_FAX) {
AddPhoneIfUnique(*value_iter, &existing_values);
} else {
- if (std::find(existing_values.begin(), existing_values.end(),
- *value_iter) == existing_values.end()) {
+ std::vector<string16>::const_iterator existing_iter = std::find_if(
+ existing_values.begin(), existing_values.end(),
+ std::bind1st(CaseInsensitiveStringEquals(), *value_iter));
+ if (existing_iter == existing_values.end())
existing_values.insert(existing_values.end(), *value_iter);
- }
}
}
SetMultiInfo(*iter, existing_values);
« no previous file with comments | « no previous file | chrome/browser/autofill/personal_data_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698