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/autofill_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 void AutofillManager::ShowAutofillSettings() { | 256 void AutofillManager::ShowAutofillSettings() { |
257 client_->ShowAutofillSettings(); | 257 client_->ShowAutofillSettings(); |
258 } | 258 } |
259 | 259 |
260 bool AutofillManager::ShouldShowScanCreditCard(const FormData& form, | 260 bool AutofillManager::ShouldShowScanCreditCard(const FormData& form, |
261 const FormFieldData& field) { | 261 const FormFieldData& field) { |
262 if (!client_->HasCreditCardScanFeature()) | 262 if (!client_->HasCreditCardScanFeature()) |
263 return false; | 263 return false; |
264 | 264 |
265 AutofillField* autofill_field = GetAutofillField(form, field); | 265 AutofillField* autofill_field = GetAutofillField(form, field); |
266 if (!autofill_field || | 266 if (!autofill_field) |
267 autofill_field->Type().GetStorableType() != CREDIT_CARD_NUMBER) { | 267 return false; |
| 268 |
| 269 bool is_card_number_field = |
| 270 autofill_field->Type().GetStorableType() == CREDIT_CARD_NUMBER && |
| 271 base::ContainsOnlyChars(CreditCard::StripSeparators(field.value), |
| 272 base::ASCIIToUTF16("0123456789")); |
| 273 if (!is_card_number_field && |
| 274 autofill_field->Type().GetStorableType() != CREDIT_CARD_NAME_FULL) { |
268 return false; | 275 return false; |
269 } | 276 } |
270 | 277 |
271 static const int kShowScanCreditCardMaxValueLength = 6; | 278 static const int kShowScanCreditCardMaxValueLength = 6; |
272 return field.value.size() <= kShowScanCreditCardMaxValueLength && | 279 return field.value.size() <= kShowScanCreditCardMaxValueLength; |
273 base::ContainsOnlyChars(CreditCard::StripSeparators(field.value), | |
274 base::ASCIIToUTF16("0123456789")); | |
275 } | 280 } |
276 | 281 |
277 bool AutofillManager::ShouldShowCreditCardSigninPromo( | 282 bool AutofillManager::ShouldShowCreditCardSigninPromo( |
278 const FormData& form, | 283 const FormData& form, |
279 const FormFieldData& field) { | 284 const FormFieldData& field) { |
280 if (!IsAutofillCreditCardSigninPromoEnabled()) | 285 if (!IsAutofillCreditCardSigninPromoEnabled()) |
281 return false; | 286 return false; |
282 | 287 |
283 // Check whether we are dealing with a credit card field and whether it's | 288 // Check whether we are dealing with a credit card field and whether it's |
284 // appropriate to show the promo (e.g. the platform is supported). | 289 // appropriate to show the promo (e.g. the platform is supported). |
(...skipping 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2066 if (i > 0) | 2071 if (i > 0) |
2067 fputs("Next oldest form:\n", file); | 2072 fputs("Next oldest form:\n", file); |
2068 } | 2073 } |
2069 fputs("\n", file); | 2074 fputs("\n", file); |
2070 | 2075 |
2071 fclose(file); | 2076 fclose(file); |
2072 } | 2077 } |
2073 #endif // ENABLE_FORM_DEBUG_DUMP | 2078 #endif // ENABLE_FORM_DEBUG_DUMP |
2074 | 2079 |
2075 } // namespace autofill | 2080 } // namespace autofill |
OLD | NEW |