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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 | 668 |
669 const std::vector<CreditCard*>& PersonalDataManager::GetLocalCreditCards() | 669 const std::vector<CreditCard*>& PersonalDataManager::GetLocalCreditCards() |
670 const { | 670 const { |
671 return local_credit_cards_.get(); | 671 return local_credit_cards_.get(); |
672 } | 672 } |
673 | 673 |
674 const std::vector<CreditCard*>& PersonalDataManager::GetCreditCards() const { | 674 const std::vector<CreditCard*>& PersonalDataManager::GetCreditCards() const { |
675 credit_cards_.clear(); | 675 credit_cards_.clear(); |
676 credit_cards_.insert(credit_cards_.end(), local_credit_cards_.begin(), | 676 credit_cards_.insert(credit_cards_.end(), local_credit_cards_.begin(), |
677 local_credit_cards_.end()); | 677 local_credit_cards_.end()); |
678 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 678 if (IsExperimentalWalletIntegrationEnabled() && |
679 switches::kEnableWalletCardImport) && | |
680 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { | 679 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { |
681 credit_cards_.insert(credit_cards_.end(), server_credit_cards_.begin(), | 680 credit_cards_.insert(credit_cards_.end(), server_credit_cards_.begin(), |
682 server_credit_cards_.end()); | 681 server_credit_cards_.end()); |
683 } | 682 } |
684 return credit_cards_; | 683 return credit_cards_; |
685 } | 684 } |
686 | 685 |
687 void PersonalDataManager::Refresh() { | 686 void PersonalDataManager::Refresh() { |
688 LoadProfiles(); | 687 LoadProfiles(); |
689 LoadCreditCards(); | 688 LoadCreditCards(); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 if (default_country_code_.empty()) | 952 if (default_country_code_.empty()) |
954 default_country_code_ = CountryCodeForCurrentTimezone(); | 953 default_country_code_ = CountryCodeForCurrentTimezone(); |
955 | 954 |
956 // Failing that, guess based on locale. | 955 // Failing that, guess based on locale. |
957 if (default_country_code_.empty()) | 956 if (default_country_code_.empty()) |
958 default_country_code_ = AutofillCountry::CountryCodeForLocale(app_locale()); | 957 default_country_code_ = AutofillCountry::CountryCodeForLocale(app_locale()); |
959 | 958 |
960 return default_country_code_; | 959 return default_country_code_; |
961 } | 960 } |
962 | 961 |
| 962 bool PersonalDataManager::IsExperimentalWalletIntegrationEnabled() const { |
| 963 // The feature can be enabled by sync experiment *or* command line flag. |
| 964 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 965 switches::kEnableWalletCardImport) || |
| 966 pref_service_->GetBoolean(prefs::kAutofillWalletSyncExperimentEnabled); |
| 967 } |
| 968 |
963 void PersonalDataManager::SetProfiles(std::vector<AutofillProfile>* profiles) { | 969 void PersonalDataManager::SetProfiles(std::vector<AutofillProfile>* profiles) { |
964 if (is_off_the_record_) | 970 if (is_off_the_record_) |
965 return; | 971 return; |
966 | 972 |
967 // Remove empty profiles from input. | 973 // Remove empty profiles from input. |
968 profiles->erase(std::remove_if(profiles->begin(), profiles->end(), | 974 profiles->erase(std::remove_if(profiles->begin(), profiles->end(), |
969 IsEmptyFunctor<AutofillProfile>(app_locale_)), | 975 IsEmptyFunctor<AutofillProfile>(app_locale_)), |
970 profiles->end()); | 976 profiles->end()); |
971 | 977 |
972 if (!database_.get()) | 978 if (!database_.get()) |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 | 1217 |
1212 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); | 1218 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); |
1213 profiles_.insert( | 1219 profiles_.insert( |
1214 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end()); | 1220 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end()); |
1215 profiles_.insert( | 1221 profiles_.insert( |
1216 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); | 1222 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); |
1217 return profiles_; | 1223 return profiles_; |
1218 } | 1224 } |
1219 | 1225 |
1220 } // namespace autofill | 1226 } // namespace autofill |
OLD | NEW |