summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/credit_card.h
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-06 05:41:34 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-06 05:41:34 +0000
commit3e6e82da372f9508e8819f84b03716b698fac2c8 (patch)
treeb95c52e1ae02f015a95f78ada0679a3fa6cdb08f /chrome/browser/autofill/credit_card.h
parent28e466cf8282a13c22ff64eb762b7adef8f68f11 (diff)
downloadchromium_src-3e6e82da372f9508e8819f84b03716b698fac2c8.zip
chromium_src-3e6e82da372f9508e8819f84b03716b698fac2c8.tar.gz
chromium_src-3e6e82da372f9508e8819f84b03716b698fac2c8.tar.bz2
Clean up Autofill CreditCard logic
* When determining possible field types (for upload to the server), match against stored data, not just against the Luhn checksum * When displaying the obfuscated credit card number, display exactly the right number of obfuscating '*'s. * When importing credit card data, only save the card if the detected card type is one we recognize. * Prune some unhelpful member variables * Prune some unhelpful methods from the header BUG=77822 TEST=unit_tests --gtest_filter=CreditCardTest.* Review URL: http://codereview.chromium.org/6690038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80580 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/credit_card.h')
-rw-r--r--chrome/browser/autofill/credit_card.h37
1 files changed, 9 insertions, 28 deletions
diff --git a/chrome/browser/autofill/credit_card.h b/chrome/browser/autofill/credit_card.h
index d27fc39..8f6c3be 100644
--- a/chrome/browser/autofill/credit_card.h
+++ b/chrome/browser/autofill/credit_card.h
@@ -30,6 +30,7 @@ class CreditCard : public FormGroup {
virtual void GetAvailableFieldTypes(FieldTypeSet* available_types) const;
virtual string16 GetInfo(AutofillFieldType type) const;
virtual void SetInfo(AutofillFieldType type, const string16& value);
+ // Credit card preview summary, for example: ******1234, Exp: 01/2020
virtual const string16 Label() const;
// Special method to set value for HTML5 month input type.
@@ -37,8 +38,6 @@ class CreditCard : public FormGroup {
// The number altered for display, for example: ******1234
string16 ObfuscatedNumber() const;
- // Credit card preview summary, for example: ******1234, Exp: 01/2020
- string16 PreviewSummary() const;
// The last four digits of the credit card number.
string16 LastFourDigits() const;
@@ -65,7 +64,7 @@ class CreditCard : public FormGroup {
// Returns true if |text| looks like a valid credit card number.
// Uses the Luhn formula to validate the number.
- static bool IsCreditCardNumber(const string16& text);
+ static bool IsValidCreditCardNumber(const string16& text);
// Returns true if there are no values (field types) set.
bool IsEmpty() const;
@@ -87,29 +86,21 @@ class CreditCard : public FormGroup {
// Sets |expiration_year_| to the integer conversion of |text|.
void SetExpirationYearFromString(const string16& text);
- const string16& name_on_card() const { return name_on_card_; }
- const string16& last_four_digits() const { return last_four_digits_; }
- int expiration_month() const { return expiration_month_; }
- int expiration_year() const { return expiration_year_; }
-
- void set_number(const string16& number);
- void set_name_on_card(const string16& name_on_card) {
- name_on_card_ = name_on_card;
- }
- void set_type(const string16& type) { type_ = type; }
- void set_last_four_digits(const string16& last_four_digits) {
- last_four_digits_ = last_four_digits;
- }
+ // Sets |number_| to the stripped version of |number|, containing only digits.
+ void SetNumber(const string16& number);
// These setters verify that the month and year are within appropriate
// ranges.
- void set_expiration_month(int expiration_month);
- void set_expiration_year(int expiration_year);
+ void SetExpirationMonth(int expiration_month);
+ void SetExpirationYear(int expiration_year);
// Returns true if |text| matches the name on the card. The comparison is
// case-insensitive.
bool IsNameOnCard(const string16& text) const;
+ // Returns true if |text| matches the card number.
+ bool IsNumber(const string16& text) const;
+
// Returns true if |text| matches the expiration month of the card.
bool IsExpirationMonth(const string16& text) const;
@@ -121,24 +112,14 @@ class CreditCard : public FormGroup {
// year.
bool Is4DigitExpirationYear(const string16& text) const;
- // Converts |date| to an integer form. Returns true if the conversion
- // succeeded.
- bool ConvertDate(const string16& date, int* num) const;
-
string16 number_; // The credit card number.
string16 name_on_card_; // The cardholder's name.
string16 type_; // The type of the card.
- // Stores the last four digits of the credit card number.
- string16 last_four_digits_;
-
// These members are zero if not present.
int expiration_month_;
int expiration_year_;
- // This is the display name of the card set by the user, e.g., Amazon Visa.
- string16 label_;
-
// The guid of this credit card.
std::string guid_;
};