| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/autofill/credit_card.h" | 5 #include "chrome/browser/autofill/credit_card.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 possible_types->insert(CREDIT_CARD_NUMBER); | 166 possible_types->insert(CREDIT_CARD_NUMBER); |
| 167 | 167 |
| 168 if (IsExpirationMonth(text)) | 168 if (IsExpirationMonth(text)) |
| 169 possible_types->insert(CREDIT_CARD_EXP_MONTH); | 169 possible_types->insert(CREDIT_CARD_EXP_MONTH); |
| 170 | 170 |
| 171 if (Is2DigitExpirationYear(text)) | 171 if (Is2DigitExpirationYear(text)) |
| 172 possible_types->insert(CREDIT_CARD_EXP_2_DIGIT_YEAR); | 172 possible_types->insert(CREDIT_CARD_EXP_2_DIGIT_YEAR); |
| 173 | 173 |
| 174 if (Is4DigitExpirationYear(text)) | 174 if (Is4DigitExpirationYear(text)) |
| 175 possible_types->insert(CREDIT_CARD_EXP_4_DIGIT_YEAR); | 175 possible_types->insert(CREDIT_CARD_EXP_4_DIGIT_YEAR); |
| 176 |
| 177 if (text == GetInfo(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)) |
| 178 possible_types->insert(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR); |
| 179 |
| 180 if (text == GetInfo(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)) |
| 181 possible_types->insert(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR); |
| 176 } | 182 } |
| 177 | 183 |
| 178 void CreditCard::GetAvailableFieldTypes(FieldTypeSet* available_types) const { | 184 void CreditCard::GetAvailableFieldTypes(FieldTypeSet* available_types) const { |
| 179 DCHECK(available_types); | 185 DCHECK(available_types); |
| 180 | 186 |
| 181 if (!name_on_card_.empty()) | 187 if (!name_on_card_.empty()) |
| 182 available_types->insert(CREDIT_CARD_NAME); | 188 available_types->insert(CREDIT_CARD_NAME); |
| 183 | 189 |
| 184 if (!number_.empty()) | 190 if (!number_.empty()) |
| 185 available_types->insert(CREDIT_CARD_NUMBER); | 191 available_types->insert(CREDIT_CARD_NUMBER); |
| 186 | 192 |
| 187 if (!ExpirationMonthAsString().empty()) | 193 if (!ExpirationMonthAsString().empty()) |
| 188 available_types->insert(CREDIT_CARD_EXP_MONTH); | 194 available_types->insert(CREDIT_CARD_EXP_MONTH); |
| 189 | 195 |
| 190 if (!Expiration2DigitYearAsString().empty()) | 196 if (!Expiration2DigitYearAsString().empty()) |
| 191 available_types->insert(CREDIT_CARD_EXP_2_DIGIT_YEAR); | 197 available_types->insert(CREDIT_CARD_EXP_2_DIGIT_YEAR); |
| 192 | 198 |
| 193 if (!Expiration4DigitYearAsString().empty()) | 199 if (!Expiration4DigitYearAsString().empty()) |
| 194 available_types->insert(CREDIT_CARD_EXP_4_DIGIT_YEAR); | 200 available_types->insert(CREDIT_CARD_EXP_4_DIGIT_YEAR); |
| 201 |
| 202 if (!GetInfo(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR).empty()) |
| 203 available_types->insert(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR); |
| 204 |
| 205 if (!GetInfo(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR).empty()) |
| 206 available_types->insert(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR); |
| 195 } | 207 } |
| 196 | 208 |
| 197 string16 CreditCard::GetInfo(AutofillFieldType type) const { | 209 string16 CreditCard::GetInfo(AutofillFieldType type) const { |
| 198 switch (type) { | 210 switch (type) { |
| 199 case CREDIT_CARD_NAME: | 211 case CREDIT_CARD_NAME: |
| 200 return name_on_card_; | 212 return name_on_card_; |
| 201 | 213 |
| 202 case CREDIT_CARD_EXP_MONTH: | 214 case CREDIT_CARD_EXP_MONTH: |
| 203 return ExpirationMonthAsString(); | 215 return ExpirationMonthAsString(); |
| 204 | 216 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 break; | 264 break; |
| 253 | 265 |
| 254 case CREDIT_CARD_EXP_2_DIGIT_YEAR: | 266 case CREDIT_CARD_EXP_2_DIGIT_YEAR: |
| 255 // This is a read-only attribute. | 267 // This is a read-only attribute. |
| 256 break; | 268 break; |
| 257 | 269 |
| 258 case CREDIT_CARD_EXP_4_DIGIT_YEAR: | 270 case CREDIT_CARD_EXP_4_DIGIT_YEAR: |
| 259 SetExpirationYearFromString(value); | 271 SetExpirationYearFromString(value); |
| 260 break; | 272 break; |
| 261 | 273 |
| 274 case CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR: |
| 275 // This is a read-only attribute. |
| 276 break; |
| 277 |
| 278 case CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR: |
| 279 // This is a read-only attribute. |
| 280 break; |
| 281 |
| 262 case CREDIT_CARD_TYPE: | 282 case CREDIT_CARD_TYPE: |
| 263 // We determine the type based on the number. | 283 // We determine the type based on the number. |
| 264 break; | 284 break; |
| 265 | 285 |
| 266 case CREDIT_CARD_NUMBER: { | 286 case CREDIT_CARD_NUMBER: { |
| 267 // Don't change the real value if the input is an obfuscated string. | 287 // Don't change the real value if the input is an obfuscated string. |
| 268 if (value.size() > 0 && value[0] != kCreditCardObfuscationSymbol) | 288 if (value.size() > 0 && value[0] != kCreditCardObfuscationSymbol) |
| 269 SetNumber(value); | 289 SetNumber(value); |
| 270 break; | 290 break; |
| 271 } | 291 } |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 // send these strings to WK, which then asks WebKitClientImpl to load the image | 575 // send these strings to WK, which then asks WebKitClientImpl to load the image |
| 556 // data. | 576 // data. |
| 557 const char* const kAmericanExpressCard = "americanExpressCC"; | 577 const char* const kAmericanExpressCard = "americanExpressCC"; |
| 558 const char* const kDinersCard = "dinersCC"; | 578 const char* const kDinersCard = "dinersCC"; |
| 559 const char* const kDiscoverCard = "discoverCC"; | 579 const char* const kDiscoverCard = "discoverCC"; |
| 560 const char* const kGenericCard = "genericCC"; | 580 const char* const kGenericCard = "genericCC"; |
| 561 const char* const kJCBCard = "jcbCC"; | 581 const char* const kJCBCard = "jcbCC"; |
| 562 const char* const kMasterCard = "masterCardCC"; | 582 const char* const kMasterCard = "masterCardCC"; |
| 563 const char* const kSoloCard = "soloCC"; | 583 const char* const kSoloCard = "soloCC"; |
| 564 const char* const kVisaCard = "visaCC"; | 584 const char* const kVisaCard = "visaCC"; |
| OLD | NEW |