| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/autofill/core/browser/webdata/autofill_table.h" | 5 #include "components/autofill/core/browser/webdata/autofill_table.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 if (!credit_card) | 1202 if (!credit_card) |
| 1203 return false; | 1203 return false; |
| 1204 credit_cards->push_back(std::move(credit_card)); | 1204 credit_cards->push_back(std::move(credit_card)); |
| 1205 } | 1205 } |
| 1206 | 1206 |
| 1207 return s.Succeeded(); | 1207 return s.Succeeded(); |
| 1208 } | 1208 } |
| 1209 | 1209 |
| 1210 bool AutofillTable::GetServerCreditCards( | 1210 bool AutofillTable::GetServerCreditCards( |
| 1211 std::vector<std::unique_ptr<CreditCard>>* credit_cards) const { | 1211 std::vector<std::unique_ptr<CreditCard>>* credit_cards) const { |
| 1212 |
| 1213 LOG(WARNING) << "3fengLog: get server credit cards start."; |
| 1212 credit_cards->clear(); | 1214 credit_cards->clear(); |
| 1213 | 1215 |
| 1214 sql::Statement s(db_->GetUniqueStatement( | 1216 sql::Statement s(db_->GetUniqueStatement( |
| 1215 "SELECT " | 1217 "SELECT " |
| 1216 "card_number_encrypted, " // 0 | 1218 "card_number_encrypted, " // 0 |
| 1217 "last_four," // 1 | 1219 "last_four," // 1 |
| 1218 "masked.id," // 2 | 1220 "masked.id," // 2 |
| 1219 "metadata.use_count," // 3 | 1221 "metadata.use_count," // 3 |
| 1220 "metadata.use_date," // 4 | 1222 "metadata.use_date," // 4 |
| 1221 "network," // 5 | 1223 "network," // 5 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 } | 1264 } |
| 1263 | 1265 |
| 1264 card->SetServerStatus(ServerStatusStringToEnum(s.ColumnString(index++))); | 1266 card->SetServerStatus(ServerStatusStringToEnum(s.ColumnString(index++))); |
| 1265 card->SetRawInfo(CREDIT_CARD_NAME_FULL, s.ColumnString16(index++)); | 1267 card->SetRawInfo(CREDIT_CARD_NAME_FULL, s.ColumnString16(index++)); |
| 1266 card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++)); | 1268 card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++)); |
| 1267 card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(index++)); | 1269 card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(index++)); |
| 1268 card->set_billing_address_id(s.ColumnString(index++)); | 1270 card->set_billing_address_id(s.ColumnString(index++)); |
| 1269 card->set_bank_name(s.ColumnString(index++)); | 1271 card->set_bank_name(s.ColumnString(index++)); |
| 1270 credit_cards->push_back(std::move(card)); | 1272 credit_cards->push_back(std::move(card)); |
| 1271 } | 1273 } |
| 1274 LOG(WARNING) << "3fengLog: get server credit cards finish."; |
| 1272 return s.Succeeded(); | 1275 return s.Succeeded(); |
| 1273 } | 1276 } |
| 1274 | 1277 |
| 1275 void AutofillTable::AddMaskedCreditCards( | 1278 void AutofillTable::AddMaskedCreditCards( |
| 1276 const std::vector<CreditCard>& credit_cards) { | 1279 const std::vector<CreditCard>& credit_cards) { |
| 1277 DCHECK_GT(db_->transaction_nesting(), 0); | 1280 DCHECK_GT(db_->transaction_nesting(), 0); |
| 1278 sql::Statement masked_insert( | 1281 sql::Statement masked_insert( |
| 1279 db_->GetUniqueStatement("INSERT INTO masked_credit_cards(" | 1282 db_->GetUniqueStatement("INSERT INTO masked_credit_cards(" |
| 1280 "id," // 0 | 1283 "id," // 0 |
| 1281 "network," // 1 | 1284 "network," // 1 |
| (...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2605 "ALTER TABLE masked_credit_cards_temp " | 2608 "ALTER TABLE masked_credit_cards_temp " |
| 2606 "RENAME TO masked_credit_cards") && | 2609 "RENAME TO masked_credit_cards") && |
| 2607 transaction.Commit(); | 2610 transaction.Commit(); |
| 2608 } | 2611 } |
| 2609 | 2612 |
| 2610 bool AutofillTable::MigrateToVersion73AddMaskedCardBankName() { | 2613 bool AutofillTable::MigrateToVersion73AddMaskedCardBankName() { |
| 2611 sql::Transaction transaction(db_); | 2614 sql::Transaction transaction(db_); |
| 2612 if (!transaction.Begin()) | 2615 if (!transaction.Begin()) |
| 2613 return false; | 2616 return false; |
| 2614 | 2617 |
| 2618 LOG(WARNING) << "3fengLog: try migrate to version 73."; |
| 2615 // Add the new bank_name column to the masked_credit_cards table. | 2619 // Add the new bank_name column to the masked_credit_cards table. |
| 2616 if (!db_->DoesColumnExist("masked_credit_cards", "bank_name") && | 2620 if (!db_->DoesColumnExist("masked_credit_cards", "bank_name") && |
| 2617 !db_->Execute("ALTER TABLE masked_credit_cards ADD COLUMN " | 2621 !db_->Execute("ALTER TABLE masked_credit_cards ADD COLUMN " |
| 2618 "bank_name VARCHAR")) { | 2622 "bank_name VARCHAR")) { |
| 2619 return false; | 2623 return false; |
| 2620 } | 2624 } |
| 2625 LOG(WARNING) << "3fengLog: migrated to version 73."; |
| 2621 | 2626 |
| 2622 return transaction.Commit(); | 2627 return transaction.Commit(); |
| 2623 } | 2628 } |
| 2624 | 2629 |
| 2625 } // namespace autofill | 2630 } // namespace autofill |
| OLD | NEW |