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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 } // namespace | 220 } // namespace |
221 | 221 |
222 PersonalDataManager::PersonalDataManager(const std::string& app_locale) | 222 PersonalDataManager::PersonalDataManager(const std::string& app_locale) |
223 : database_(NULL), | 223 : database_(NULL), |
224 is_data_loaded_(false), | 224 is_data_loaded_(false), |
225 pending_profiles_query_(0), | 225 pending_profiles_query_(0), |
226 pending_server_profiles_query_(0), | 226 pending_server_profiles_query_(0), |
227 pending_creditcards_query_(0), | 227 pending_creditcards_query_(0), |
228 pending_server_creditcards_query_(0), | 228 pending_server_creditcards_query_(0), |
| 229 test_force_wallet_card_sync_enabled_(false), |
229 app_locale_(app_locale), | 230 app_locale_(app_locale), |
230 pref_service_(NULL), | 231 pref_service_(NULL), |
231 is_off_the_record_(false), | 232 is_off_the_record_(false), |
232 has_logged_profile_count_(false) {} | 233 has_logged_profile_count_(false) {} |
233 | 234 |
234 void PersonalDataManager::Init(scoped_refptr<AutofillWebDataService> database, | 235 void PersonalDataManager::Init(scoped_refptr<AutofillWebDataService> database, |
235 PrefService* pref_service, | 236 PrefService* pref_service, |
236 bool is_off_the_record) { | 237 bool is_off_the_record) { |
237 database_ = database; | 238 database_ = database; |
238 SetPrefService(pref_service); | 239 SetPrefService(pref_service); |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 | 669 |
669 const std::vector<CreditCard*>& PersonalDataManager::GetLocalCreditCards() | 670 const std::vector<CreditCard*>& PersonalDataManager::GetLocalCreditCards() |
670 const { | 671 const { |
671 return local_credit_cards_.get(); | 672 return local_credit_cards_.get(); |
672 } | 673 } |
673 | 674 |
674 const std::vector<CreditCard*>& PersonalDataManager::GetCreditCards() const { | 675 const std::vector<CreditCard*>& PersonalDataManager::GetCreditCards() const { |
675 credit_cards_.clear(); | 676 credit_cards_.clear(); |
676 credit_cards_.insert(credit_cards_.end(), local_credit_cards_.begin(), | 677 credit_cards_.insert(credit_cards_.end(), local_credit_cards_.begin(), |
677 local_credit_cards_.end()); | 678 local_credit_cards_.end()); |
678 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 679 if (test_force_wallet_card_sync_enabled_ || |
679 switches::kEnableWalletCardImport) && | 680 (base::CommandLine::ForCurrentProcess()->HasSwitch( |
680 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { | 681 switches::kEnableWalletCardImport) && |
| 682 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled))) { |
681 credit_cards_.insert(credit_cards_.end(), server_credit_cards_.begin(), | 683 credit_cards_.insert(credit_cards_.end(), server_credit_cards_.begin(), |
682 server_credit_cards_.end()); | 684 server_credit_cards_.end()); |
683 } | 685 } |
684 return credit_cards_; | 686 return credit_cards_; |
685 } | 687 } |
686 | 688 |
687 void PersonalDataManager::Refresh() { | 689 void PersonalDataManager::Refresh() { |
688 LoadProfiles(); | 690 LoadProfiles(); |
689 LoadCreditCards(); | 691 LoadCreditCards(); |
690 } | 692 } |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 return std::string(); | 1191 return std::string(); |
1190 } | 1192 } |
1191 | 1193 |
1192 void PersonalDataManager::EnabledPrefChanged() { | 1194 void PersonalDataManager::EnabledPrefChanged() { |
1193 default_country_code_.clear(); | 1195 default_country_code_.clear(); |
1194 NotifyPersonalDataChanged(); | 1196 NotifyPersonalDataChanged(); |
1195 } | 1197 } |
1196 | 1198 |
1197 const std::vector<AutofillProfile*>& PersonalDataManager::GetProfiles( | 1199 const std::vector<AutofillProfile*>& PersonalDataManager::GetProfiles( |
1198 bool record_metrics) const { | 1200 bool record_metrics) const { |
| 1201 bool use_auxiliary_profiles = |
1199 #if defined(OS_MACOSX) && !defined(OS_IOS) | 1202 #if defined(OS_MACOSX) && !defined(OS_IOS) |
1200 if (!pref_service_->GetBoolean(prefs::kAutofillUseMacAddressBook)) | 1203 pref_service_->GetBoolean(prefs::kAutofillUseMacAddressBook); |
1201 return web_profiles(); | |
1202 #else | 1204 #else |
1203 if (!pref_service_->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled)) | 1205 pref_service_->GetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled); |
1204 return web_profiles(); | |
1205 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 1206 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
1206 | 1207 |
1207 profiles_.clear(); | 1208 profiles_.clear(); |
1208 | 1209 |
1209 // Populates |auxiliary_profiles_|. | 1210 // Populates |auxiliary_profiles_|. |
1210 LoadAuxiliaryProfiles(record_metrics); | 1211 if (use_auxiliary_profiles) { |
| 1212 LoadAuxiliaryProfiles(record_metrics); |
| 1213 } |
1211 | 1214 |
1212 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); | 1215 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); |
1213 profiles_.insert( | 1216 if (use_auxiliary_profiles) { |
1214 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end()); | 1217 profiles_.insert( |
| 1218 profiles_.end(), auxiliary_profiles_.begin(), |
| 1219 auxiliary_profiles_.end()); |
| 1220 } |
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 |