| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_AUTOFILL_WALLET_WALLET_ITEMS_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_WALLET_WALLET_ITEMS_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_WALLET_WALLET_ITEMS_H_ | 6 #define CHROME_BROWSER_AUTOFILL_WALLET_WALLET_ITEMS_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/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "chrome/browser/autofill/wallet/wallet_address.h" | 16 #include "chrome/browser/autofill/wallet/wallet_address.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class DictionaryValue; | 19 class DictionaryValue; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace wallet { | 22 namespace wallet { |
| 23 | 23 |
| 24 class RequiredAction; |
| 24 class WalletItemsTest; | 25 class WalletItemsTest; |
| 25 | 26 |
| 26 // WalletItems primarily serves as a container for the user's instruments and | 27 // WalletItems is a collection of cards and addresses that a user picks from to |
| 27 // address, however, it also provides a transaction id which must be used | 28 // construct a full wallet. However, it also provides a transaction ID which |
| 28 // throughout all API calls being made using this data. Additionally, user | 29 // must be used throughout all API calls being made using this data. |
| 29 // actions may be required before a purchase can be completed using Online | 30 // Additionally, user actions may be required before a purchase can be completed |
| 30 // Wallet and those actions are present in the object as well. | 31 // using Online Wallet and those actions are present in the object as well. |
| 31 class WalletItems { | 32 class WalletItems { |
| 32 public: | 33 public: |
| 33 // Container for all information about a credit card except for it's card | 34 // Container for all information about a credit card except for it's card |
| 34 // verfication number (CVN) and it's complete primary account number (PAN). | 35 // verfication number (CVN) and it's complete primary account number (PAN). |
| 35 class MaskedInstrument { | 36 class MaskedInstrument { |
| 36 public: | 37 public: |
| 37 enum Type { | 38 enum Type { |
| 38 AMEX, | 39 AMEX, |
| 39 DISCOVER, | 40 DISCOVER, |
| 40 MAESTRO, | 41 MAESTRO, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 instruments_.push_back(instrument.release()); | 152 instruments_.push_back(instrument.release()); |
| 152 } | 153 } |
| 153 void AddAddress(scoped_ptr<Address> address) { | 154 void AddAddress(scoped_ptr<Address> address) { |
| 154 DCHECK(address.get()); | 155 DCHECK(address.get()); |
| 155 addresses_.push_back(address.release()); | 156 addresses_.push_back(address.release()); |
| 156 } | 157 } |
| 157 void AddLegalDocument(scoped_ptr<LegalDocument> legal_document) { | 158 void AddLegalDocument(scoped_ptr<LegalDocument> legal_document) { |
| 158 DCHECK(legal_document.get()); | 159 DCHECK(legal_document.get()); |
| 159 legal_documents_.push_back(legal_document.release()); | 160 legal_documents_.push_back(legal_document.release()); |
| 160 } | 161 } |
| 161 const std::vector<std::string>& required_actions() const { | 162 const std::vector<RequiredAction>& required_actions() const { |
| 162 return required_actions_; | 163 return required_actions_; |
| 163 } | 164 } |
| 164 const std::string& google_transaction_id() const { | 165 const std::string& google_transaction_id() const { |
| 165 return google_transaction_id_; | 166 return google_transaction_id_; |
| 166 } | 167 } |
| 167 const std::vector<MaskedInstrument*>& instruments() const { | 168 const std::vector<MaskedInstrument*>& instruments() const { |
| 168 return instruments_.get(); | 169 return instruments_.get(); |
| 169 } | 170 } |
| 170 const std::string& default_instrument_id() const { | 171 const std::string& default_instrument_id() const { |
| 171 return default_instrument_id_; | 172 return default_instrument_id_; |
| 172 } | 173 } |
| 173 const std::vector<Address*>& addresses() const { return addresses_.get(); } | 174 const std::vector<Address*>& addresses() const { return addresses_.get(); } |
| 174 const std::string& default_address_id() const { | 175 const std::string& default_address_id() const { |
| 175 return default_address_id_; | 176 return default_address_id_; |
| 176 } | 177 } |
| 177 const std::vector<LegalDocument*>& legal_documents() const { | 178 const std::vector<LegalDocument*>& legal_documents() const { |
| 178 return legal_documents_.get(); | 179 return legal_documents_.get(); |
| 179 } | 180 } |
| 180 | 181 |
| 181 private: | 182 private: |
| 182 friend class WalletItemsTest; | 183 friend class WalletItemsTest; |
| 183 FRIEND_TEST_ALL_PREFIXES(WalletItemsTest, CreateWalletItems); | 184 FRIEND_TEST_ALL_PREFIXES(WalletItemsTest, CreateWalletItems); |
| 184 FRIEND_TEST_ALL_PREFIXES(WalletItemsTest, | 185 FRIEND_TEST_ALL_PREFIXES(WalletItemsTest, |
| 185 CreateWalletItemsWithRequiredActions); | 186 CreateWalletItemsWithRequiredActions); |
| 186 WalletItems(const std::vector<std::string>& required_actions, | 187 WalletItems(const std::vector<RequiredAction>& required_actions, |
| 187 const std::string& google_transaction_id, | 188 const std::string& google_transaction_id, |
| 188 const std::string& default_instrument_id, | 189 const std::string& default_instrument_id, |
| 189 const std::string& default_address_id); | 190 const std::string& default_address_id); |
| 190 // Actions that must be completed by the user before a FullWallet can be | 191 // Actions that must be completed by the user before a FullWallet can be |
| 191 // issued to them by the Online Wallet service. | 192 // issued to them by the Online Wallet service. |
| 192 // TODO(ahutter): |required_actions_| should be members of an enum not | 193 std::vector<RequiredAction> required_actions_; |
| 193 // strings. See http://crbug.com/165195. | |
| 194 std::vector<std::string> required_actions_; | |
| 195 std::string google_transaction_id_; | 194 std::string google_transaction_id_; |
| 196 std::string default_instrument_id_; | 195 std::string default_instrument_id_; |
| 197 std::string default_address_id_; | 196 std::string default_address_id_; |
| 198 ScopedVector<MaskedInstrument> instruments_; | 197 ScopedVector<MaskedInstrument> instruments_; |
| 199 ScopedVector<Address> addresses_; | 198 ScopedVector<Address> addresses_; |
| 200 ScopedVector<LegalDocument> legal_documents_; | 199 ScopedVector<LegalDocument> legal_documents_; |
| 201 DISALLOW_COPY_AND_ASSIGN(WalletItems); | 200 DISALLOW_COPY_AND_ASSIGN(WalletItems); |
| 202 }; | 201 }; |
| 203 | 202 |
| 204 } // namespace wallet | 203 } // namespace wallet |
| 205 | 204 |
| 206 #endif // CHROME_BROWSER_AUTOFILL_WALLET_WALLET_ITEMS_H_ | 205 #endif // CHROME_BROWSER_AUTOFILL_WALLET_WALLET_ITEMS_H_ |
| 207 | 206 |
| OLD | NEW |