| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 sql::Statement masked_insert(db_->GetUniqueStatement( | 1227 sql::Statement masked_insert(db_->GetUniqueStatement( |
| 1228 "INSERT INTO masked_credit_cards(" | 1228 "INSERT INTO masked_credit_cards(" |
| 1229 "id," // 0 | 1229 "id," // 0 |
| 1230 "type," // 1 | 1230 "type," // 1 |
| 1231 "status," // 2 | 1231 "status," // 2 |
| 1232 "name_on_card," // 3 | 1232 "name_on_card," // 3 |
| 1233 "last_four," // 4 | 1233 "last_four," // 4 |
| 1234 "exp_month," // 4 | 1234 "exp_month," // 4 |
| 1235 "exp_year) " // 5 | 1235 "exp_year) " // 5 |
| 1236 "VALUES (?,?,?,?,?,?,?)")); | 1236 "VALUES (?,?,?,?,?,?,?)")); |
| 1237 sql::Statement unmasked_insert(db_->GetUniqueStatement( | |
| 1238 "INSERT INTO unmasked_credit_cards(" | |
| 1239 "id," // 0 | |
| 1240 "card_number_encrypted)" // 1 | |
| 1241 "VALUES (?,?)")); | |
| 1242 for (const CreditCard& card : credit_cards) { | 1237 for (const CreditCard& card : credit_cards) { |
| 1243 DCHECK(card.record_type() != CreditCard::LOCAL_CARD); | 1238 DCHECK_EQ(CreditCard::MASKED_SERVER_CARD, card.record_type()); |
| 1244 | 1239 |
| 1245 masked_insert.BindString(0, card.server_id()); | 1240 masked_insert.BindString(0, card.server_id()); |
| 1246 masked_insert.BindString(1, card.type()); | 1241 masked_insert.BindString(1, card.type()); |
| 1247 masked_insert.BindString(2, | 1242 masked_insert.BindString(2, |
| 1248 ServerStatusEnumToString(card.GetServerStatus())); | 1243 ServerStatusEnumToString(card.GetServerStatus())); |
| 1249 masked_insert.BindString16(3, card.GetRawInfo(CREDIT_CARD_NAME)); | 1244 masked_insert.BindString16(3, card.GetRawInfo(CREDIT_CARD_NAME)); |
| 1250 masked_insert.BindString16(4, card.LastFourDigits()); | 1245 masked_insert.BindString16(4, card.LastFourDigits()); |
| 1251 masked_insert.BindString16(5, card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); | 1246 masked_insert.BindString16(5, card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); |
| 1252 masked_insert.BindString16(6, | 1247 masked_insert.BindString16(6, |
| 1253 card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 1248 card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
| 1254 | 1249 |
| 1255 masked_insert.Run(); | 1250 masked_insert.Run(); |
| 1256 masked_insert.Reset(true); | 1251 masked_insert.Reset(true); |
| 1257 | |
| 1258 if (card.record_type() == CreditCard::FULL_SERVER_CARD) { | |
| 1259 // Unmasked cards also get an entry in the unmasked table. Note that the | |
| 1260 // input card could be MASKED but if we have an UNMASKED entry for that | |
| 1261 // card already, it will be preserved. | |
| 1262 unmasked_insert.BindString(0, card.server_id()); | |
| 1263 BindEncryptedCardToColumn(&unmasked_insert, 1, | |
| 1264 card.GetRawInfo(CREDIT_CARD_NUMBER)); | |
| 1265 unmasked_insert.Run(); | |
| 1266 unmasked_insert.Reset(true); | |
| 1267 } | |
| 1268 } | 1252 } |
| 1269 } | 1253 } |
| 1270 | 1254 |
| 1271 bool AutofillTable::UnmaskServerCreditCard(const std::string& id, | 1255 bool AutofillTable::UnmaskServerCreditCard(const std::string& id, |
| 1272 const base::string16& full_number) { | 1256 const base::string16& full_number) { |
| 1273 // Make sure there aren't duplicates for this card. | 1257 // Make sure there aren't duplicates for this card. |
| 1274 MaskServerCreditCard(id); | 1258 MaskServerCreditCard(id); |
| 1275 sql::Statement s(db_->GetUniqueStatement( | 1259 sql::Statement s(db_->GetUniqueStatement( |
| 1276 "INSERT INTO unmasked_credit_cards(id, card_number_encrypted," | 1260 "INSERT INTO unmasked_credit_cards(id, card_number_encrypted," |
| 1277 " use_count, use_date) " | 1261 " use_count, use_date) " |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1983 bool AutofillTable::MigrateToVersion63AddServerRecipientName() { | 1967 bool AutofillTable::MigrateToVersion63AddServerRecipientName() { |
| 1984 if (!db_->DoesColumnExist("server_addresses", "recipient_name") && | 1968 if (!db_->DoesColumnExist("server_addresses", "recipient_name") && |
| 1985 !db_->Execute("ALTER TABLE server_addresses ADD COLUMN " | 1969 !db_->Execute("ALTER TABLE server_addresses ADD COLUMN " |
| 1986 "recipient_name VARCHAR")) { | 1970 "recipient_name VARCHAR")) { |
| 1987 return false; | 1971 return false; |
| 1988 } | 1972 } |
| 1989 return true; | 1973 return true; |
| 1990 } | 1974 } |
| 1991 | 1975 |
| 1992 } // namespace autofill | 1976 } // namespace autofill |
| OLD | NEW |