| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/webdata/web_database.h" | 5 #include "chrome/browser/webdata/web_database.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 #include <limits> | 8 #include <limits> | 
| 9 #include <set> | 9 #include <set> | 
| 10 #include <string> | 10 #include <string> | 
| (...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1560   s->BindString16(3, text); | 1560   s->BindString16(3, text); | 
| 1561   text.clear();  // No unencrypted cc info. | 1561   text.clear();  // No unencrypted cc info. | 
| 1562   s->BindString16(4, text); | 1562   s->BindString16(4, text); | 
| 1563   text = credit_card.GetFieldText(AutoFillType(CREDIT_CARD_EXP_MONTH)); | 1563   text = credit_card.GetFieldText(AutoFillType(CREDIT_CARD_EXP_MONTH)); | 
| 1564   s->BindString16(5, text); | 1564   s->BindString16(5, text); | 
| 1565   text = credit_card.GetFieldText(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 1565   text = credit_card.GetFieldText(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 
| 1566   s->BindString16(6, text); | 1566   s->BindString16(6, text); | 
| 1567   text.clear(); | 1567   text.clear(); | 
| 1568   s->BindString16(7, text); | 1568   s->BindString16(7, text); | 
| 1569   s->BindString16(8, credit_card.billing_address()); | 1569   s->BindString16(8, credit_card.billing_address()); | 
| 1570   s->BindString16(9, credit_card.shipping_address()); | 1570   // We don't store the shipping address anymore. | 
|  | 1571   text.clear(); | 
|  | 1572   s->BindString16(9, text); | 
| 1571   text = credit_card.GetFieldText(AutoFillType(CREDIT_CARD_NUMBER)); | 1573   text = credit_card.GetFieldText(AutoFillType(CREDIT_CARD_NUMBER)); | 
| 1572   std::string encrypted_data; | 1574   std::string encrypted_data; | 
| 1573   Encryptor::EncryptString16(text, &encrypted_data); | 1575   Encryptor::EncryptString16(text, &encrypted_data); | 
| 1574   s->BindBlob(10, encrypted_data.data(), | 1576   s->BindBlob(10, encrypted_data.data(), | 
| 1575               static_cast<int>(encrypted_data.length())); | 1577               static_cast<int>(encrypted_data.length())); | 
| 1576   text = credit_card.GetFieldText(AutoFillType(CREDIT_CARD_VERIFICATION_CODE)); | 1578   // We don't store the CVV anymore. | 
| 1577   Encryptor::EncryptString16(text, &encrypted_data); | 1579   text.clear(); | 
| 1578   s->BindBlob(11, encrypted_data.data(), | 1580   s->BindBlob(11, text.data(), static_cast<int>(text.length())); | 
| 1579               static_cast<int>(encrypted_data.length())); |  | 
| 1580 } | 1581 } | 
| 1581 | 1582 | 
| 1582 bool WebDatabase::AddCreditCard(const CreditCard& credit_card) { | 1583 bool WebDatabase::AddCreditCard(const CreditCard& credit_card) { | 
| 1583   sql::Statement s(db_.GetUniqueStatement( | 1584   sql::Statement s(db_.GetUniqueStatement( | 
| 1584       "INSERT INTO credit_cards" | 1585       "INSERT INTO credit_cards" | 
| 1585       "(label, unique_id, name_on_card, type, card_number," | 1586       "(label, unique_id, name_on_card, type, card_number," | 
| 1586       " expiration_month, expiration_year, verification_code, billing_address," | 1587       " expiration_month, expiration_year, verification_code, billing_address," | 
| 1587       " shipping_address, card_number_encrypted, verification_code_encrypted)" | 1588       " shipping_address, card_number_encrypted, verification_code_encrypted)" | 
| 1588       "VALUES (?,?,?,?,?,?,?,?,?,?,?,?)")); | 1589       "VALUES (?,?,?,?,?,?,?,?,?,?,?,?)")); | 
| 1589   if (!s) { | 1590   if (!s) { | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1621       Encryptor::DecryptString16(encrypted_cc, &credit_card_number); | 1622       Encryptor::DecryptString16(encrypted_cc, &credit_card_number); | 
| 1622     } | 1623     } | 
| 1623   } | 1624   } | 
| 1624   credit_card->SetInfo(AutoFillType(CREDIT_CARD_NUMBER), credit_card_number); | 1625   credit_card->SetInfo(AutoFillType(CREDIT_CARD_NUMBER), credit_card_number); | 
| 1625   credit_card->SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), | 1626   credit_card->SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), | 
| 1626                        s.ColumnString16(5)); | 1627                        s.ColumnString16(5)); | 
| 1627   credit_card->SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), | 1628   credit_card->SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), | 
| 1628                        s.ColumnString16(6)); | 1629                        s.ColumnString16(6)); | 
| 1629 | 1630 | 
| 1630   string16 credit_card_verification_code = s.ColumnString16(7); | 1631   string16 credit_card_verification_code = s.ColumnString16(7); | 
| 1631   // It could be non-empty prior to version 23. After that it encrypted in | 1632   // We don't store the CVV anymore. | 
| 1632   // the column 11. |  | 
| 1633   if (credit_card_verification_code.empty()) { |  | 
| 1634     int encrypted_cc_len = s.ColumnByteLength(11); |  | 
| 1635     std::string encrypted_cc; |  | 
| 1636     if (encrypted_cc_len) { |  | 
| 1637       encrypted_cc.resize(encrypted_cc_len); |  | 
| 1638       memcpy(&encrypted_cc[0], s.ColumnBlob(11), encrypted_cc_len); |  | 
| 1639       Encryptor::DecryptString16(encrypted_cc, &credit_card_verification_code); |  | 
| 1640     } |  | 
| 1641   } |  | 
| 1642   credit_card->SetInfo(AutoFillType(CREDIT_CARD_VERIFICATION_CODE), |  | 
| 1643                        credit_card_verification_code); |  | 
| 1644   credit_card->set_billing_address(s.ColumnString16(8)); | 1633   credit_card->set_billing_address(s.ColumnString16(8)); | 
| 1645   credit_card->set_shipping_address(s.ColumnString16(9)); | 1634   // We don't store the shipping address anymore. | 
| 1646   // Column 10 is processed above. | 1635   // Column 10 is processed above. | 
| 1647   // Column 11 is processed above. | 1636   // Column 11 is processed above. | 
| 1648 | 1637 | 
| 1649   return credit_card; | 1638   return credit_card; | 
| 1650 } | 1639 } | 
| 1651 | 1640 | 
| 1652 bool WebDatabase::GetCreditCardForLabel(const string16& label, | 1641 bool WebDatabase::GetCreditCardForLabel(const string16& label, | 
| 1653                                         CreditCard** credit_card) { | 1642                                         CreditCard** credit_card) { | 
| 1654   DCHECK(credit_card); | 1643   DCHECK(credit_card); | 
| 1655   sql::Statement s(db_.GetUniqueStatement( | 1644   sql::Statement s(db_.GetUniqueStatement( | 
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1889 | 1878 | 
| 1890     // Add successive versions here.  Each should set the version number and | 1879     // Add successive versions here.  Each should set the version number and | 
| 1891     // compatible version number as appropriate, then fall through to the next | 1880     // compatible version number as appropriate, then fall through to the next | 
| 1892     // case. | 1881     // case. | 
| 1893 | 1882 | 
| 1894     case kCurrentVersionNumber: | 1883     case kCurrentVersionNumber: | 
| 1895       // No migration needed. | 1884       // No migration needed. | 
| 1896       return; | 1885       return; | 
| 1897   } | 1886   } | 
| 1898 } | 1887 } | 
| OLD | NEW | 
|---|