summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/credit_card.cc
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-20 03:24:55 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-20 03:24:55 +0000
commitd3d728e9b36811fb77d8176297d607c84e6a2d18 (patch)
tree200690d244f5ab82d30283dd0ec16052225d3281 /chrome/browser/autofill/credit_card.cc
parente3322f4b2588371b962b0a7da5fbede0ace0cdd8 (diff)
downloadchromium_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/credit_card.cc')
-rw-r--r--chrome/browser/autofill/credit_card.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/chrome/browser/autofill/credit_card.cc b/chrome/browser/autofill/credit_card.cc
index 98ba665..a288bf6 100644
--- a/chrome/browser/autofill/credit_card.cc
+++ b/chrome/browser/autofill/credit_card.cc
@@ -14,6 +14,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/autofill/autofill_type.h"
#include "chrome/browser/autofill/field_types.h"
+#include "chrome/browser/guid.h"
#include "grit/generated_resources.h"
namespace {
@@ -125,19 +126,30 @@ std::string GetCreditCardType(const string16& number) {
} // namespace
-CreditCard::CreditCard()
+CreditCard::CreditCard(const string16& label,
+ int unique_id)
: expiration_month_(0),
expiration_year_(0),
+ label_(label),
billing_address_id_(0),
- unique_id_(0) {
+ unique_id_(unique_id),
+ guid_(guid::GenerateGUID()) {
}
-CreditCard::CreditCard(const string16& label, int unique_id)
+CreditCard::CreditCard(const std::string& guid)
+ : expiration_month_(0),
+ expiration_year_(0),
+ billing_address_id_(0),
+ unique_id_(0),
+ guid_(guid) {
+}
+
+CreditCard::CreditCard()
: expiration_month_(0),
expiration_year_(0),
- label_(label),
billing_address_id_(0),
- unique_id_(unique_id) {
+ unique_id_(0),
+ guid_(guid::GenerateGUID()) {
}
CreditCard::CreditCard(const CreditCard& card) : FormGroup() {
@@ -373,6 +385,7 @@ void CreditCard::operator=(const CreditCard& source) {
label_ = source.label_;
billing_address_id_ = source.billing_address_id_;
unique_id_ = source.unique_id_;
+ guid_ = source.guid_;
}
bool CreditCard::operator==(const CreditCard& creditcard) const {
@@ -609,6 +622,8 @@ std::ostream& operator<<(std::ostream& os, const CreditCard& creditcard) {
<< " "
<< creditcard.unique_id()
<< " "
+ << creditcard.guid()
+ << " "
<< creditcard.billing_address_id()
<< " "
<< UTF16ToUTF8(creditcard.GetFieldText(AutoFillType(CREDIT_CARD_NAME)))