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

Side by Side Diff: components/autofill/browser/credit_card.h

Issue 14096009: [Autofill] Split off AutofillDataModel as a subclass of FormData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Android compile Created 7 years, 8 months 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
« no previous file with comments | « components/autofill/browser/contact_info.h ('k') | components/autofill/browser/credit_card.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 COMPONENTS_AUTOFILL_BROWSER_CREDIT_CARD_H_ 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_CREDIT_CARD_H_
6 #define COMPONENTS_AUTOFILL_BROWSER_CREDIT_CARD_H_ 6 #define COMPONENTS_AUTOFILL_BROWSER_CREDIT_CARD_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h"
12 #include "base/string16.h" 13 #include "base/string16.h"
14 #include "components/autofill/browser/autofill_data_model.h"
13 #include "components/autofill/browser/field_types.h" 15 #include "components/autofill/browser/field_types.h"
14 #include "components/autofill/browser/form_group.h"
15 16
16 namespace autofill { 17 namespace autofill {
17 18
18 struct FormFieldData; 19 struct FormFieldData;
19 20
20 // A form group that stores credit card information. 21 // A form group that stores credit card information.
21 class CreditCard : public FormGroup { 22 class CreditCard : public AutofillDataModel {
22 public: 23 public:
23 explicit CreditCard(const std::string& guid); 24 explicit CreditCard(const std::string& guid);
24 25
25 // For use in STL containers. 26 // For use in STL containers.
26 CreditCard(); 27 CreditCard();
27 CreditCard(const CreditCard& credit_card); 28 CreditCard(const CreditCard& credit_card);
28 virtual ~CreditCard(); 29 virtual ~CreditCard();
29 30
30 // Returns a version of |number| that has any separator characters removed. 31 // Returns a version of |number| that has any separator characters removed.
31 static const base::string16 StripSeparators(const base::string16& number); 32 static const base::string16 StripSeparators(const base::string16& number);
32 33
33 // The user-visible type of the card, e.g. 'Mastercard'. 34 // The user-visible type of the card, e.g. 'Mastercard'.
34 static base::string16 TypeForDisplay(const std::string& type); 35 static base::string16 TypeForDisplay(const std::string& type);
35 36
36 // FormGroup implementation: 37 // FormGroup:
37 virtual std::string GetGUID() const OVERRIDE;
38 virtual void GetMatchingTypes(const base::string16& text, 38 virtual void GetMatchingTypes(const base::string16& text,
39 const std::string& app_locale, 39 const std::string& app_locale,
40 FieldTypeSet* matching_types) const OVERRIDE; 40 FieldTypeSet* matching_types) const OVERRIDE;
41 virtual base::string16 GetRawInfo(AutofillFieldType type) const OVERRIDE; 41 virtual base::string16 GetRawInfo(AutofillFieldType type) const OVERRIDE;
42 virtual void SetRawInfo(AutofillFieldType type, 42 virtual void SetRawInfo(AutofillFieldType type,
43 const base::string16& value) OVERRIDE; 43 const base::string16& value) OVERRIDE;
44 virtual base::string16 GetInfo(AutofillFieldType type, 44 virtual base::string16 GetInfo(AutofillFieldType type,
45 const std::string& app_locale) const OVERRIDE; 45 const std::string& app_locale) const OVERRIDE;
46 virtual bool SetInfo(AutofillFieldType type, 46 virtual bool SetInfo(AutofillFieldType type,
47 const base::string16& value, 47 const base::string16& value,
48 const std::string& app_locale) OVERRIDE; 48 const std::string& app_locale) OVERRIDE;
49
50 // AutofillDataModel:
49 virtual void FillFormField(const AutofillField& field, 51 virtual void FillFormField(const AutofillField& field,
50 size_t variant, 52 size_t variant,
51 const std::string& app_locale, 53 const std::string& app_locale,
52 FormFieldData* field_data) const OVERRIDE; 54 FormFieldData* field_data) const OVERRIDE;
53 55
54 // Credit card preview summary, for example: ******1234, Exp: 01/2020 56 // Credit card preview summary, for example: ******1234, Exp: 01/2020
55 const base::string16 Label() const; 57 const base::string16 Label() const;
56 58
57 // Special method to set value for HTML5 month input type. 59 // Special method to set value for HTML5 month input type.
58 void SetInfoForMonthInputType(const base::string16& value); 60 void SetInfoForMonthInputType(const base::string16& value);
59 61
60 // The number altered for display, for example: ******1234 62 // The number altered for display, for example: ******1234
61 base::string16 ObfuscatedNumber() const; 63 base::string16 ObfuscatedNumber() const;
62 // The last four digits of the credit card number. 64 // The last four digits of the credit card number.
63 base::string16 LastFourDigits() const; 65 base::string16 LastFourDigits() const;
64 // The user-visible type of the card, e.g. 'Mastercard'. 66 // The user-visible type of the card, e.g. 'Mastercard'.
65 base::string16 TypeForDisplay() const; 67 base::string16 TypeForDisplay() const;
66 // A label for this credit card formatted as 'Cardname - 2345'. 68 // A label for this credit card formatted as 'Cardname - 2345'.
67 base::string16 TypeAndLastFourDigits() const; 69 base::string16 TypeAndLastFourDigits() const;
68 // The ResourceBundle ID for the appropriate credit card image. 70 // The ResourceBundle ID for the appropriate credit card image.
69 int IconResourceId() const; 71 int IconResourceId() const;
70 72
71 const std::string& type() const { return type_; } 73 const std::string& type() const { return type_; }
72 74
73 int expiration_month() const { return expiration_month_; } 75 int expiration_month() const { return expiration_month_; }
74 int expiration_year() const { return expiration_year_; } 76 int expiration_year() const { return expiration_year_; }
75 77
76 // The guid is the primary identifier for |CreditCard| objects.
77 // TODO(estade): remove this and just use GetGUID().
78 const std::string guid() const { return guid_; }
79 void set_guid(const std::string& guid) { guid_ = guid; }
80
81 // For use in STL containers. 78 // For use in STL containers.
82 void operator=(const CreditCard& credit_card); 79 void operator=(const CreditCard& credit_card);
83 80
84 // If the card numbers for |this| and |imported_card| match, overwrites |this| 81 // If the card numbers for |this| and |imported_card| match, overwrites |this|
85 // card's data with the data in |credit_card| and returns true. Otherwise, 82 // card's data with the data in |credit_card| and returns true. Otherwise,
86 // returns false. 83 // returns false.
87 bool UpdateFromImportedCard(const CreditCard& imported_card, 84 bool UpdateFromImportedCard(const CreditCard& imported_card,
88 const std::string& app_locale) WARN_UNUSED_RESULT; 85 const std::string& app_locale) WARN_UNUSED_RESULT;
89 86
90 // Comparison for Sync. Returns 0 if the credit card is the same as |this|, 87 // Comparison for Sync. Returns 0 if the credit card is the same as |this|,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void SetExpirationMonth(int expiration_month); 131 void SetExpirationMonth(int expiration_month);
135 void SetExpirationYear(int expiration_year); 132 void SetExpirationYear(int expiration_year);
136 133
137 base::string16 number_; // The credit card number. 134 base::string16 number_; // The credit card number.
138 base::string16 name_on_card_; // The cardholder's name. 135 base::string16 name_on_card_; // The cardholder's name.
139 std::string type_; // The type of the card. 136 std::string type_; // The type of the card.
140 137
141 // These members are zero if not present. 138 // These members are zero if not present.
142 int expiration_month_; 139 int expiration_month_;
143 int expiration_year_; 140 int expiration_year_;
144
145 // The guid of this credit card.
146 std::string guid_;
147 }; 141 };
148 142
149 // So we can compare CreditCards with EXPECT_EQ(). 143 // So we can compare CreditCards with EXPECT_EQ().
150 std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card); 144 std::ostream& operator<<(std::ostream& os, const CreditCard& credit_card);
151 145
152 // The string identifiers for credit card icon resources. 146 // The string identifiers for credit card icon resources.
153 extern const char* const kAmericanExpressCard; 147 extern const char* const kAmericanExpressCard;
154 extern const char* const kDinersCard; 148 extern const char* const kDinersCard;
155 extern const char* const kDiscoverCard; 149 extern const char* const kDiscoverCard;
156 extern const char* const kGenericCard; 150 extern const char* const kGenericCard;
157 extern const char* const kJCBCard; 151 extern const char* const kJCBCard;
158 extern const char* const kMasterCard; 152 extern const char* const kMasterCard;
159 extern const char* const kSoloCard; 153 extern const char* const kSoloCard;
160 extern const char* const kVisaCard; 154 extern const char* const kVisaCard;
161 155
162 } // namespace autofill 156 } // namespace autofill
163 157
164 #endif // COMPONENTS_AUTOFILL_BROWSER_CREDIT_CARD_H_ 158 #endif // COMPONENTS_AUTOFILL_BROWSER_CREDIT_CARD_H_
OLDNEW
« no previous file with comments | « components/autofill/browser/contact_info.h ('k') | components/autofill/browser/credit_card.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698