| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 static_cast<int>(encrypted_data.length())); | 133 static_cast<int>(encrypted_data.length())); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void BindCreditCardToStatement(const CreditCard& credit_card, | 136 void BindCreditCardToStatement(const CreditCard& credit_card, |
| 137 const Time& modification_date, | 137 const Time& modification_date, |
| 138 sql::Statement* s) { | 138 sql::Statement* s) { |
| 139 DCHECK(base::IsValidGUID(credit_card.guid())); | 139 DCHECK(base::IsValidGUID(credit_card.guid())); |
| 140 int index = 0; | 140 int index = 0; |
| 141 s->BindString(index++, credit_card.guid()); | 141 s->BindString(index++, credit_card.guid()); |
| 142 | 142 |
| 143 s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_NAME)); | 143 s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_NAME_FULL)); |
| 144 s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_EXP_MONTH)); | 144 s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_EXP_MONTH)); |
| 145 s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 145 s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
| 146 BindEncryptedCardToColumn(s, index++, | 146 BindEncryptedCardToColumn(s, index++, |
| 147 credit_card.GetRawInfo(CREDIT_CARD_NUMBER)); | 147 credit_card.GetRawInfo(CREDIT_CARD_NUMBER)); |
| 148 | 148 |
| 149 s->BindInt64(index++, credit_card.use_count()); | 149 s->BindInt64(index++, credit_card.use_count()); |
| 150 s->BindInt64(index++, credit_card.use_date().ToTimeT()); | 150 s->BindInt64(index++, credit_card.use_date().ToTimeT()); |
| 151 s->BindInt64(index++, modification_date.ToTimeT()); | 151 s->BindInt64(index++, modification_date.ToTimeT()); |
| 152 s->BindString(index++, credit_card.origin()); | 152 s->BindString(index++, credit_card.origin()); |
| 153 } | 153 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 166 return credit_card_number; | 166 return credit_card_number; |
| 167 } | 167 } |
| 168 | 168 |
| 169 scoped_ptr<CreditCard> CreditCardFromStatement(const sql::Statement& s) { | 169 scoped_ptr<CreditCard> CreditCardFromStatement(const sql::Statement& s) { |
| 170 scoped_ptr<CreditCard> credit_card(new CreditCard); | 170 scoped_ptr<CreditCard> credit_card(new CreditCard); |
| 171 | 171 |
| 172 int index = 0; | 172 int index = 0; |
| 173 credit_card->set_guid(s.ColumnString(index++)); | 173 credit_card->set_guid(s.ColumnString(index++)); |
| 174 DCHECK(base::IsValidGUID(credit_card->guid())); | 174 DCHECK(base::IsValidGUID(credit_card->guid())); |
| 175 | 175 |
| 176 credit_card->SetRawInfo(CREDIT_CARD_NAME, s.ColumnString16(index++)); | 176 credit_card->SetRawInfo(CREDIT_CARD_NAME_FULL, s.ColumnString16(index++)); |
| 177 credit_card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++)); | 177 credit_card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++)); |
| 178 credit_card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, | 178 credit_card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, |
| 179 s.ColumnString16(index++)); | 179 s.ColumnString16(index++)); |
| 180 credit_card->SetRawInfo(CREDIT_CARD_NUMBER, | 180 credit_card->SetRawInfo(CREDIT_CARD_NUMBER, |
| 181 UnencryptedCardFromColumn(s, index++)); | 181 UnencryptedCardFromColumn(s, index++)); |
| 182 credit_card->set_use_count(s.ColumnInt64(index++)); | 182 credit_card->set_use_count(s.ColumnInt64(index++)); |
| 183 credit_card->set_use_date(Time::FromTimeT(s.ColumnInt64(index++))); | 183 credit_card->set_use_date(Time::FromTimeT(s.ColumnInt64(index++))); |
| 184 credit_card->set_modification_date(Time::FromTimeT(s.ColumnInt64(index++))); | 184 credit_card->set_modification_date(Time::FromTimeT(s.ColumnInt64(index++))); |
| 185 credit_card->set_origin(s.ColumnString(index++)); | 185 credit_card->set_origin(s.ColumnString(index++)); |
| 186 | 186 |
| (...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 std::string card_type = s.ColumnString(index++); | 1221 std::string card_type = s.ColumnString(index++); |
| 1222 if (record_type == CreditCard::MASKED_SERVER_CARD) { | 1222 if (record_type == CreditCard::MASKED_SERVER_CARD) { |
| 1223 // The type must be set after setting the number to override the | 1223 // The type must be set after setting the number to override the |
| 1224 // autodectected type. | 1224 // autodectected type. |
| 1225 card->SetTypeForMaskedCard(card_type.c_str()); | 1225 card->SetTypeForMaskedCard(card_type.c_str()); |
| 1226 } else { | 1226 } else { |
| 1227 DCHECK_EQ(CreditCard::GetCreditCardType(full_card_number), card_type); | 1227 DCHECK_EQ(CreditCard::GetCreditCardType(full_card_number), card_type); |
| 1228 } | 1228 } |
| 1229 | 1229 |
| 1230 card->SetServerStatus(ServerStatusStringToEnum(s.ColumnString(index++))); | 1230 card->SetServerStatus(ServerStatusStringToEnum(s.ColumnString(index++))); |
| 1231 card->SetRawInfo(CREDIT_CARD_NAME, s.ColumnString16(index++)); | 1231 card->SetRawInfo(CREDIT_CARD_NAME_FULL, s.ColumnString16(index++)); |
| 1232 card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++)); | 1232 card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++)); |
| 1233 card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(index++)); | 1233 card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(index++)); |
| 1234 credit_cards->push_back(card); | 1234 credit_cards->push_back(card); |
| 1235 } | 1235 } |
| 1236 | 1236 |
| 1237 return s.Succeeded(); | 1237 return s.Succeeded(); |
| 1238 } | 1238 } |
| 1239 | 1239 |
| 1240 void AutofillTable::SetServerCreditCards( | 1240 void AutofillTable::SetServerCreditCards( |
| 1241 const std::vector<CreditCard>& credit_cards) { | 1241 const std::vector<CreditCard>& credit_cards) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1258 "exp_month," // 4 | 1258 "exp_month," // 4 |
| 1259 "exp_year) " // 5 | 1259 "exp_year) " // 5 |
| 1260 "VALUES (?,?,?,?,?,?,?)")); | 1260 "VALUES (?,?,?,?,?,?,?)")); |
| 1261 for (const CreditCard& card : credit_cards) { | 1261 for (const CreditCard& card : credit_cards) { |
| 1262 DCHECK_EQ(CreditCard::MASKED_SERVER_CARD, card.record_type()); | 1262 DCHECK_EQ(CreditCard::MASKED_SERVER_CARD, card.record_type()); |
| 1263 | 1263 |
| 1264 masked_insert.BindString(0, card.server_id()); | 1264 masked_insert.BindString(0, card.server_id()); |
| 1265 masked_insert.BindString(1, card.type()); | 1265 masked_insert.BindString(1, card.type()); |
| 1266 masked_insert.BindString(2, | 1266 masked_insert.BindString(2, |
| 1267 ServerStatusEnumToString(card.GetServerStatus())); | 1267 ServerStatusEnumToString(card.GetServerStatus())); |
| 1268 masked_insert.BindString16(3, card.GetRawInfo(CREDIT_CARD_NAME)); | 1268 masked_insert.BindString16(3, card.GetRawInfo(CREDIT_CARD_NAME_FULL)); |
| 1269 masked_insert.BindString16(4, card.LastFourDigits()); | 1269 masked_insert.BindString16(4, card.LastFourDigits()); |
| 1270 masked_insert.BindString16(5, card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); | 1270 masked_insert.BindString16(5, card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); |
| 1271 masked_insert.BindString16(6, | 1271 masked_insert.BindString16(6, |
| 1272 card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 1272 card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
| 1273 | 1273 |
| 1274 masked_insert.Run(); | 1274 masked_insert.Run(); |
| 1275 masked_insert.Reset(true); | 1275 masked_insert.Reset(true); |
| 1276 | 1276 |
| 1277 // Save the use count and use date of the card. | 1277 // Save the use count and use date of the card. |
| 1278 UpdateServerCardUsageStats(card); | 1278 UpdateServerCardUsageStats(card); |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 insert.BindString16(index++, profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); | 2253 insert.BindString16(index++, profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); |
| 2254 insert.BindString(index++, profile.language_code()); | 2254 insert.BindString(index++, profile.language_code()); |
| 2255 insert.Run(); | 2255 insert.Run(); |
| 2256 insert.Reset(true); | 2256 insert.Reset(true); |
| 2257 } | 2257 } |
| 2258 | 2258 |
| 2259 return transaction.Commit(); | 2259 return transaction.Commit(); |
| 2260 } | 2260 } |
| 2261 | 2261 |
| 2262 } // namespace autofill | 2262 } // namespace autofill |
| OLD | NEW |