| Index: components/autofill/core/browser/webdata/autofill_table.cc
|
| diff --git a/components/autofill/core/browser/webdata/autofill_table.cc b/components/autofill/core/browser/webdata/autofill_table.cc
|
| index 5f2ff3a8e8e65c8102f504544ce0736bb811f099..98ebfafce36d2232dabb358884c97a0c74a01a84 100644
|
| --- a/components/autofill/core/browser/webdata/autofill_table.cc
|
| +++ b/components/autofill/core/browser/webdata/autofill_table.cc
|
| @@ -459,6 +459,9 @@ bool AutofillTable::MigrateToVersion(int version,
|
| case 66:
|
| *update_compatible_version = false;
|
| return MigrateToVersion66AddCardBillingAddress();
|
| + case 67:
|
| + *update_compatible_version = false;
|
| + return MigrateToVersion67AddMaskedCardBillingAddress();
|
| }
|
| return true;
|
| }
|
| @@ -1205,7 +1208,8 @@ bool AutofillTable::GetServerCreditCards(
|
| "status," // 6
|
| "name_on_card," // 7
|
| "exp_month," // 8
|
| - "exp_year " // 9
|
| + "exp_year," // 9
|
| + "billing_address_id " // 10
|
| "FROM masked_credit_cards masked "
|
| "LEFT OUTER JOIN unmasked_credit_cards USING (id) "
|
| "LEFT OUTER JOIN server_card_metadata metadata USING (id)"));
|
| @@ -1245,6 +1249,7 @@ bool AutofillTable::GetServerCreditCards(
|
| card->SetRawInfo(CREDIT_CARD_NAME_FULL, s.ColumnString16(index++));
|
| card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++));
|
| card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(index++));
|
| + card->set_billing_address_id(s.ColumnString(index++));
|
| credit_cards->push_back(card);
|
| }
|
|
|
| @@ -1269,9 +1274,10 @@ void AutofillTable::SetServerCreditCards(
|
| "status," // 2
|
| "name_on_card," // 3
|
| "last_four," // 4
|
| - "exp_month," // 4
|
| - "exp_year) " // 5
|
| - "VALUES (?,?,?,?,?,?,?)"));
|
| + "exp_month," // 5
|
| + "exp_year," // 6
|
| + "billing_address_id) " // 7
|
| + "VALUES (?,?,?,?,?,?,?,?)"));
|
| for (const CreditCard& card : credit_cards) {
|
| DCHECK_EQ(CreditCard::MASKED_SERVER_CARD, card.record_type());
|
|
|
| @@ -1284,6 +1290,7 @@ void AutofillTable::SetServerCreditCards(
|
| masked_insert.BindString16(5, card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
|
| masked_insert.BindString16(6,
|
| card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
|
| + masked_insert.BindString(7, card.billing_address_id());
|
|
|
| masked_insert.Run();
|
| masked_insert.Reset(true);
|
| @@ -1394,6 +1401,21 @@ bool AutofillTable::UpdateServerAddressUsageStats(
|
| return db_->GetLastChangeCount() > 0;
|
| }
|
|
|
| +bool AutofillTable::UpdateServerCardBillingAddress(
|
| + const CreditCard& credit_card) {
|
| + DCHECK_NE(CreditCard::LOCAL_CARD, credit_card.record_type());
|
| +
|
| + sql::Statement update(db_->GetUniqueStatement(
|
| + "UPDATE masked_credit_cards SET billing_address_id = ? "
|
| + "WHERE id = ?"));
|
| + update.BindString(0, credit_card.billing_address_id());
|
| + update.BindString(1, credit_card.server_id());
|
| + if (!update.Run())
|
| + return false;
|
| +
|
| + return db_->GetLastChangeCount() > 0;
|
| +}
|
| +
|
| bool AutofillTable::ClearAllServerData() {
|
| sql::Transaction transaction(db_);
|
| if (!transaction.Begin())
|
| @@ -1778,7 +1800,8 @@ bool AutofillTable::InitMaskedCreditCardsTable() {
|
| "type VARCHAR,"
|
| "last_four VARCHAR,"
|
| "exp_month INTEGER DEFAULT 0,"
|
| - "exp_year INTEGER DEFAULT 0)")) {
|
| + "exp_year INTEGER DEFAULT 0, "
|
| + "billing_address_id VARCHAR)")) {
|
| NOTREACHED();
|
| return false;
|
| }
|
| @@ -2281,4 +2304,11 @@ bool AutofillTable::MigrateToVersion66AddCardBillingAddress() {
|
| "ALTER TABLE credit_cards ADD COLUMN billing_address_id VARCHAR");
|
| }
|
|
|
| +bool AutofillTable::MigrateToVersion67AddMaskedCardBillingAddress() {
|
| + // The default value for this column is null, but Connection::ColumnString()
|
| + // returns an empty string for that.
|
| + return db_->Execute(
|
| + "ALTER TABLE masked_credit_cards ADD COLUMN billing_address_id VARCHAR");
|
| +}
|
| +
|
| } // namespace autofill
|
|
|