Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(884)

Side by Side Diff: components/autofill/core/browser/webdata/autofill_table.cc

Issue 2948943003: Revert "Experiment to add bank name in autofill ui." (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 credit_card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, 186 credit_card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR,
187 s.ColumnString16(index++)); 187 s.ColumnString16(index++));
188 credit_card->SetRawInfo(CREDIT_CARD_NUMBER, 188 credit_card->SetRawInfo(CREDIT_CARD_NUMBER,
189 UnencryptedCardFromColumn(s, index++, encryptor)); 189 UnencryptedCardFromColumn(s, index++, encryptor));
190 credit_card->set_use_count(s.ColumnInt64(index++)); 190 credit_card->set_use_count(s.ColumnInt64(index++));
191 credit_card->set_use_date(base::Time::FromTimeT(s.ColumnInt64(index++))); 191 credit_card->set_use_date(base::Time::FromTimeT(s.ColumnInt64(index++)));
192 credit_card->set_modification_date( 192 credit_card->set_modification_date(
193 base::Time::FromTimeT(s.ColumnInt64(index++))); 193 base::Time::FromTimeT(s.ColumnInt64(index++)));
194 credit_card->set_origin(s.ColumnString(index++)); 194 credit_card->set_origin(s.ColumnString(index++));
195 credit_card->set_billing_address_id(s.ColumnString(index++)); 195 credit_card->set_billing_address_id(s.ColumnString(index++));
196 credit_card->set_bank_name(s.ColumnString(index++));
197 196
198 return credit_card; 197 return credit_card;
199 } 198 }
200 199
201 bool AddAutofillProfileNamesToProfile(sql::Connection* db, 200 bool AddAutofillProfileNamesToProfile(sql::Connection* db,
202 AutofillProfile* profile) { 201 AutofillProfile* profile) {
203 // TODO(estade): update schema so that multiple names are not associated per 202 // TODO(estade): update schema so that multiple names are not associated per
204 // unique profile guid. Please refer https://crbug.com/497934. 203 // unique profile guid. Please refer https://crbug.com/497934.
205 sql::Statement s(db->GetUniqueStatement( 204 sql::Statement s(db->GetUniqueStatement(
206 "SELECT guid, first_name, middle_name, last_name, full_name " 205 "SELECT guid, first_name, middle_name, last_name, full_name "
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 return MigrateToVersion67AddMaskedCardBillingAddress(); 465 return MigrateToVersion67AddMaskedCardBillingAddress();
467 case 70: 466 case 70:
468 *update_compatible_version = false; 467 *update_compatible_version = false;
469 return MigrateToVersion70AddSyncMetadata(); 468 return MigrateToVersion70AddSyncMetadata();
470 case 71: 469 case 71:
471 *update_compatible_version = true; 470 *update_compatible_version = true;
472 return MigrateToVersion71AddHasConvertedAndBillingAddressIdMetadata(); 471 return MigrateToVersion71AddHasConvertedAndBillingAddressIdMetadata();
473 case 72: 472 case 72:
474 *update_compatible_version = true; 473 *update_compatible_version = true;
475 return MigrateToVersion72RenameCardTypeToIssuerNetwork(); 474 return MigrateToVersion72RenameCardTypeToIssuerNetwork();
476 case 73:
477 *update_compatible_version = false;
478 return MigrateToVersion73AddMaskedCardBankName();
479 } 475 }
480 return true; 476 return true;
481 } 477 }
482 478
483 bool AutofillTable::AddFormFieldValues( 479 bool AutofillTable::AddFormFieldValues(
484 const std::vector<FormFieldData>& elements, 480 const std::vector<FormFieldData>& elements,
485 std::vector<AutofillChange>* changes) { 481 std::vector<AutofillChange>* changes) {
486 return AddFormFieldValuesTime(elements, changes, AutofillClock::Now()); 482 return AddFormFieldValuesTime(elements, changes, AutofillClock::Now());
487 } 483 }
488 484
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 "card_number_encrypted, " // 0 1212 "card_number_encrypted, " // 0
1217 "last_four," // 1 1213 "last_four," // 1
1218 "masked.id," // 2 1214 "masked.id," // 2
1219 "metadata.use_count," // 3 1215 "metadata.use_count," // 3
1220 "metadata.use_date," // 4 1216 "metadata.use_date," // 4
1221 "network," // 5 1217 "network," // 5
1222 "status," // 6 1218 "status," // 6
1223 "name_on_card," // 7 1219 "name_on_card," // 7
1224 "exp_month," // 8 1220 "exp_month," // 8
1225 "exp_year," // 9 1221 "exp_year," // 9
1226 "metadata.billing_address_id," // 10 1222 "metadata.billing_address_id " // 10
1227 "bank_name " // 11
1228 "FROM masked_credit_cards masked " 1223 "FROM masked_credit_cards masked "
1229 "LEFT OUTER JOIN unmasked_credit_cards USING (id) " 1224 "LEFT OUTER JOIN unmasked_credit_cards USING (id) "
1230 "LEFT OUTER JOIN server_card_metadata metadata USING (id)")); 1225 "LEFT OUTER JOIN server_card_metadata metadata USING (id)"));
1231 while (s.Step()) { 1226 while (s.Step()) {
1232 int index = 0; 1227 int index = 0;
1233 1228
1234 // If the card_number_encrypted field is nonempty, we can assume this card 1229 // If the card_number_encrypted field is nonempty, we can assume this card
1235 // is a full card, otherwise it's masked. 1230 // is a full card, otherwise it's masked.
1236 base::string16 full_card_number = 1231 base::string16 full_card_number =
1237 UnencryptedCardFromColumn(s, index++, *autofill_table_encryptor_); 1232 UnencryptedCardFromColumn(s, index++, *autofill_table_encryptor_);
(...skipping 21 matching lines...) Expand all
1259 card->SetNetworkForMaskedCard(card_network.c_str()); 1254 card->SetNetworkForMaskedCard(card_network.c_str());
1260 } else { 1255 } else {
1261 DCHECK_EQ(CreditCard::GetCardNetwork(full_card_number), card_network); 1256 DCHECK_EQ(CreditCard::GetCardNetwork(full_card_number), card_network);
1262 } 1257 }
1263 1258
1264 card->SetServerStatus(ServerStatusStringToEnum(s.ColumnString(index++))); 1259 card->SetServerStatus(ServerStatusStringToEnum(s.ColumnString(index++)));
1265 card->SetRawInfo(CREDIT_CARD_NAME_FULL, s.ColumnString16(index++)); 1260 card->SetRawInfo(CREDIT_CARD_NAME_FULL, s.ColumnString16(index++));
1266 card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++)); 1261 card->SetRawInfo(CREDIT_CARD_EXP_MONTH, s.ColumnString16(index++));
1267 card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(index++)); 1262 card->SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, s.ColumnString16(index++));
1268 card->set_billing_address_id(s.ColumnString(index++)); 1263 card->set_billing_address_id(s.ColumnString(index++));
1269 card->set_bank_name(s.ColumnString(index++));
1270 credit_cards->push_back(std::move(card)); 1264 credit_cards->push_back(std::move(card));
1271 } 1265 }
1272 return s.Succeeded(); 1266 return s.Succeeded();
1273 } 1267 }
1274 1268
1275 void AutofillTable::AddMaskedCreditCards( 1269 void AutofillTable::AddMaskedCreditCards(
1276 const std::vector<CreditCard>& credit_cards) { 1270 const std::vector<CreditCard>& credit_cards) {
1277 DCHECK_GT(db_->transaction_nesting(), 0); 1271 DCHECK_GT(db_->transaction_nesting(), 0);
1278 sql::Statement masked_insert( 1272 sql::Statement masked_insert(
1279 db_->GetUniqueStatement("INSERT INTO masked_credit_cards(" 1273 db_->GetUniqueStatement("INSERT INTO masked_credit_cards("
1280 "id," // 0 1274 "id," // 0
1281 "network," // 1 1275 "network," // 1
1282 "status," // 2 1276 "status," // 2
1283 "name_on_card," // 3 1277 "name_on_card," // 3
1284 "last_four," // 4 1278 "last_four," // 4
1285 "exp_month," // 5 1279 "exp_month," // 5
1286 "exp_year," // 6 1280 "exp_year)" // 6
1287 "bank_name)" // 7 1281 "VALUES (?,?,?,?,?,?,?)"));
1288 "VALUES (?,?,?,?,?,?,?,?)"));
1289 for (const CreditCard& card : credit_cards) { 1282 for (const CreditCard& card : credit_cards) {
1290 DCHECK_EQ(CreditCard::MASKED_SERVER_CARD, card.record_type()); 1283 DCHECK_EQ(CreditCard::MASKED_SERVER_CARD, card.record_type());
1291 masked_insert.BindString(0, card.server_id()); 1284 masked_insert.BindString(0, card.server_id());
1292 masked_insert.BindString(1, card.network()); 1285 masked_insert.BindString(1, card.network());
1293 masked_insert.BindString(2, 1286 masked_insert.BindString(2,
1294 ServerStatusEnumToString(card.GetServerStatus())); 1287 ServerStatusEnumToString(card.GetServerStatus()));
1295 masked_insert.BindString16(3, card.GetRawInfo(CREDIT_CARD_NAME_FULL)); 1288 masked_insert.BindString16(3, card.GetRawInfo(CREDIT_CARD_NAME_FULL));
1296 masked_insert.BindString16(4, card.LastFourDigits()); 1289 masked_insert.BindString16(4, card.LastFourDigits());
1297 masked_insert.BindString16(5, card.GetRawInfo(CREDIT_CARD_EXP_MONTH)); 1290 masked_insert.BindString16(5, card.GetRawInfo(CREDIT_CARD_EXP_MONTH));
1298 masked_insert.BindString16(6, 1291 masked_insert.BindString16(6,
1299 card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); 1292 card.GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
1300 masked_insert.BindString(7, card.bank_name()); 1293
1301 masked_insert.Run(); 1294 masked_insert.Run();
1302 masked_insert.Reset(true); 1295 masked_insert.Reset(true);
1303 1296
1304 // Save the use count and use date of the card. 1297 // Save the use count and use date of the card.
1305 UpdateServerCardMetadata(card); 1298 UpdateServerCardMetadata(card);
1306 } 1299 }
1307 } 1300 }
1308 1301
1309 void AutofillTable::SetServerCreditCards( 1302 void AutofillTable::SetServerCreditCards(
1310 const std::vector<CreditCard>& credit_cards) { 1303 const std::vector<CreditCard>& credit_cards) {
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 1949
1957 bool AutofillTable::InitMaskedCreditCardsTable() { 1950 bool AutofillTable::InitMaskedCreditCardsTable() {
1958 if (!db_->DoesTableExist("masked_credit_cards")) { 1951 if (!db_->DoesTableExist("masked_credit_cards")) {
1959 if (!db_->Execute("CREATE TABLE masked_credit_cards (" 1952 if (!db_->Execute("CREATE TABLE masked_credit_cards ("
1960 "id VARCHAR," 1953 "id VARCHAR,"
1961 "status VARCHAR," 1954 "status VARCHAR,"
1962 "name_on_card VARCHAR," 1955 "name_on_card VARCHAR,"
1963 "network VARCHAR," 1956 "network VARCHAR,"
1964 "last_four VARCHAR," 1957 "last_four VARCHAR,"
1965 "exp_month INTEGER DEFAULT 0," 1958 "exp_month INTEGER DEFAULT 0,"
1966 "exp_year INTEGER DEFAULT 0, " 1959 "exp_year INTEGER DEFAULT 0)")) {
1967 "bank_name VARCHAR)")) {
1968 NOTREACHED(); 1960 NOTREACHED();
1969 return false; 1961 return false;
1970 } 1962 }
1971 } 1963 }
1972 return true; 1964 return true;
1973 } 1965 }
1974 1966
1975 bool AutofillTable::InitUnmaskedCreditCardsTable() { 1967 bool AutofillTable::InitUnmaskedCreditCardsTable() {
1976 if (!db_->DoesTableExist("unmasked_credit_cards")) { 1968 if (!db_->DoesTableExist("unmasked_credit_cards")) {
1977 if (!db_->Execute("CREATE TABLE unmasked_credit_cards (" 1969 if (!db_->Execute("CREATE TABLE unmasked_credit_cards ("
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
2600 ") SELECT " 2592 ") SELECT "
2601 "id, status, name_on_card, type, last_four, exp_month, exp_year" 2593 "id, status, name_on_card, type, last_four, exp_month, exp_year"
2602 " FROM masked_credit_cards") && 2594 " FROM masked_credit_cards") &&
2603 db_->Execute("DROP TABLE masked_credit_cards") && 2595 db_->Execute("DROP TABLE masked_credit_cards") &&
2604 db_->Execute( 2596 db_->Execute(
2605 "ALTER TABLE masked_credit_cards_temp " 2597 "ALTER TABLE masked_credit_cards_temp "
2606 "RENAME TO masked_credit_cards") && 2598 "RENAME TO masked_credit_cards") &&
2607 transaction.Commit(); 2599 transaction.Commit();
2608 } 2600 }
2609 2601
2610 bool AutofillTable::MigrateToVersion73AddMaskedCardBankName() {
2611 sql::Transaction transaction(db_);
2612 if (!transaction.Begin())
2613 return false;
2614
2615 // Add the new bank_name column to the masked_credit_cards table.
2616 if (!db_->DoesColumnExist("masked_credit_cards", "bank_name") &&
2617 !db_->Execute("ALTER TABLE masked_credit_cards ADD COLUMN "
2618 "bank_name VARCHAR")) {
2619 return false;
2620 }
2621
2622 return transaction.Commit();
2623 }
2624
2625 } // namespace autofill 2602 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698