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

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

Issue 2818033: AutoFill: Aggregate profile data. Remove the AutoFill InfoBar. (Closed)
Patch Set: Comment. Created 10 years, 6 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 | « chrome/browser/autofill/autofill_profile.h ('k') | chrome/browser/autofill/autofill_profile_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 655f938d4f4402dd73ccd809f88c1b1560aba51c..a0d128254a7a0154b0a463229a085533713e544e 100644
--- a/chrome/browser/autofill/autofill_profile.cc
+++ b/chrome/browser/autofill/autofill_profile.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/autofill/autofill_profile.h"
+#include <algorithm>
#include <vector>
#include "app/l10n_util.h"
@@ -52,12 +53,21 @@ AutoFillProfile::~AutoFillProfile() {
void AutoFillProfile::GetPossibleFieldTypes(
const string16& text,
FieldTypeSet* possible_types) const {
- FormGroupMap::const_iterator iter;
- for (iter = personal_info_.begin(); iter != personal_info_.end(); ++iter) {
+ for (FormGroupMap::const_iterator iter = personal_info_.begin();
+ iter != personal_info_.end(); ++iter) {
+ FormGroup* data = iter->second;
+ DCHECK(data != NULL);
+ data->GetPossibleFieldTypes(text, possible_types);
+ }
+}
+
+void AutoFillProfile::GetAvailableFieldTypes(
+ FieldTypeSet* available_types) const {
+ for (FormGroupMap::const_iterator iter = personal_info_.begin();
+ iter != personal_info_.end(); ++iter) {
FormGroup* data = iter->second;
DCHECK(data != NULL);
- if (data != NULL)
- data->GetPossibleFieldTypes(text, possible_types);
+ data->GetAvailableFieldTypes(available_types);
}
}
@@ -148,6 +158,58 @@ FormGroup* AutoFillProfile::Clone() const {
return profile;
}
+bool AutoFillProfile::IsSubsetOf(const AutoFillProfile& profile) const {
+ FieldTypeSet types;
+ GetAvailableFieldTypes(&types);
+
+ for (FieldTypeSet::const_iterator iter = types.begin(); iter != types.end();
+ ++iter) {
+ AutoFillType type(*iter);
+ if (GetFieldText(type) != profile.GetFieldText(type))
+ return false;
+ }
+
+ return true;
+}
+
+bool AutoFillProfile::IntersectionOfTypesHasEqualValues(
+ const AutoFillProfile& profile) const {
+ FieldTypeSet a, b, intersection;
+ GetAvailableFieldTypes(&a);
+ profile.GetAvailableFieldTypes(&b);
+ std::set_intersection(a.begin(), a.end(),
+ b.begin(), b.end(),
+ std::inserter(intersection, intersection.begin()));
+
+ // An empty intersection can't have equal values.
+ if (intersection.empty())
+ return false;
+
+ for (FieldTypeSet::const_iterator iter = intersection.begin();
+ iter != intersection.end(); ++iter) {
+ AutoFillType type(*iter);
+ if (GetFieldText(type) != profile.GetFieldText(type))
+ return false;
+ }
+
+ return true;
+}
+
+void AutoFillProfile::MergeWith(const AutoFillProfile& profile) {
+ FieldTypeSet a, b, intersection;
+ GetAvailableFieldTypes(&a);
+ profile.GetAvailableFieldTypes(&b);
+ std::set_difference(b.begin(), b.end(),
+ a.begin(), a.end(),
+ std::inserter(intersection, intersection.begin()));
+
+ for (FieldTypeSet::const_iterator iter = intersection.begin();
+ iter != intersection.end(); ++iter) {
+ AutoFillType type(*iter);
+ SetInfo(type, profile.GetFieldText(type));
+ }
+}
+
string16 AutoFillProfile::PreviewSummary() const {
// Fetch the components of the summary string. Any or all of these
// may be an empty string.
« no previous file with comments | « chrome/browser/autofill/autofill_profile.h ('k') | chrome/browser/autofill/autofill_profile_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698