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 <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <iterator> | 9 #include <iterator> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" | 31 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" |
32 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fo
rmatter.h" | 32 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fo
rmatter.h" |
33 | 33 |
34 namespace autofill { | 34 namespace autofill { |
35 namespace { | 35 namespace { |
36 | 36 |
37 using ::i18n::addressinput::AddressField; | 37 using ::i18n::addressinput::AddressField; |
38 using ::i18n::addressinput::GetStreetAddressLinesAsSingleLine; | 38 using ::i18n::addressinput::GetStreetAddressLinesAsSingleLine; |
39 using ::i18n::addressinput::STREET_ADDRESS; | 39 using ::i18n::addressinput::STREET_ADDRESS; |
40 | 40 |
41 const base::string16::value_type kCreditCardPrefix[] = {'*', 0}; | |
42 | |
43 template<typename T> | 41 template<typename T> |
44 class FormGroupMatchesByGUIDFunctor { | 42 class FormGroupMatchesByGUIDFunctor { |
45 public: | 43 public: |
46 explicit FormGroupMatchesByGUIDFunctor(const std::string& guid) | 44 explicit FormGroupMatchesByGUIDFunctor(const std::string& guid) |
47 : guid_(guid) { | 45 : guid_(guid) { |
48 } | 46 } |
49 | 47 |
50 bool operator()(const T& form_group) { | 48 bool operator()(const T& form_group) { |
51 return form_group.guid() == guid_; | 49 return form_group.guid() == guid_; |
52 } | 50 } |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { | 864 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { |
867 suggestion->value = credit_card->TypeAndLastFourDigits(); | 865 suggestion->value = credit_card->TypeAndLastFourDigits(); |
868 suggestion->label = credit_card->GetInfo( | 866 suggestion->label = credit_card->GetInfo( |
869 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); | 867 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); |
870 } else if (credit_card->number().empty()) { | 868 } else if (credit_card->number().empty()) { |
871 if (type.GetStorableType() != CREDIT_CARD_NAME) { | 869 if (type.GetStorableType() != CREDIT_CARD_NAME) { |
872 suggestion->label = | 870 suggestion->label = |
873 credit_card->GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_); | 871 credit_card->GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_); |
874 } | 872 } |
875 } else { | 873 } else { |
876 suggestion->label = kCreditCardPrefix; | 874 #if defined(OS_ANDROID) |
| 875 // Since Android places the label on its own row, there's more horizontal |
| 876 // space to work with. Show "Amex - 1234" rather than desktop's "*1234". |
| 877 suggestion->label = credit_card->TypeAndLastFourDigits(); |
| 878 #else |
| 879 suggestion->label = base::ASCIIToUTF16("*"); |
877 suggestion->label.append(credit_card->LastFourDigits()); | 880 suggestion->label.append(credit_card->LastFourDigits()); |
| 881 #endif |
878 } | 882 } |
879 } | 883 } |
880 return suggestions; | 884 return suggestions; |
881 } | 885 } |
882 | 886 |
883 bool PersonalDataManager::IsAutofillEnabled() const { | 887 bool PersonalDataManager::IsAutofillEnabled() const { |
884 DCHECK(pref_service_); | 888 DCHECK(pref_service_); |
885 return pref_service_->GetBoolean(prefs::kAutofillEnabled); | 889 return pref_service_->GetBoolean(prefs::kAutofillEnabled); |
886 } | 890 } |
887 | 891 |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 } | 1266 } |
1263 if (IsExperimentalWalletIntegrationEnabled() && | 1267 if (IsExperimentalWalletIntegrationEnabled() && |
1264 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { | 1268 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { |
1265 profiles_.insert( | 1269 profiles_.insert( |
1266 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); | 1270 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); |
1267 } | 1271 } |
1268 return profiles_; | 1272 return profiles_; |
1269 } | 1273 } |
1270 | 1274 |
1271 } // namespace autofill | 1275 } // namespace autofill |
OLD | NEW |