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_CORE_BROWSER_CREDIT_CARD_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 28 matching lines...) Expand all Loading... |
39 EXPIRED, | 39 EXPIRED, |
40 OK, | 40 OK, |
41 }; | 41 }; |
42 | 42 |
43 CreditCard(const std::string& guid, const std::string& origin); | 43 CreditCard(const std::string& guid, const std::string& origin); |
44 CreditCard(const base::string16& card_number, | 44 CreditCard(const base::string16& card_number, |
45 int expiration_month, | 45 int expiration_month, |
46 int expiration_year); | 46 int expiration_year); |
47 | 47 |
48 // Creates a server card. The type must be MASKED_SERVER_CARD or | 48 // Creates a server card. The type must be MASKED_SERVER_CARD or |
49 // FULL_SERVER_CARD. | 49 // FULL_SERVER_CARD. |server_id| should not be empty. |
50 CreditCard(RecordType type, const std::string& server_id); | 50 CreditCard(RecordType type, const std::string& server_id); |
51 | 51 |
52 // For use in STL containers. | 52 // For use in STL containers. |
53 CreditCard(); | 53 CreditCard(); |
54 CreditCard(const CreditCard& credit_card); | 54 CreditCard(const CreditCard& credit_card); |
55 ~CreditCard() override; | 55 ~CreditCard() override; |
56 | 56 |
57 // Returns a version of |number| that has any separator characters removed. | 57 // Returns a version of |number| that has any separator characters removed. |
58 static const base::string16 StripSeparators(const base::string16& number); | 58 static const base::string16 StripSeparators(const base::string16& number); |
59 | 59 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 int expiration_month() const { return expiration_month_; } | 117 int expiration_month() const { return expiration_month_; } |
118 int expiration_year() const { return expiration_year_; } | 118 int expiration_year() const { return expiration_year_; } |
119 | 119 |
120 // These setters verify that the month and year are within appropriate | 120 // These setters verify that the month and year are within appropriate |
121 // ranges, or 0. They take integers as an alternative to setting the inputs | 121 // ranges, or 0. They take integers as an alternative to setting the inputs |
122 // from strings via SetInfo(). | 122 // from strings via SetInfo(). |
123 void SetExpirationMonth(int expiration_month); | 123 void SetExpirationMonth(int expiration_month); |
124 void SetExpirationYear(int expiration_year); | 124 void SetExpirationYear(int expiration_year); |
125 | 125 |
126 const std::string& server_id() const { return server_id_; } | |
127 | |
128 // For use in STL containers. | 126 // For use in STL containers. |
129 void operator=(const CreditCard& credit_card); | 127 void operator=(const CreditCard& credit_card); |
130 | 128 |
131 // If the card numbers for |this| and |imported_card| match, and merging the | 129 // If the card numbers for |this| and |imported_card| match, and merging the |
132 // two wouldn't result in unverified data overwriting verified data, | 130 // two wouldn't result in unverified data overwriting verified data, |
133 // overwrites |this| card's data with the data in |credit_card|. | 131 // overwrites |this| card's data with the data in |credit_card|. |
134 // Returns true if the card numbers match, false otherwise. | 132 // Returns true if the card numbers match, false otherwise. |
135 bool UpdateFromImportedCard(const CreditCard& imported_card, | 133 bool UpdateFromImportedCard(const CreditCard& imported_card, |
136 const std::string& app_locale) WARN_UNUSED_RESULT; | 134 const std::string& app_locale) WARN_UNUSED_RESULT; |
137 | 135 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // The cardholder's name. May be empty. | 208 // The cardholder's name. May be empty. |
211 base::string16 name_on_card_; | 209 base::string16 name_on_card_; |
212 | 210 |
213 // The type of the card. This is one of the k...Card constants below. | 211 // The type of the card. This is one of the k...Card constants below. |
214 std::string type_; | 212 std::string type_; |
215 | 213 |
216 // These members are zero if not present. | 214 // These members are zero if not present. |
217 int expiration_month_; | 215 int expiration_month_; |
218 int expiration_year_; | 216 int expiration_year_; |
219 | 217 |
220 // For server cards (both MASKED and UNMASKED) this is the ID assigned by the | |
221 // server to uniquely identify this card. | |
222 std::string server_id_; | |
223 | |
224 // The status of the card, as reported by the server. Not valid for local | 218 // The status of the card, as reported by the server. Not valid for local |
225 // cards. | 219 // cards. |
226 ServerStatus server_status_; | 220 ServerStatus server_status_; |
227 }; | 221 }; |
228 | 222 |
229 // So we can compare CreditCards with EXPECT_EQ(). | 223 // So we can compare CreditCards with EXPECT_EQ(). |
230 std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card); | 224 std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card); |
231 | 225 |
232 // The string identifiers for credit card icon resources. | 226 // The string identifiers for credit card icon resources. |
233 extern const char* const kAmericanExpressCard; | 227 extern const char* const kAmericanExpressCard; |
234 extern const char* const kDinersCard; | 228 extern const char* const kDinersCard; |
235 extern const char* const kDiscoverCard; | 229 extern const char* const kDiscoverCard; |
236 extern const char* const kGenericCard; | 230 extern const char* const kGenericCard; |
237 extern const char* const kJCBCard; | 231 extern const char* const kJCBCard; |
238 extern const char* const kMasterCard; | 232 extern const char* const kMasterCard; |
239 extern const char* const kUnionPay; | 233 extern const char* const kUnionPay; |
240 extern const char* const kVisaCard; | 234 extern const char* const kVisaCard; |
241 | 235 |
242 } // namespace autofill | 236 } // namespace autofill |
243 | 237 |
244 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ | 238 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_CREDIT_CARD_H_ |
OLD | NEW |