| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "components/autofill/content/browser/wallet/required_action.h" | |
| 16 #include "components/autofill/content/browser/wallet/wallet_address.h" | 15 #include "components/autofill/content/browser/wallet/wallet_address.h" |
| 17 | 16 |
| 18 namespace base { | 17 namespace base { |
| 19 class DictionaryValue; | 18 class DictionaryValue; |
| 20 } | 19 } |
| 21 | 20 |
| 22 namespace autofill { | 21 namespace autofill { |
| 23 | 22 |
| 24 class AutofillType; | 23 class AutofillType; |
| 25 | 24 |
| 26 namespace wallet { | 25 namespace wallet { |
| 27 | 26 |
| 28 class FullWalletTest; | 27 class FullWalletTest; |
| 29 | 28 |
| 30 // FullWallet contains all the information a merchant requires from a user for | 29 // FullWallet contains all the information a merchant requires from a user for |
| 31 // that user to make a purchase. This includes: | 30 // that user to make a purchase. This includes: |
| 32 // - billing information | 31 // - billing information |
| 33 // - shipping information | 32 // - shipping information |
| 34 // - a proxy card for the backing card selected from a user's wallet items | 33 // - a proxy card for the backing card selected from a user's wallet items |
| 35 class FullWallet { | 34 class FullWallet { |
| 36 public: | 35 public: |
| 37 ~FullWallet(); | 36 ~FullWallet(); |
| 38 | 37 |
| 39 // Returns an empty scoped_ptr if the input invalid, an empty wallet with | |
| 40 // required actions if there are any, or a valid wallet. | |
| 41 static scoped_ptr<FullWallet> | |
| 42 CreateFullWallet(const base::DictionaryValue& dictionary); | |
| 43 | |
| 44 // Returns a wallet built from the provided clear-text data. | 38 // Returns a wallet built from the provided clear-text data. |
| 45 // Data is not validated; |pan|, |cvn| and |billing_address| must be set. | 39 // Data is not validated; |pan|, |cvn| and |billing_address| must be set. |
| 46 static scoped_ptr<FullWallet> | 40 static scoped_ptr<FullWallet> |
| 47 CreateFullWalletFromClearText(int expiration_month, | 41 CreateFullWalletFromClearText(int expiration_month, |
| 48 int expiration_year, | 42 int expiration_year, |
| 49 const std::string& pan, | 43 const std::string& pan, |
| 50 const std::string& cvn, | 44 const std::string& cvn, |
| 51 scoped_ptr<Address> billing_address, | 45 scoped_ptr<Address> billing_address, |
| 52 scoped_ptr<Address> shipping_address); | 46 scoped_ptr<Address> shipping_address); |
| 53 | 47 |
| 54 // Returns corresponding data for |type|. | 48 // Returns corresponding data for |type|. |
| 55 base::string16 GetInfo(const std::string& app_locale, | 49 base::string16 GetInfo(const std::string& app_locale, |
| 56 const AutofillType& type); | 50 const AutofillType& type); |
| 57 | 51 |
| 58 // Whether or not |action| is in |required_actions_|. | |
| 59 bool HasRequiredAction(RequiredAction action) const; | |
| 60 | |
| 61 // The type of the card that this FullWallet contains and the last four digits | 52 // The type of the card that this FullWallet contains and the last four digits |
| 62 // like this "Visa - 4111". | 53 // like this "Visa - 4111". |
| 63 base::string16 TypeAndLastFourDigits(); | 54 base::string16 TypeAndLastFourDigits(); |
| 64 | 55 |
| 65 // Decrypts and returns the primary account number (PAN) using the generated | 56 // Decrypts and returns the primary account number (PAN) using the generated |
| 66 // one time pad, |one_time_pad_|. | 57 // one time pad, |one_time_pad_|. |
| 67 const std::string& GetPan(); | 58 const std::string& GetPan(); |
| 68 | 59 |
| 69 bool operator==(const FullWallet& other) const; | 60 bool operator==(const FullWallet& other) const; |
| 70 bool operator!=(const FullWallet& other) const; | 61 bool operator!=(const FullWallet& other) const; |
| 71 | 62 |
| 72 // If there are required actions |billing_address_| might contain NULL. | |
| 73 const Address* billing_address() const { return billing_address_.get(); } | 63 const Address* billing_address() const { return billing_address_.get(); } |
| 74 | |
| 75 // If there are required actions or shipping address is not required | |
| 76 // |shipping_address_| might contain NULL. | |
| 77 const Address* shipping_address() const { return shipping_address_.get(); } | 64 const Address* shipping_address() const { return shipping_address_.get(); } |
| 78 | 65 |
| 79 const std::vector<RequiredAction>& required_actions() const { | |
| 80 return required_actions_; | |
| 81 } | |
| 82 int expiration_month() const { return expiration_month_; } | 66 int expiration_month() const { return expiration_month_; } |
| 83 int expiration_year() const { return expiration_year_; } | 67 int expiration_year() const { return expiration_year_; } |
| 84 | 68 |
| 85 void set_one_time_pad(const std::vector<uint8>& one_time_pad) { | 69 void set_one_time_pad(const std::vector<uint8>& one_time_pad) { |
| 86 one_time_pad_ = one_time_pad; | 70 one_time_pad_ = one_time_pad; |
| 87 } | 71 } |
| 88 | 72 |
| 89 private: | 73 private: |
| 90 friend class FullWalletTest; | 74 friend class FullWalletTest; |
| 91 friend scoped_ptr<FullWallet> GetTestFullWalletWithRequiredActions( | 75 friend scoped_ptr<FullWallet> GetTestFullWallet(); |
| 92 const std::vector<RequiredAction>& action); | |
| 93 friend scoped_ptr<FullWallet> GetTestFullWalletInstrumentOnly(); | 76 friend scoped_ptr<FullWallet> GetTestFullWalletInstrumentOnly(); |
| 94 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, CreateFullWallet); | 77 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, CreateFullWallet); |
| 95 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, CreateFullWalletWithRequiredActions); | |
| 96 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, RestLengthCorrectDecryptionTest); | 78 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, RestLengthCorrectDecryptionTest); |
| 97 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, RestLengthUnderDecryptionTest); | 79 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, RestLengthUnderDecryptionTest); |
| 98 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, GetCreditCardInfo); | 80 FRIEND_TEST_ALL_PREFIXES(FullWalletTest, GetCreditCardInfo); |
| 99 | 81 |
| 100 FullWallet(int expiration_month, | 82 FullWallet(int expiration_month, |
| 101 int expiration_year, | 83 int expiration_year, |
| 102 const std::string& iin, | 84 const std::string& iin, |
| 103 const std::string& encrypted_rest, | 85 const std::string& encrypted_rest, |
| 104 scoped_ptr<Address> billing_address, | 86 scoped_ptr<Address> billing_address, |
| 105 scoped_ptr<Address> shipping_address, | 87 scoped_ptr<Address> shipping_address); |
| 106 const std::vector<RequiredAction>& required_actions); | |
| 107 | 88 |
| 108 // Decrypts both |pan_| and |cvn_|. | 89 // Decrypts both |pan_| and |cvn_|. |
| 109 void DecryptCardInfo(); | 90 void DecryptCardInfo(); |
| 110 | 91 |
| 111 // Decrypts and returns the card verification number (CVN) using the generated | 92 // Decrypts and returns the card verification number (CVN) using the generated |
| 112 // one time pad, |one_time_pad_|. | 93 // one time pad, |one_time_pad_|. |
| 113 const std::string& GetCvn(); | 94 const std::string& GetCvn(); |
| 114 | 95 |
| 115 // The expiration month of the proxy card. It should be 1-12. | 96 // The expiration month of the proxy card. It should be 1-12. |
| 116 int expiration_month_; | 97 int expiration_month_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 129 | 110 |
| 130 // Encrypted concatentation of CVN and PAN without IIN | 111 // Encrypted concatentation of CVN and PAN without IIN |
| 131 std::string encrypted_rest_; | 112 std::string encrypted_rest_; |
| 132 | 113 |
| 133 // The billing address of the backing instrument. | 114 // The billing address of the backing instrument. |
| 134 scoped_ptr<Address> billing_address_; | 115 scoped_ptr<Address> billing_address_; |
| 135 | 116 |
| 136 // The shipping address for the transaction. | 117 // The shipping address for the transaction. |
| 137 scoped_ptr<Address> shipping_address_; | 118 scoped_ptr<Address> shipping_address_; |
| 138 | 119 |
| 139 // Actions that must be completed by the user before a FullWallet can be | |
| 140 // issued to them by the Online Wallet service. | |
| 141 std::vector<RequiredAction> required_actions_; | |
| 142 | |
| 143 // The one time pad used for FullWallet encryption. | 120 // The one time pad used for FullWallet encryption. |
| 144 std::vector<uint8> one_time_pad_; | 121 std::vector<uint8> one_time_pad_; |
| 145 | 122 |
| 146 DISALLOW_COPY_AND_ASSIGN(FullWallet); | 123 DISALLOW_COPY_AND_ASSIGN(FullWallet); |
| 147 }; | 124 }; |
| 148 | 125 |
| 149 } // namespace wallet | 126 } // namespace wallet |
| 150 } // namespace autofill | 127 } // namespace autofill |
| 151 | 128 |
| 152 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_FULL_WALLET_H_ | 129 #endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_WALLET_FULL_WALLET_H_ |
| OLD | NEW |