Chromium Code Reviews| 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 72cf35b3c7b95d449836df720b1cda51042b3a57..e519907868b8fe4eefce0c691df111b3dcd66e2c 100644 |
| --- a/components/autofill/core/browser/webdata/autofill_table.cc |
| +++ b/components/autofill/core/browser/webdata/autofill_table.cc |
| @@ -483,6 +483,9 @@ bool AutofillTable::MigrateToVersion(int version, |
| case 71: |
| *update_compatible_version = true; |
| return MigrateToVersion71AddHasConvertedAndBillingAddressIdMetadata(); |
| + case 72: |
| + *update_compatible_version = true; |
| + return MigrateToVersion72AddMaskedCardBankName(); |
| } |
| return true; |
| } |
| @@ -1239,7 +1242,8 @@ bool AutofillTable::GetServerCreditCards( |
| "name_on_card," // 7 |
| "exp_month," // 8 |
| "exp_year," // 9 |
| - "metadata.billing_address_id " // 10 |
| + "metadata.billing_address_id," // 10 |
| + "bank_name " // 11 |
| "FROM masked_credit_cards masked " |
| "LEFT OUTER JOIN unmasked_credit_cards USING (id) " |
| "LEFT OUTER JOIN server_card_metadata metadata USING (id)")); |
| @@ -1282,6 +1286,7 @@ bool AutofillTable::GetServerCreditCards( |
| 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++)); |
| + card->SetBankName(s.ColumnString(index++)); |
| credit_cards->push_back(std::move(card)); |
| } |
| @@ -1307,8 +1312,9 @@ void AutofillTable::SetServerCreditCards( |
| "name_on_card," // 3 |
| "last_four," // 4 |
| "exp_month," // 5 |
| - "exp_year)" // 6 |
| - "VALUES (?,?,?,?,?,?,?)")); |
| + "exp_year," // 6 |
| + "bank_name)" // 7 |
| + "VALUES (?,?,?,?,?,?,?,?)")); |
| for (const CreditCard& card : credit_cards) { |
| DCHECK_EQ(CreditCard::MASKED_SERVER_CARD, card.record_type()); |
| @@ -1321,6 +1327,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.bank_name()); |
| masked_insert.Run(); |
| masked_insert.Reset(true); |
| @@ -1936,7 +1943,8 @@ bool AutofillTable::InitMaskedCreditCardsTable() { |
| "type VARCHAR," |
| "last_four VARCHAR," |
| "exp_month INTEGER DEFAULT 0," |
| - "exp_year INTEGER DEFAULT 0)")) { |
| + "exp_year INTEGER DEFAULT 0," |
| + " bank_name VARCHAR)")) { |
|
Jared Saul
2017/03/03 23:40:09
remove space in front?
Shanfeng
2017/03/04 00:01:08
This is a standard way to make migrating from the
Jared Saul
2017/03/10 19:51:54
(FYI I kind of thought that might be the case, but
Shanfeng
2017/03/10 21:49:57
It is weird. Exp_year is in the table when this ta
Mathieu
2017/03/31 18:25:10
elsewhere they put the space on the previous line
Shanfeng
2017/04/12 01:58:59
Done.
|
| NOTREACHED(); |
| return false; |
| } |
| @@ -2544,4 +2552,19 @@ bool AutofillTable:: |
| return transaction.Commit(); |
| } |
| +bool AutofillTable::MigrateToVersion72AddMaskedCardBankName() { |
| + sql::Transaction transaction(db_); |
| + if (!transaction.Begin()) |
| + return false; |
| + |
| + // Add the new bank_name column to the masked_credit_cards table. |
| + if (!db_->DoesColumnExist("masked_credit_cards", "bank_name") && |
| + !db_->Execute("ALTER TABLE masked_credit_cards ADD COLUMN " |
| + "bank_name VARCHAR")) { |
| + return false; |
| + } |
| + |
| + return transaction.Commit(); |
| +} |
| + |
| } // namespace autofill |