Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/browser/autofill/wallet/wallet_items.h

Issue 11293078: Integrating Online Wallet into Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and most fixes from Albert's initial review. Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
Dan Beam 2012/12/01 01:19:49 doc comement
ahutter 2012/12/01 04:06:51 Done.
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 // Returns null if input is invalid or a valid masked instrument. Caller
58 // owns returned pointer.
59 static MaskedInstrument* CreateMaskedInstrument(
60 base::DictionaryValue* dictionary);
61 bool operator==(const MaskedInstrument& other) const;
62 bool operator!=(const MaskedInstrument& other) const;
63
64 const std::string get_descriptive_name() const { return descriptive_name_; }
Dan Beam 2012/12/01 01:19:49 nit: s/get_// for all simple dumb unix_hacker_gett
ahutter 2012/12/01 04:06:51 Done.
65 Type get_type() const { return type_; }
66 const std::vector<std::string> get_supported_currencies() const {
67 return supported_currencies_;
68 }
69 const std::string get_last_four_digits() const { return last_four_digits_; }
70 int get_expiration_month() const { return expiration_month_; }
71 int get_expiration_year() const { return expiration_year_; }
72 const std::string GetBrand() const { return brand_; }
73 const Address* get_address() const { return address_.get(); }
74 Status get_status() const { return status_; }
75 const std::string get_object_id() const { return object_id_; }
76
77 private:
78 static Type TypeFromString(const std::string& type_string);
79 static Status StatusFromString(const std::string& status_string);
80 std::string descriptive_name_;
81 Type type_;
82 std::vector<std::string> supported_currencies_;
83 std::string last_four_digits_;
84 int expiration_month_;
85 int expiration_year_;
86 std::string brand_;
87 scoped_ptr<Address> address_;
88 Status status_;
89 std::string object_id_;
90 DISALLOW_COPY_AND_ASSIGN(MaskedInstrument);
91 };
92
93 class LegalDocument {
94 public:
95 LegalDocument(const std::string& document_id,
96 const std::string& display_name,
97 const std::string& document_body);
98 ~LegalDocument();
99 // Returns null if input is invalid or a valid legal document. Caller owns
100 // returned pointer.
101 static LegalDocument* CreateLegalDocument(
102 base::DictionaryValue* dictionary);
103 bool operator==(const LegalDocument& other) const;
104 bool operator!=(const LegalDocument& other) const;
105
Dan Beam 2012/12/01 01:19:49 nit: same nit re: removing get_
ahutter 2012/12/01 04:06:51 Done.
106 const std::string get_document_id() const { return document_id_; }
107 const std::string get_display_name() const { return display_name_; }
108 const std::string get_document_body() const { return document_body_; }
109
110 private:
111 std::string document_id_;
112 std::string display_name_;
113 std::string document_body_;
114 DISALLOW_COPY_AND_ASSIGN(LegalDocument);
115 };
116
117 WalletItems(const std::vector<std::string> required_actions,
118 const std::string& google_transaction_id,
119 const std::string& default_instrument_id,
120 const std::string& default_address_id);
121 ~WalletItems();
122 // Returns null if input is invalid, an empty wallet items with required
Dan Beam 2012/12/01 01:19:49 nit: this looks like a run-on sentence, use ; or .
ahutter 2012/12/01 04:06:51 Done.
123 // actions if they are present or valid wallet items. Caller owns returned
124 // pointer.
125 static WalletItems* CreateWalletItems(base::DictionaryValue* dictionary);
126 bool operator==(const WalletItems& other) const;
127 bool operator!=(const WalletItems& other) const;
128
129 void AddInstrument(MaskedInstrument* instrument) {
130 instruments_.push_back(instrument);
131 }
132 void AddAddress(Address* address) { addresses_.push_back(address); }
133 void AddLegalDocument(LegalDocument* legal_document) {
134 legal_documents_.push_back(legal_document);
135 }
136 const std::vector<std::string> get_required_actions() const {
137 return required_actions_;
138 }
139 const std::string get_google_transaction_id() const {
140 return google_transaction_id_;
141 }
142 const std::vector<MaskedInstrument*> get_instruments() const {
143 return instruments_.get();
144 }
145 const std::string get_default_instrument_id() const {
146 return default_instrument_id_;
147 }
148 const std::vector<Address*> get_addresses() const { return addresses_.get(); }
149 const std::string get_default_address_id() const {
150 return default_address_id_;
151 }
152 const std::vector<LegalDocument*> get_legal_documents() const {
153 return legal_documents_.get();
154 }
155
156 private:
157 std::vector<std::string> required_actions_;
158 std::string google_transaction_id_;
159 std::string default_instrument_id_;
160 std::string default_address_id_;
161 ScopedVector<MaskedInstrument> instruments_;
162 ScopedVector<Address> addresses_;
163 ScopedVector<LegalDocument> legal_documents_;
164 DISALLOW_COPY_AND_ASSIGN(WalletItems);
165 };
166
167 } // end namespace wallet
168
169 #endif // CHROME_BROWSER_AUTOFILL_WALLET_WALLET_ITEMS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698