OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_AUTOFILL_WALLET_WALLET_ITEMS_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_WALLET_WALLET_ITEMS_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/scoped_vector.h" |
| 14 #include "chrome/browser/autofill/wallet/wallet_address.h" |
| 15 |
| 16 namespace base { |
| 17 class DictionaryValue; |
| 18 } |
| 19 |
| 20 namespace wallet { |
| 21 |
| 22 class WalletItems { |
| 23 public: |
| 24 class MaskedInstrument { |
| 25 public: |
| 26 enum Type { |
| 27 UNKNOWN, |
| 28 VISA, |
| 29 MASTER_CARD, |
| 30 AMEX, |
| 31 DISCOVER, |
| 32 SOLO, |
| 33 MAESTRO, |
| 34 SWITCH, |
| 35 }; |
| 36 enum Status { |
| 37 PENDING, |
| 38 VALID, |
| 39 DECLINED, |
| 40 UNSUPPORTED_COUNTRY, |
| 41 EXPIRED, |
| 42 BILLING_INCOMPLETE, |
| 43 // correspond to any other inapplicable reasons that do not listed above |
| 44 INAPPLICABLE, |
| 45 }; |
| 46 MaskedInstrument(const std::string& descriptve_name, |
| 47 Type type, |
| 48 std::vector<std::string> supported_currencies, |
| 49 const std::string& last_four_digits, |
| 50 int expiration_month, |
| 51 int expiration_year, |
| 52 const std::string& brand, |
| 53 Address* address, |
| 54 Status status, |
| 55 const std::string& object_id); |
| 56 ~MaskedInstrument(); |
| 57 static MaskedInstrument* FromDictionary(base::DictionaryValue* dictionary); |
| 58 bool operator==(const MaskedInstrument& other) const; |
| 59 bool operator!=(const MaskedInstrument& other) const; |
| 60 |
| 61 const std::string GetDescriptiveName() const { return descriptive_name_; } |
| 62 Type getType() const { return type_; } |
| 63 const std::vector<std::string> GetSupportedCurrencies() const { |
| 64 return supported_currencies_; |
| 65 } |
| 66 const std::string GetLastFourDigits() const { return last_four_digits_; } |
| 67 int GetExpirationMonth() const { return expiration_month_; } |
| 68 int getExpirationYear() const { return expiration_year_; } |
| 69 const std::string GetBrand() const { return brand_; } |
| 70 const Address* GetAddress() const { return address_.get(); } |
| 71 Status GetStatus() const { return status_; } |
| 72 const std::string GetObjectId() const { return object_id_; } |
| 73 |
| 74 private: |
| 75 static Type TypeFromString(const std::string& type_string); |
| 76 static Status StatusFromString(const std::string& status_string); |
| 77 std::string descriptive_name_; |
| 78 Type type_; |
| 79 std::vector<std::string> supported_currencies_; |
| 80 std::string last_four_digits_; |
| 81 int expiration_month_; |
| 82 int expiration_year_; |
| 83 std::string brand_; |
| 84 scoped_ptr<Address> address_; |
| 85 Status status_; |
| 86 std::string object_id_; |
| 87 DISALLOW_COPY_AND_ASSIGN(MaskedInstrument); |
| 88 }; |
| 89 |
| 90 class LegalDocument { |
| 91 public: |
| 92 LegalDocument(const std::string& document_id, |
| 93 const std::string& display_name, |
| 94 const std::string& document_body); |
| 95 ~LegalDocument(); |
| 96 static LegalDocument* FromDictionary(base::DictionaryValue* dictionary); |
| 97 bool operator==(const LegalDocument& other) const; |
| 98 bool operator!=(const LegalDocument& other) const; |
| 99 |
| 100 const std::string GetDocumentId() const { return document_id_; } |
| 101 const std::string GetDisplayName() const { return display_name_; } |
| 102 const std::string GetDocumentBody() const { return document_body_; } |
| 103 |
| 104 private: |
| 105 std::string document_id_; |
| 106 std::string display_name_; |
| 107 std::string document_body_; |
| 108 DISALLOW_COPY_AND_ASSIGN(LegalDocument); |
| 109 }; |
| 110 |
| 111 WalletItems(const std::vector<std::string> required_actions, |
| 112 const std::string& google_transaction_id, |
| 113 const std::string& default_instrument_id, |
| 114 const std::string& default_address_id); |
| 115 ~WalletItems(); |
| 116 static scoped_ptr<WalletItems> FromDictionary( |
| 117 base::DictionaryValue* dictionary); |
| 118 bool operator==(const WalletItems& other) const; |
| 119 bool operator!=(const WalletItems& other) const; |
| 120 |
| 121 void AddInstrument(MaskedInstrument* instrument) { |
| 122 instruments_.push_back(instrument); |
| 123 } |
| 124 void AddAddress(Address* address) { addresses_.push_back(address); } |
| 125 void AddLegalDocument(LegalDocument* legal_document) { |
| 126 legal_documents_.push_back(legal_document); |
| 127 } |
| 128 const std::vector<std::string> GetRequiredActions() const { |
| 129 return required_actions_; |
| 130 } |
| 131 const std::string GetGoogleTransactionId() const { |
| 132 return google_transaction_id_; |
| 133 } |
| 134 const std::vector<MaskedInstrument*> GetInstruments() const { |
| 135 return instruments_.get(); |
| 136 } |
| 137 const std::string GetDefaultInstrumentId() const { |
| 138 return default_instrument_id_; |
| 139 } |
| 140 const std::vector<Address*> GetAddresses() const { return addresses_.get(); } |
| 141 const std::string GetDefaultAddressId() const { return default_address_id_; } |
| 142 const std::vector<LegalDocument*> GetLegalDocuments() const { |
| 143 return legal_documents_.get(); |
| 144 } |
| 145 |
| 146 private: |
| 147 std::vector<std::string> required_actions_; |
| 148 std::string google_transaction_id_; |
| 149 std::string default_instrument_id_; |
| 150 std::string default_address_id_; |
| 151 ScopedVector<MaskedInstrument> instruments_; |
| 152 ScopedVector<Address> addresses_; |
| 153 ScopedVector<LegalDocument> legal_documents_; |
| 154 DISALLOW_COPY_AND_ASSIGN(WalletItems); |
| 155 }; |
| 156 |
| 157 } // end namespace wallet |
| 158 |
| 159 #endif // CHROME_BROWSER_AUTOFILL_WALLET_WALLET_ITEMS_H_ |
OLD | NEW |