diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 03:24:55 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-20 03:24:55 +0000 |
commit | d3d728e9b36811fb77d8176297d607c84e6a2d18 (patch) | |
tree | 200690d244f5ab82d30283dd0ec16052225d3281 /chrome/browser/autofill/autofill_profile.h | |
parent | e3322f4b2588371b962b0a7da5fbede0ace0cdd8 (diff) | |
download | chromium_src-d3d728e9b36811fb77d8176297d607c84e6a2d18.zip chromium_src-d3d728e9b36811fb77d8176297d607c84e6a2d18.tar.gz chromium_src-d3d728e9b36811fb77d8176297d607c84e6a2d18.tar.bz2 |
This is stage 1 of transition to GUIDs as primary identifier for AutoFill profiles and credit cards.
The transition will look like this in terms of table migration:
Current:
CREATE TABLE autofill_profiles (
label VARCHAR,
unique_id INTEGER PRIMARY KEY,
first_name VARCHAR,
middle_name VARCHAR,
last_name VARCHAR,
email VARCHAR,
company_name VARCHAR,
address_line_1 VARCHAR,
address_line_2 VARCHAR,
city VARCHAR,
state VARCHAR,
zipcode VARCHAR,
country VARCHAR,
phone VARCHAR,
fax VARCHAR);
Transitional (adds guid column):
CREATE TABLE autofill_profiles (
label VARCHAR,
unique_id INTEGER PRIMARY KEY,
first_name VARCHAR,
middle_name VARCHAR,
last_name VARCHAR,
email VARCHAR,
company_name VARCHAR,
address_line_1 VARCHAR,
address_line_2 VARCHAR,
city VARCHAR,
state VARCHAR,
zipcode VARCHAR,
country VARCHAR,
phone VARCHAR,
fax VARCHAR,
guid VARCHAR NOT NULL); // <- add guid
End goal (in follow up CL):
CREATE TABLE autofill_profiles (
// remove label
// remove unique_id
guid VARCHAR NOT NULL PRIMARY KEY // <- reorder guid, make primary
first_name VARCHAR,
middle_name VARCHAR,
last_name VARCHAR,
email VARCHAR,
company_name VARCHAR,
address_line_1 VARCHAR,
address_line_2 VARCHAR,
city VARCHAR,
state VARCHAR,
zipcode VARCHAR,
country VARCHAR,
phone VARCHAR,
fax VARCHAR);
And similarly for the credit_cards table.
BUG=58813
TEST=AutoFillProfileTest.Compare, GUIDTest.GUIDCorrectlyFormatted, WebDataServiceAutofillTest.ProfileRemoveGUID, WebDataServiceAutofillTest.CreditCardRemoveGUID, WebDatabaseTest.AutoFillProfile, WebDatabaseTest.CreditCard, WebDatabaseMigrationTest.MigrateVersion30ToCurrent
Review URL: http://codereview.chromium.org/3760009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63173 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/autofill_profile.h')
-rw-r--r-- | chrome/browser/autofill/autofill_profile.h | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/chrome/browser/autofill/autofill_profile.h b/chrome/browser/autofill/autofill_profile.h index 1da4f27..4336139b 100644 --- a/chrome/browser/autofill/autofill_profile.h +++ b/chrome/browser/autofill/autofill_profile.h @@ -21,7 +21,11 @@ typedef std::map<FieldTypeGroup, FormGroup*> FormGroupMap; // to the requested form group type. class AutoFillProfile : public FormGroup { public: + // DEPRECATED + // TODO(dhollowa): Remove unique ID and label. http://crbug.com/58813 AutoFillProfile(const string16& label, int unique_id); + explicit AutoFillProfile(const std::string& guid); + // For use in STL containers. AutoFillProfile(); AutoFillProfile(const AutoFillProfile&); @@ -44,8 +48,12 @@ class AutoFillProfile : public FormGroup { virtual FormGroup* Clone() const; virtual const string16& Label() const; - void set_unique_id(int id) { unique_id_ = id; } int unique_id() const { return unique_id_; } + void set_unique_id(int id) { unique_id_ = id; } + + // This guid is the primary identifier for |AutoFillProfile| objects. + const std::string guid() const { return guid_; } + void set_guid(const std::string& guid) { guid_ = guid; } // Profile summary string for UI. // Constructs a summary string based on NAME_FIRST, NAME_LAST, and @@ -88,7 +96,17 @@ class AutoFillProfile : public FormGroup { // For use in STL containers. void operator=(const AutoFillProfile&); - // For WebData and Sync. + // Comparison for Sync. Returns 0 if the profile is the same as |this|, + // or < 0, or > 0 if it is different. The implied ordering can be used for + // culling duplicates. + // GUIDs, labels, and unique IDs are not compared, only the values of the + // profiles themselves. + int Compare(const AutoFillProfile& profile) const; + + // TODO(dhollowa): These operators need to be made private and then the unit + // tests that use them made friends. The public |Compare| method should be + // used by external clients (such as Sync). + // http://crbug.com/58813 bool operator==(const AutoFillProfile& profile) const; virtual bool operator!=(const AutoFillProfile& profile) const; void set_label(const string16& label) { label_ = label; } @@ -109,6 +127,9 @@ class AutoFillProfile : public FormGroup { // The unique ID of this profile. int unique_id_; + // The guid of this profile. + std::string guid_; + // Personal information for this profile. FormGroupMap personal_info_; }; |