diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-20 20:15:25 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-20 20:15:25 +0000 |
commit | 4139a98bb67d3044fdb28f9da171cba1691b141d (patch) | |
tree | 861f6584aff3cb69d13cb40dbad4a1d24d37a5ee /chrome/browser/autofill | |
parent | b335f5ea6da983c3736442594fc0684ca37c3601 (diff) | |
download | chromium_src-4139a98bb67d3044fdb28f9da171cba1691b141d.zip chromium_src-4139a98bb67d3044fdb28f9da171cba1691b141d.tar.gz chromium_src-4139a98bb67d3044fdb28f9da171cba1691b141d.tar.bz2 |
Implement initial support for saving and loading AutoFill profiles to the WebDB.
BUG=18201
TEST=WebDatabaseTest.AutoFillProfile
Review URL: http://codereview.chromium.org/548078
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r-- | chrome/browser/autofill/autofill_profile.cc | 31 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_profile.h | 13 |
2 files changed, 39 insertions, 5 deletions
diff --git a/chrome/browser/autofill/autofill_profile.cc b/chrome/browser/autofill/autofill_profile.cc index c0466e8..a292a41 100644 --- a/chrome/browser/autofill/autofill_profile.cc +++ b/chrome/browser/autofill/autofill_profile.cc @@ -125,6 +125,37 @@ void AutoFillProfile::operator=(const AutoFillProfile& source) { } } +bool AutoFillProfile::operator==(const AutoFillProfile& profile) const { + // The following AutoFill field types are the only types we store in the WebDB + // so far, so we're only concerned with matching these types in the profile. + const AutoFillFieldType types[] = { NAME_FIRST, + NAME_MIDDLE, + NAME_LAST, + EMAIL_ADDRESS, + COMPANY_NAME, + ADDRESS_HOME_LINE1, + ADDRESS_HOME_LINE2, + ADDRESS_HOME_CITY, + ADDRESS_HOME_STATE, + ADDRESS_HOME_ZIP, + ADDRESS_HOME_COUNTRY, + PHONE_HOME_NUMBER, + PHONE_FAX_NUMBER }; + + if (label_ != profile.label_ || + unique_id_ != profile.unique_id_ || + use_billing_address_ != profile.use_billing_address_) + return false; + + for (size_t index = 0; index < arraysize(types); ++index) { + if (GetFieldText(AutoFillType(types[index])) != + profile.GetFieldText(AutoFillType(types[index]))) + return false; + } + + return true; +} + void AutoFillProfile::set_use_billing_address(bool use) { if (use_billing_address_ == use) return; diff --git a/chrome/browser/autofill/autofill_profile.h b/chrome/browser/autofill/autofill_profile.h index 4b1fde6..a6ed0d3 100644 --- a/chrome/browser/autofill/autofill_profile.h +++ b/chrome/browser/autofill/autofill_profile.h @@ -21,7 +21,7 @@ typedef std::map<FieldTypeGroup, FormGroup*> FormGroupMap; class AutoFillProfile : public FormGroup { public: AutoFillProfile(const string16& label, int unique_id); - // for use in std containers + // For use in std containers. AutoFillProfile(); AutoFillProfile(const AutoFillProfile&); virtual ~AutoFillProfile(); @@ -42,9 +42,6 @@ class AutoFillProfile : public FormGroup { virtual FormGroup* Clone() const; virtual string16 Label() const { return label_; } - // for use in std containers - void operator=(const AutoFillProfile&); - // NOTE: callers must write the profile to the WebDB after changing the value // of use_billing_address. void set_use_billing_address(bool use); @@ -52,7 +49,13 @@ class AutoFillProfile : public FormGroup { int unique_id() const { return unique_id_; } - // TODO(jhawkins): Implement RemoveProfile. + // For use in std containers. + void operator=(const AutoFillProfile&); + + // Used by tests. + bool operator==(const AutoFillProfile& profile) const; + void set_label(const string16& label) { label_ = label; } + void set_unique_id(int id) { unique_id_ = id; } private: Address* GetBillingAddress(); |