| 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 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_FULL_WALLET_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_FULL_WALLET_H_ |
| 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_FULL_WALLET_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_FULL_WALLET_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 17 #include "components/autofill/content/browser/wallet/wallet_address.h" | 17 #include "components/autofill/content/browser/wallet/wallet_address.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class DictionaryValue; | 20 class DictionaryValue; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace autofill { | 23 namespace autofill { |
| 24 | 24 |
| 25 class AutofillType; | 25 class AutofillType; |
| 26 | 26 |
| 27 namespace wallet { | 27 namespace wallet { |
| 28 | 28 |
| 29 class FullWalletTest; | 29 class FullWalletTest; |
| 30 | 30 |
| 31 // FullWallet contains all the information a merchant requires from a user for | 31 // FullWallet contains all the information a merchant requires from a user for |
| 32 // that user to make a purchase. This includes: | 32 // that user to make a purchase. This includes: |
| 33 // - billing information | 33 // - billing information |
| 34 // - shipping information | 34 // - shipping information |
| 35 // - a proxy card for the backing card selected from a user's wallet items | 35 // - a proxy card for the backing card selected from a user's wallet items |
| 36 class FullWallet { | 36 class FullWallet { |
| 37 public: | 37 public: |
| 38 ~FullWallet(); | 38 ~FullWallet(); |
| 39 | 39 |
| 40 // Returns a wallet built from the provided clear-text data. | 40 // Returns a wallet built from the provided clear-text data. |
| 41 // Data is not validated; |pan|, |cvn| and |billing_address| must be set. | 41 // Data is not validated; |pan|, |cvn| and |billing_address| must be set. |
| 42 static scoped_ptr<FullWallet> | 42 static std::unique_ptr<FullWallet> CreateFullWalletFromClearText( |
| 43 CreateFullWalletFromClearText(int expiration_month, | 43 int expiration_month, |
| 44 int expiration_year, | 44 int expiration_year, |
| 45 const std::string& pan, | 45 const std::string& pan, |
| 46 const std::string& cvn, | 46 const std::string& cvn, |
| 47 scoped_ptr<Address> billing_address, | 47 std::unique_ptr<Address> billing_address, |
| 48 scoped_ptr<Address> shipping_address); | 48 std::unique_ptr<Address> shipping_address); |
| 49 | 49 |
| 50 // Returns corresponding data for |type|. | 50 // Returns corresponding data for |type|. |
| 51 base::string16 GetInfo(const std::string& app_locale, | 51 base::string16 GetInfo(const std::string& app_locale, |
| 52 const AutofillType& type); | 52 const AutofillType& type); |
| 53 | 53 |
| 54 // The type of the card that this FullWallet contains and the last four digits | 54 // The type of the card that this FullWallet contains and the last four digits |
| 55 // like this "Visa - 4111". | 55 // like this "Visa - 4111". |
| 56 base::string16 TypeAndLastFourDigits(); | 56 base::string16 TypeAndLastFourDigits(); |
| 57 | 57 |
| 58 // Decrypts and returns the primary account number (PAN) using the generated | 58 // Decrypts and returns the primary account number (PAN) using the generated |
| 59 // one time pad, |one_time_pad_|. | 59 // one time pad, |one_time_pad_|. |
| 60 const std::string& GetPan(); | 60 const std::string& GetPan(); |
| 61 | 61 |
| 62 bool operator==(const FullWallet& other) const; | 62 bool operator==(const FullWallet& other) const; |
| 63 bool operator!=(const FullWallet& other) const; | 63 bool operator!=(const FullWallet& other) const; |
| 64 | 64 |
| 65 const Address* billing_address() const { return billing_address_.get(); } | 65 const Address* billing_address() const { return billing_address_.get(); } |
| 66 const Address* shipping_address() const { return shipping_address_.get(); } | 66 const Address* shipping_address() const { return shipping_address_.get(); } |
| 67 | 67 |
| 68 int expiration_month() const { return expiration_month_; } | 68 int expiration_month() const { return expiration_month_; } |
| 69 int expiration_year() const { return expiration_year_; } | 69 int expiration_year() const { return expiration_year_; } |
| 70 | 70 |
| 71 void set_one_time_pad(const std::vector<uint8_t>& one_time_pad) { | 71 void set_one_time_pad(const std::vector<uint8_t>& one_time_pad) { |
| 72 one_time_pad_ = one_time_pad; | 72 one_time_pad_ = one_time_pad; |
| 73 } | 73 } |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 friend class FullWalletTest; | 76 friend class FullWalletTest; |
| 77 friend scoped_ptr<FullWallet> GetTestFullWallet(); | 77 friend std::unique_ptr<FullWallet> GetTestFullWallet(); |
| 78 friend scoped_ptr<FullWallet> GetTestFullWalletInstrumentOnly(); | 78 friend std::unique_ptr<FullWallet> GetTestFullWalletInstrumentOnly(); |
| 79 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, CreateFullWallet); | 79 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, CreateFullWallet); |
| 80 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, RestLengthCorrectDecryptionTest); | 80 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, RestLengthCorrectDecryptionTest); |
| 81 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, RestLengthUnderDecryptionTest); | 81 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, RestLengthUnderDecryptionTest); |
| 82 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, GetCreditCardInfo); | 82 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, GetCreditCardInfo); |
| 83 | 83 |
| 84 FullWallet(int expiration_month, | 84 FullWallet(int expiration_month, |
| 85 int expiration_year, | 85 int expiration_year, |
| 86 const std::string& iin, | 86 const std::string& iin, |
| 87 const std::string& encrypted_rest, | 87 const std::string& encrypted_rest, |
| 88 scoped_ptr<Address> billing_address, | 88 std::unique_ptr<Address> billing_address, |
| 89 scoped_ptr<Address> shipping_address); | 89 std::unique_ptr<Address> shipping_address); |
| 90 | 90 |
| 91 // Decrypts both |pan_| and |cvn_|. | 91 // Decrypts both |pan_| and |cvn_|. |
| 92 void DecryptCardInfo(); | 92 void DecryptCardInfo(); |
| 93 | 93 |
| 94 // Decrypts and returns the card verification number (CVN) using the generated | 94 // Decrypts and returns the card verification number (CVN) using the generated |
| 95 // one time pad, |one_time_pad_|. | 95 // one time pad, |one_time_pad_|. |
| 96 const std::string& GetCvn(); | 96 const std::string& GetCvn(); |
| 97 | 97 |
| 98 // The expiration month of the proxy card. It should be 1-12. | 98 // The expiration month of the proxy card. It should be 1-12. |
| 99 int expiration_month_; | 99 int expiration_month_; |
| 100 | 100 |
| 101 // The expiration year of the proxy card. It should be a 4-digit year. | 101 // The expiration year of the proxy card. It should be a 4-digit year. |
| 102 int expiration_year_; | 102 int expiration_year_; |
| 103 | 103 |
| 104 // Primary account number (PAN). Its format is \d{16}. | 104 // Primary account number (PAN). Its format is \d{16}. |
| 105 std::string pan_; | 105 std::string pan_; |
| 106 | 106 |
| 107 // Card verification number (CVN). Its format is \d{3}. | 107 // Card verification number (CVN). Its format is \d{3}. |
| 108 std::string cvn_; | 108 std::string cvn_; |
| 109 | 109 |
| 110 // Issuer identification number (IIN). Its format is \d{6}. | 110 // Issuer identification number (IIN). Its format is \d{6}. |
| 111 std::string iin_; | 111 std::string iin_; |
| 112 | 112 |
| 113 // Encrypted concatentation of CVN and PAN without IIN | 113 // Encrypted concatentation of CVN and PAN without IIN |
| 114 std::string encrypted_rest_; | 114 std::string encrypted_rest_; |
| 115 | 115 |
| 116 // The billing address of the backing instrument. | 116 // The billing address of the backing instrument. |
| 117 scoped_ptr<Address> billing_address_; | 117 std::unique_ptr<Address> billing_address_; |
| 118 | 118 |
| 119 // The shipping address for the transaction. | 119 // The shipping address for the transaction. |
| 120 scoped_ptr<Address> shipping_address_; | 120 std::unique_ptr<Address> shipping_address_; |
| 121 | 121 |
| 122 // The one time pad used for FullWallet encryption. | 122 // The one time pad used for FullWallet encryption. |
| 123 std::vector<uint8_t> one_time_pad_; | 123 std::vector<uint8_t> one_time_pad_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(FullWallet); | 125 DISALLOW_COPY_AND_ASSIGN(FullWallet); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 } // namespace wallet | 128 } // namespace wallet |
| 129 } // namespace autofill | 129 } // namespace autofill |
| 130 | 130 |
| 131 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_FULL_WALLET_H_ | 131 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_FULL_WALLET_H_ |
| OLD | NEW |