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* CreateFromDictionary( |
| 58 base::DictionaryValue* dictionary); |
| 59 bool operator==(const MaskedInstrument& other) const; |
| 60 bool operator!=(const MaskedInstrument& other) const; |
| 61 |
| 62 const std::string get_descriptive_name() const { return descriptive_name_; } |
| 63 Type get_type() const { return type_; } |
| 64 const std::vector<std::string> get_supported_currencies() const { |
| 65 return supported_currencies_; |
| 66 } |
| 67 const std::string get_last_four_digits() const { return last_four_digits_; } |
| 68 int get_expiration_month() const { return expiration_month_; } |
| 69 int get_expiration_year() const { return expiration_year_; } |
| 70 const std::string GetBrand() const { return brand_; } |
| 71 const Address* get_address() const { return address_.get(); } |
| 72 Status get_status() const { return status_; } |
| 73 const std::string get_object_id() const { return object_id_; } |
| 74 |
| 75 private: |
| 76 static Type TypeFromString(const std::string& type_string); |
| 77 static Status StatusFromString(const std::string& status_string); |
| 78 std::string descriptive_name_; |
| 79 Type type_; |
| 80 std::vector<std::string> supported_currencies_; |
| 81 std::string last_four_digits_; |
| 82 int expiration_month_; |
| 83 int expiration_year_; |
| 84 std::string brand_; |
| 85 scoped_ptr<Address> address_; |
| 86 Status status_; |
| 87 std::string object_id_; |
| 88 DISALLOW_COPY_AND_ASSIGN(MaskedInstrument); |
| 89 }; |
| 90 |
| 91 class LegalDocument { |
| 92 public: |
| 93 LegalDocument(const std::string& document_id, |
| 94 const std::string& display_name, |
| 95 const std::string& document_body); |
| 96 ~LegalDocument(); |
| 97 static LegalDocument* CreateFromDictionary( |
| 98 base::DictionaryValue* dictionary); |
| 99 bool operator==(const LegalDocument& other) const; |
| 100 bool operator!=(const LegalDocument& other) const; |
| 101 |
| 102 const std::string get_document_id() const { return document_id_; } |
| 103 const std::string get_display_name() const { return display_name_; } |
| 104 const std::string get_document_body() const { return document_body_; } |
| 105 |
| 106 private: |
| 107 std::string document_id_; |
| 108 std::string display_name_; |
| 109 std::string document_body_; |
| 110 DISALLOW_COPY_AND_ASSIGN(LegalDocument); |
| 111 }; |
| 112 |
| 113 WalletItems(const std::vector<std::string> required_actions, |
| 114 const std::string& google_transaction_id, |
| 115 const std::string& default_instrument_id, |
| 116 const std::string& default_address_id); |
| 117 ~WalletItems(); |
| 118 static WalletItems* CreateFromDictionary(base::DictionaryValue* dictionary); |
| 119 bool operator==(const WalletItems& other) const; |
| 120 bool operator!=(const WalletItems& other) const; |
| 121 |
| 122 void AddInstrument(MaskedInstrument* instrument) { |
| 123 instruments_.push_back(instrument); |
| 124 } |
| 125 void AddAddress(Address* address) { addresses_.push_back(address); } |
| 126 void AddLegalDocument(LegalDocument* legal_document) { |
| 127 legal_documents_.push_back(legal_document); |
| 128 } |
| 129 const std::vector<std::string> get_required_actions() const { |
| 130 return required_actions_; |
| 131 } |
| 132 const std::string get_google_transaction_id() const { |
| 133 return google_transaction_id_; |
| 134 } |
| 135 const std::vector<MaskedInstrument*> get_instruments() const { |
| 136 return instruments_.get(); |
| 137 } |
| 138 const std::string get_default_instrument_id() const { |
| 139 return default_instrument_id_; |
| 140 } |
| 141 const std::vector<Address*> get_addresses() const { return addresses_.get(); } |
| 142 const std::string get_default_address_id() const { |
| 143 return default_address_id_; |
| 144 } |
| 145 const std::vector<LegalDocument*> get_legal_documents() const { |
| 146 return legal_documents_.get(); |
| 147 } |
| 148 |
| 149 private: |
| 150 std::vector<std::string> required_actions_; |
| 151 std::string google_transaction_id_; |
| 152 std::string default_instrument_id_; |
| 153 std::string default_address_id_; |
| 154 ScopedVector<MaskedInstrument> instruments_; |
| 155 ScopedVector<Address> addresses_; |
| 156 ScopedVector<LegalDocument> legal_documents_; |
| 157 DISALLOW_COPY_AND_ASSIGN(WalletItems); |
| 158 }; |
| 159 |
| 160 } // end namespace wallet |
| 161 |
| 162 #endif // CHROME_BROWSER_AUTOFILL_WALLET_WALLET_ITEMS_H_ |
OLD | NEW |