| 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_field.h" | 5 #include "components/autofill/core/browser/autofill_field.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/i18n/string_search.h" | 10 #include "base/i18n/string_search.h" |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 // Use the html type specified by the website unless it is unrecognized and | 499 // Use the html type specified by the website unless it is unrecognized and |
| 500 // autofill predicts a credit card type. | 500 // autofill predicts a credit card type. |
| 501 if (html_type_ != HTML_TYPE_UNSPECIFIED && | 501 if (html_type_ != HTML_TYPE_UNSPECIFIED && |
| 502 !(html_type_ == HTML_TYPE_UNRECOGNIZED && IsCreditCardPrediction())) { | 502 !(html_type_ == HTML_TYPE_UNRECOGNIZED && IsCreditCardPrediction())) { |
| 503 return AutofillType(html_type_, html_mode_); | 503 return AutofillType(html_type_, html_mode_); |
| 504 } | 504 } |
| 505 | 505 |
| 506 if (server_type_ != NO_SERVER_DATA) { | 506 if (server_type_ != NO_SERVER_DATA) { |
| 507 // See http://crbug.com/429236 for background on why we might not always | 507 // See http://crbug.com/429236 for background on why we might not always |
| 508 // believe the server. | 508 // believe the server. |
| 509 // See http://crbug.com/441488 for potential improvements to the server | 509 // TODO(http://crbug.com/589129) investigate how well the server is doing in |
| 510 // which may obviate the need for this logic. | 510 // regard to credit card predictions. |
| 511 bool believe_server = | 511 bool believe_server = |
| 512 !(server_type_ == NAME_FULL && heuristic_type_ == CREDIT_CARD_NAME) && | 512 !(server_type_ == NAME_FULL && |
| 513 !(server_type_ == CREDIT_CARD_NAME && heuristic_type_ == NAME_FULL) && | 513 heuristic_type_ == CREDIT_CARD_NAME_FULL) && |
| 514 !(server_type_ == CREDIT_CARD_NAME_FULL && |
| 515 heuristic_type_ == NAME_FULL) && |
| 516 !(server_type_ == NAME_FIRST && |
| 517 heuristic_type_ == CREDIT_CARD_NAME_FIRST) && |
| 518 !(server_type_ == NAME_LAST && |
| 519 heuristic_type_ == CREDIT_CARD_NAME_LAST) && |
| 514 // CVC is sometimes type="password", which tricks the server. | 520 // CVC is sometimes type="password", which tricks the server. |
| 515 // See http://crbug.com/469007 | 521 // See http://crbug.com/469007 |
| 516 !(AutofillType(server_type_).group() == PASSWORD_FIELD && | 522 !(AutofillType(server_type_).group() == PASSWORD_FIELD && |
| 517 heuristic_type_ == CREDIT_CARD_VERIFICATION_CODE); | 523 heuristic_type_ == CREDIT_CARD_VERIFICATION_CODE); |
| 518 if (believe_server) | 524 if (believe_server) |
| 519 return AutofillType(server_type_); | 525 return AutofillType(server_type_); |
| 520 } | 526 } |
| 521 | 527 |
| 522 return AutofillType(heuristic_type_); | 528 return AutofillType(heuristic_type_); |
| 523 } | 529 } |
| 524 | 530 |
| 525 bool AutofillField::IsEmpty() const { | 531 bool AutofillField::IsEmpty() const { |
| 526 return value.empty(); | 532 return value.empty(); |
| 527 } | 533 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 } | 642 } |
| 637 return false; | 643 return false; |
| 638 } | 644 } |
| 639 | 645 |
| 640 bool AutofillField::IsCreditCardPrediction() const { | 646 bool AutofillField::IsCreditCardPrediction() const { |
| 641 return AutofillType(server_type_).group() == CREDIT_CARD || | 647 return AutofillType(server_type_).group() == CREDIT_CARD || |
| 642 AutofillType(heuristic_type_).group() == CREDIT_CARD; | 648 AutofillType(heuristic_type_).group() == CREDIT_CARD; |
| 643 } | 649 } |
| 644 | 650 |
| 645 } // namespace autofill | 651 } // namespace autofill |
| OLD | NEW |