diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 00:57:33 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 00:57:33 +0000 |
commit | cea1d11b9375368e29906255b7f865f78045200b (patch) | |
tree | b8cde41281263b22a948510933ee5e82c6ffa9b9 /chrome/browser/autofill/autofill_profile.cc | |
parent | e7c3784d1fb8d5f1862409fe62feab2112b70af0 (diff) | |
download | chromium_src-cea1d11b9375368e29906255b7f865f78045200b.zip chromium_src-cea1d11b9375368e29906255b7f865f78045200b.tar.gz chromium_src-cea1d11b9375368e29906255b7f865f78045200b.tar.bz2 |
AutoFill: Aggregate profile data. Remove the AutoFill InfoBar. Remove more remnants of shipping address and CVV.
BUG=47426,47423
TEST=PersonalDataManager.*
Review URL: http://codereview.chromium.org/2818033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51322 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/autofill_profile.cc')
-rw-r--r-- | chrome/browser/autofill/autofill_profile.cc | 70 |
1 files changed, 66 insertions, 4 deletions
diff --git a/chrome/browser/autofill/autofill_profile.cc b/chrome/browser/autofill/autofill_profile.cc index 655f938..a0d1282 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. |