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/personal_data_manager.h" | 5 #include "components/autofill/core/browser/personal_data_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 1615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1626 suggestion->backend_id = credit_card->guid(); | 1626 suggestion->backend_id = credit_card->guid(); |
| 1627 suggestion->match = prefix_matched_suggestion | 1627 suggestion->match = prefix_matched_suggestion |
| 1628 ? Suggestion::PREFIX_MATCH | 1628 ? Suggestion::PREFIX_MATCH |
| 1629 : Suggestion::SUBSTRING_MATCH; | 1629 : Suggestion::SUBSTRING_MATCH; |
| 1630 | 1630 |
| 1631 // If the value is the card number, the label is the expiration date. | 1631 // If the value is the card number, the label is the expiration date. |
| 1632 // Otherwise the label is the card number, or if that is empty the | 1632 // Otherwise the label is the card number, or if that is empty the |
| 1633 // cardholder name. The label should never repeat the value. | 1633 // cardholder name. The label should never repeat the value. |
| 1634 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { | 1634 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { |
| 1635 suggestion->value = credit_card->TypeAndLastFourDigits(); | 1635 suggestion->value = credit_card->TypeAndLastFourDigits(); |
| 1636 suggestion->label = credit_card->GetInfo( | 1636 if (IsAutofillCreditCardLastUsedDateDisplayExperimentEnabled() && |
| 1637 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); | 1637 !IsKeyboardAccessoryEnabled()) { |
| 1638 if (ShowExpirationDateInAutofillCreditCardLastUsedDate()) { | |
| 1639 suggestion->label = credit_card->GetInfo( | |
| 1640 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); | |
| 1641 } | |
| 1642 if (suggestion->label.empty()) { | |
| 1643 suggestion->label = credit_card->GetLastUsedDateForDisplay( | |
| 1644 ShowExpirationDateInAutofillCreditCardLastUsedDate(), | |
| 1645 ShowTimeDetailInAutofillCreditCardLastUsedDate()); | |
| 1646 } else { | |
| 1647 suggestion->label.append(credit_card->GetLastUsedDateForDisplay( | |
| 1648 ShowExpirationDateInAutofillCreditCardLastUsedDate(), | |
| 1649 ShowTimeDetailInAutofillCreditCardLastUsedDate())); | |
|
jungshik at Google
2017/01/23 21:43:24
This kind of concatenating strings (Exp. date + La
jiahuiguo
2017/01/26 05:46:13
Done.
| |
| 1650 } | |
| 1651 } else { | |
| 1652 suggestion->label = credit_card->GetInfo( | |
| 1653 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); | |
| 1654 } | |
| 1638 if (IsAutofillCreditCardPopupLayoutExperimentEnabled()) | 1655 if (IsAutofillCreditCardPopupLayoutExperimentEnabled()) |
| 1639 ModifyAutofillCreditCardSuggestion(suggestion); | 1656 ModifyAutofillCreditCardSuggestion(suggestion); |
| 1640 } else if (credit_card->number().empty()) { | 1657 } else if (credit_card->number().empty()) { |
| 1641 if (type.GetStorableType() != CREDIT_CARD_NAME_FULL) { | 1658 if (type.GetStorableType() != CREDIT_CARD_NAME_FULL) { |
| 1642 suggestion->label = credit_card->GetInfo( | 1659 suggestion->label = credit_card->GetInfo( |
| 1643 AutofillType(CREDIT_CARD_NAME_FULL), app_locale_); | 1660 AutofillType(CREDIT_CARD_NAME_FULL), app_locale_); |
| 1644 } | 1661 } |
| 1645 } else { | 1662 } else { |
| 1646 #if defined(OS_ANDROID) | 1663 #if defined(OS_ANDROID) |
| 1647 // Since Android places the label on its own row, there's more | 1664 // Since Android places the label on its own row, there's more |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1861 } | 1878 } |
| 1862 | 1879 |
| 1863 // If the card was modified, apply the changes to the database. | 1880 // If the card was modified, apply the changes to the database. |
| 1864 if (was_modified) { | 1881 if (was_modified) { |
| 1865 database_->UpdateCreditCard(*credit_card); | 1882 database_->UpdateCreditCard(*credit_card); |
| 1866 } | 1883 } |
| 1867 } | 1884 } |
| 1868 } | 1885 } |
| 1869 | 1886 |
| 1870 } // namespace autofill | 1887 } // namespace autofill |
| OLD | NEW |