| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/autofill/personal_data_manager.h" | 5 #include "chrome/browser/autofill/personal_data_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 | 698 |
| 699 // Add the new profiles to the web database. Don't add a duplicate. | 699 // Add the new profiles to the web database. Don't add a duplicate. |
| 700 for (std::vector<AutofillProfile>::iterator iter = profiles->begin(); | 700 for (std::vector<AutofillProfile>::iterator iter = profiles->begin(); |
| 701 iter != profiles->end(); ++iter) { | 701 iter != profiles->end(); ++iter) { |
| 702 if (!FindByGUID<AutofillProfile>(web_profiles_, iter->guid()) && | 702 if (!FindByGUID<AutofillProfile>(web_profiles_, iter->guid()) && |
| 703 !FindByContents(web_profiles_, *iter)) | 703 !FindByContents(web_profiles_, *iter)) |
| 704 wds->AddAutofillProfile(*iter); | 704 wds->AddAutofillProfile(*iter); |
| 705 } | 705 } |
| 706 | 706 |
| 707 // Copy in the new profiles. | 707 // Copy in the new profiles. |
| 708 web_profiles_.reset(); | 708 web_profiles_.clear(); |
| 709 for (std::vector<AutofillProfile>::iterator iter = profiles->begin(); | 709 for (std::vector<AutofillProfile>::iterator iter = profiles->begin(); |
| 710 iter != profiles->end(); ++iter) { | 710 iter != profiles->end(); ++iter) { |
| 711 web_profiles_.push_back(new AutofillProfile(*iter)); | 711 web_profiles_.push_back(new AutofillProfile(*iter)); |
| 712 } | 712 } |
| 713 | 713 |
| 714 // Refresh our local cache and send notifications to observers. | 714 // Refresh our local cache and send notifications to observers. |
| 715 Refresh(); | 715 Refresh(); |
| 716 } | 716 } |
| 717 | 717 |
| 718 void PersonalDataManager::SetCreditCards( | 718 void PersonalDataManager::SetCreditCards( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 749 | 749 |
| 750 // Add the new credit cards to the web database. Don't add a duplicate. | 750 // Add the new credit cards to the web database. Don't add a duplicate. |
| 751 for (std::vector<CreditCard>::iterator iter = credit_cards->begin(); | 751 for (std::vector<CreditCard>::iterator iter = credit_cards->begin(); |
| 752 iter != credit_cards->end(); ++iter) { | 752 iter != credit_cards->end(); ++iter) { |
| 753 if (!FindByGUID<CreditCard>(credit_cards_, iter->guid()) && | 753 if (!FindByGUID<CreditCard>(credit_cards_, iter->guid()) && |
| 754 !FindByContents(credit_cards_, *iter)) | 754 !FindByContents(credit_cards_, *iter)) |
| 755 wds->AddCreditCard(*iter); | 755 wds->AddCreditCard(*iter); |
| 756 } | 756 } |
| 757 | 757 |
| 758 // Copy in the new credit cards. | 758 // Copy in the new credit cards. |
| 759 credit_cards_.reset(); | 759 credit_cards_.clear(); |
| 760 for (std::vector<CreditCard>::iterator iter = credit_cards->begin(); | 760 for (std::vector<CreditCard>::iterator iter = credit_cards->begin(); |
| 761 iter != credit_cards->end(); ++iter) { | 761 iter != credit_cards->end(); ++iter) { |
| 762 credit_cards_.push_back(new CreditCard(*iter)); | 762 credit_cards_.push_back(new CreditCard(*iter)); |
| 763 } | 763 } |
| 764 | 764 |
| 765 // Refresh our local cache and send notifications to observers. | 765 // Refresh our local cache and send notifications to observers. |
| 766 Refresh(); | 766 Refresh(); |
| 767 } | 767 } |
| 768 | 768 |
| 769 void PersonalDataManager::LoadProfiles() { | 769 void PersonalDataManager::LoadProfiles() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 797 CancelPendingQuery(&pending_creditcards_query_); | 797 CancelPendingQuery(&pending_creditcards_query_); |
| 798 | 798 |
| 799 pending_creditcards_query_ = web_data_service->GetCreditCards(this); | 799 pending_creditcards_query_ = web_data_service->GetCreditCards(this); |
| 800 } | 800 } |
| 801 | 801 |
| 802 void PersonalDataManager::ReceiveLoadedProfiles(WebDataService::Handle h, | 802 void PersonalDataManager::ReceiveLoadedProfiles(WebDataService::Handle h, |
| 803 const WDTypedResult* result) { | 803 const WDTypedResult* result) { |
| 804 DCHECK_EQ(pending_profiles_query_, h); | 804 DCHECK_EQ(pending_profiles_query_, h); |
| 805 | 805 |
| 806 pending_profiles_query_ = 0; | 806 pending_profiles_query_ = 0; |
| 807 web_profiles_.reset(); | 807 web_profiles_.clear(); |
| 808 | 808 |
| 809 const WDResult<std::vector<AutofillProfile*> >* r = | 809 const WDResult<std::vector<AutofillProfile*> >* r = |
| 810 static_cast<const WDResult<std::vector<AutofillProfile*> >*>(result); | 810 static_cast<const WDResult<std::vector<AutofillProfile*> >*>(result); |
| 811 | 811 |
| 812 std::vector<AutofillProfile*> profiles = r->GetValue(); | 812 std::vector<AutofillProfile*> profiles = r->GetValue(); |
| 813 for (std::vector<AutofillProfile*>::iterator iter = profiles.begin(); | 813 for (std::vector<AutofillProfile*>::iterator iter = profiles.begin(); |
| 814 iter != profiles.end(); ++iter) { | 814 iter != profiles.end(); ++iter) { |
| 815 web_profiles_.push_back(*iter); | 815 web_profiles_.push_back(*iter); |
| 816 } | 816 } |
| 817 | 817 |
| 818 LogProfileCount(); | 818 LogProfileCount(); |
| 819 EmptyMigrationTrash(); | 819 EmptyMigrationTrash(); |
| 820 } | 820 } |
| 821 | 821 |
| 822 void PersonalDataManager::ReceiveLoadedCreditCards( | 822 void PersonalDataManager::ReceiveLoadedCreditCards( |
| 823 WebDataService::Handle h, const WDTypedResult* result) { | 823 WebDataService::Handle h, const WDTypedResult* result) { |
| 824 DCHECK_EQ(pending_creditcards_query_, h); | 824 DCHECK_EQ(pending_creditcards_query_, h); |
| 825 | 825 |
| 826 pending_creditcards_query_ = 0; | 826 pending_creditcards_query_ = 0; |
| 827 credit_cards_.reset(); | 827 credit_cards_.clear(); |
| 828 | 828 |
| 829 const WDResult<std::vector<CreditCard*> >* r = | 829 const WDResult<std::vector<CreditCard*> >* r = |
| 830 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); | 830 static_cast<const WDResult<std::vector<CreditCard*> >*>(result); |
| 831 | 831 |
| 832 std::vector<CreditCard*> credit_cards = r->GetValue(); | 832 std::vector<CreditCard*> credit_cards = r->GetValue(); |
| 833 for (std::vector<CreditCard*>::iterator iter = credit_cards.begin(); | 833 for (std::vector<CreditCard*>::iterator iter = credit_cards.begin(); |
| 834 iter != credit_cards.end(); ++iter) { | 834 iter != credit_cards.end(); ++iter) { |
| 835 credit_cards_.push_back(*iter); | 835 credit_cards_.push_back(*iter); |
| 836 } | 836 } |
| 837 } | 837 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 } | 941 } |
| 942 | 942 |
| 943 const AutofillMetrics* PersonalDataManager::metric_logger() const { | 943 const AutofillMetrics* PersonalDataManager::metric_logger() const { |
| 944 return metric_logger_.get(); | 944 return metric_logger_.get(); |
| 945 } | 945 } |
| 946 | 946 |
| 947 void PersonalDataManager::set_metric_logger( | 947 void PersonalDataManager::set_metric_logger( |
| 948 const AutofillMetrics* metric_logger) { | 948 const AutofillMetrics* metric_logger) { |
| 949 metric_logger_.reset(metric_logger); | 949 metric_logger_.reset(metric_logger); |
| 950 } | 950 } |
| OLD | NEW |