Chromium Code Reviews| 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 #include "components/autofill/core/browser/credit_card_field.h" | 5 #include "components/autofill/core/browser/credit_card_field.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 ok && AddClassification(expiration_date_, GetExpirationYearType(), map); | 236 ok && AddClassification(expiration_date_, GetExpirationYearType(), map); |
| 237 } else { | 237 } else { |
| 238 ok = ok && AddClassification(expiration_month_, CREDIT_CARD_EXP_MONTH, map); | 238 ok = ok && AddClassification(expiration_month_, CREDIT_CARD_EXP_MONTH, map); |
| 239 ok = | 239 ok = |
| 240 ok && AddClassification(expiration_year_, GetExpirationYearType(), map); | 240 ok && AddClassification(expiration_year_, GetExpirationYearType(), map); |
| 241 } | 241 } |
| 242 | 242 |
| 243 return ok; | 243 return ok; |
| 244 } | 244 } |
| 245 | 245 |
| 246 size_t CreditCardField::FieldCount() const { | |
| 247 size_t count = 0; | |
| 248 | |
| 249 if (cardholder_) | |
| 250 ++count; | |
| 251 if (cardholder_last_) | |
| 252 ++count; | |
| 253 if (type_) | |
| 254 ++count; | |
| 255 count += numbers_.size(); | |
|
Evan Stade
2015/01/21 22:52:49
this should probably be
if (!numbers_.empty())
Lei Zhang
2015/01/22 08:07:36
Done.
| |
| 256 if (verification_) | |
| 257 ++count; | |
| 258 if (expiration_month_) | |
| 259 ++count; | |
| 260 if (expiration_year_) | |
| 261 ++count; | |
| 262 if (expiration_date_) | |
| 263 ++count; | |
| 264 | |
| 265 return count;; | |
| 266 } | |
| 267 | |
| 246 ServerFieldType CreditCardField::GetExpirationYearType() const { | 268 ServerFieldType CreditCardField::GetExpirationYearType() const { |
| 247 return (expiration_date_ | 269 return (expiration_date_ |
| 248 ? exp_year_type_ | 270 ? exp_year_type_ |
| 249 : ((expiration_year_ && expiration_year_->max_length == 2) | 271 : ((expiration_year_ && expiration_year_->max_length == 2) |
| 250 ? CREDIT_CARD_EXP_2_DIGIT_YEAR | 272 ? CREDIT_CARD_EXP_2_DIGIT_YEAR |
| 251 : CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 273 : CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
| 252 } | 274 } |
| 253 | 275 |
| 254 } // namespace autofill | 276 } // namespace autofill |
| OLD | NEW |