| 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 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 | 614 |
| 615 const std::vector<CreditCard*>& PersonalDataManager::GetLocalCreditCards() | 615 const std::vector<CreditCard*>& PersonalDataManager::GetLocalCreditCards() |
| 616 const { | 616 const { |
| 617 return local_credit_cards_.get(); | 617 return local_credit_cards_.get(); |
| 618 } | 618 } |
| 619 | 619 |
| 620 const std::vector<CreditCard*>& PersonalDataManager::GetCreditCards() const { | 620 const std::vector<CreditCard*>& PersonalDataManager::GetCreditCards() const { |
| 621 credit_cards_.clear(); | 621 credit_cards_.clear(); |
| 622 credit_cards_.insert(credit_cards_.end(), local_credit_cards_.begin(), | 622 credit_cards_.insert(credit_cards_.end(), local_credit_cards_.begin(), |
| 623 local_credit_cards_.end()); | 623 local_credit_cards_.end()); |
| 624 if (IsExperimentalWalletIntegrationEnabled() && | 624 if (pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { |
| 625 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { | |
| 626 credit_cards_.insert(credit_cards_.end(), server_credit_cards_.begin(), | 625 credit_cards_.insert(credit_cards_.end(), server_credit_cards_.begin(), |
| 627 server_credit_cards_.end()); | 626 server_credit_cards_.end()); |
| 628 } | 627 } |
| 629 return credit_cards_; | 628 return credit_cards_; |
| 630 } | 629 } |
| 631 | 630 |
| 632 bool PersonalDataManager::HasServerData() const { | 631 bool PersonalDataManager::HasServerData() const { |
| 633 return !server_credit_cards_.empty() || !server_profiles_.empty(); | 632 return !server_credit_cards_.empty() || !server_profiles_.empty(); |
| 634 } | 633 } |
| 635 | 634 |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 if (default_country_code_.empty()) | 966 if (default_country_code_.empty()) |
| 968 default_country_code_ = CountryCodeForCurrentTimezone(); | 967 default_country_code_ = CountryCodeForCurrentTimezone(); |
| 969 | 968 |
| 970 // Failing that, guess based on locale. | 969 // Failing that, guess based on locale. |
| 971 if (default_country_code_.empty()) | 970 if (default_country_code_.empty()) |
| 972 default_country_code_ = AutofillCountry::CountryCodeForLocale(app_locale()); | 971 default_country_code_ = AutofillCountry::CountryCodeForLocale(app_locale()); |
| 973 | 972 |
| 974 return default_country_code_; | 973 return default_country_code_; |
| 975 } | 974 } |
| 976 | 975 |
| 977 bool PersonalDataManager::IsExperimentalWalletIntegrationEnabled() const { | |
| 978 return pref_service_->GetBoolean(prefs::kAutofillWalletSyncExperimentEnabled); | |
| 979 } | |
| 980 | |
| 981 // static | 976 // static |
| 982 void PersonalDataManager::DedupeCreditCardSuggestions( | 977 void PersonalDataManager::DedupeCreditCardSuggestions( |
| 983 std::list<const CreditCard*>* cards_to_suggest) { | 978 std::list<const CreditCard*>* cards_to_suggest) { |
| 984 for (auto outer_it = cards_to_suggest->begin(); | 979 for (auto outer_it = cards_to_suggest->begin(); |
| 985 outer_it != cards_to_suggest->end(); ++outer_it) { | 980 outer_it != cards_to_suggest->end(); ++outer_it) { |
| 986 // If considering a full server card, look for local cards that are | 981 // If considering a full server card, look for local cards that are |
| 987 // duplicates of it and remove them. | 982 // duplicates of it and remove them. |
| 988 if ((*outer_it)->record_type() == CreditCard::FULL_SERVER_CARD) { | 983 if ((*outer_it)->record_type() == CreditCard::FULL_SERVER_CARD) { |
| 989 for (auto inner_it = cards_to_suggest->begin(); | 984 for (auto inner_it = cards_to_suggest->begin(); |
| 990 inner_it != cards_to_suggest->end();) { | 985 inner_it != cards_to_suggest->end();) { |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1402 | 1397 |
| 1403 imported_credit_card->reset(new CreditCard(candidate_credit_card)); | 1398 imported_credit_card->reset(new CreditCard(candidate_credit_card)); |
| 1404 return true; | 1399 return true; |
| 1405 } | 1400 } |
| 1406 | 1401 |
| 1407 const std::vector<AutofillProfile*>& PersonalDataManager::GetProfiles( | 1402 const std::vector<AutofillProfile*>& PersonalDataManager::GetProfiles( |
| 1408 bool record_metrics) const { | 1403 bool record_metrics) const { |
| 1409 profiles_.clear(); | 1404 profiles_.clear(); |
| 1410 profiles_.insert(profiles_.end(), web_profiles().begin(), | 1405 profiles_.insert(profiles_.end(), web_profiles().begin(), |
| 1411 web_profiles().end()); | 1406 web_profiles().end()); |
| 1412 if (IsExperimentalWalletIntegrationEnabled() && | 1407 if (pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { |
| 1413 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { | |
| 1414 profiles_.insert( | 1408 profiles_.insert( |
| 1415 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); | 1409 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); |
| 1416 } | 1410 } |
| 1417 return profiles_; | 1411 return profiles_; |
| 1418 } | 1412 } |
| 1419 | 1413 |
| 1420 } // namespace autofill | 1414 } // namespace autofill |
| OLD | NEW |