Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: components/autofill/browser/personal_data_manager.cc

Issue 13928035: WIP Component build of autofill Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make windows compiling Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "components/autofill/browser/personal_data_manager.h" 5 #include "components/autofill/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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 PersonalDataManager::PersonalDataManager(const std::string& app_locale) 133 PersonalDataManager::PersonalDataManager(const std::string& app_locale)
134 : browser_context_(NULL), 134 : browser_context_(NULL),
135 is_data_loaded_(false), 135 is_data_loaded_(false),
136 pending_profiles_query_(0), 136 pending_profiles_query_(0),
137 pending_creditcards_query_(0), 137 pending_creditcards_query_(0),
138 app_locale_(app_locale), 138 app_locale_(app_locale),
139 metric_logger_(new AutofillMetrics), 139 metric_logger_(new AutofillMetrics),
140 has_logged_profile_count_(false) {} 140 has_logged_profile_count_(false) {}
141 141
142 void PersonalDataManager::Init(BrowserContext* browser_context) { 142 void PersonalDataManager::Init(BrowserContext* browser_context,
143 AutofillWebDataService* autofill_webdata) {
143 browser_context_ = browser_context; 144 browser_context_ = browser_context;
144 metric_logger_->LogIsAutofillEnabledAtStartup(IsAutofillEnabled()); 145 metric_logger_->LogIsAutofillEnabledAtStartup(IsAutofillEnabled());
145 146
146 scoped_refptr<AutofillWebDataService> autofill_data( 147 // WebDataService may not be available in tests.
147 AutofillWebDataService::FromBrowserContext(browser_context_)); 148 if (!autofill_webdata)
149 return;
148 150
149 // WebDataService may not be available in tests. 151 autofill_webdata_ = autofill_webdata;
150 if (!autofill_data.get())
151 return;
152 152
153 LoadProfiles(); 153 LoadProfiles();
154 LoadCreditCards(); 154 LoadCreditCards();
155 155
156 autofill_data->AddObserver(this); 156 autofill_webdata_->AddObserver(this);
157 } 157 }
158 158
159 PersonalDataManager::~PersonalDataManager() { 159 PersonalDataManager::~PersonalDataManager() {
160 CancelPendingQuery(&pending_profiles_query_); 160 CancelPendingQuery(&pending_profiles_query_);
161 CancelPendingQuery(&pending_creditcards_query_); 161 CancelPendingQuery(&pending_creditcards_query_);
162 162
163 if (!browser_context_) 163 if (!browser_context_)
164 return; 164 return;
165 165
166 scoped_refptr<AutofillWebDataService> autofill_data( 166 if (autofill_webdata_.get())
167 AutofillWebDataService::FromBrowserContext(browser_context_)); 167 autofill_webdata_->RemoveObserver(this);
168 if (autofill_data.get())
169 autofill_data->RemoveObserver(this);
170 } 168 }
171 169
172 void PersonalDataManager::OnWebDataServiceRequestDone( 170 void PersonalDataManager::OnWebDataServiceRequestDone(
173 WebDataServiceBase::Handle h, 171 WebDataServiceBase::Handle h,
174 const WDTypedResult* result) { 172 const WDTypedResult* result) {
175 DCHECK(pending_profiles_query_ || pending_creditcards_query_); 173 DCHECK(pending_profiles_query_ || pending_creditcards_query_);
176 174
177 if (!result) { 175 if (!result) {
178 // Error from the web database. 176 // Error from the web database.
179 if (h == pending_creditcards_query_) 177 if (h == pending_creditcards_query_)
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 if (browser_context_->IsOffTheRecord()) 356 if (browser_context_->IsOffTheRecord())
359 return; 357 return;
360 358
361 if (profile.IsEmpty(app_locale_)) 359 if (profile.IsEmpty(app_locale_))
362 return; 360 return;
363 361
364 // Don't add an existing profile. 362 // Don't add an existing profile.
365 if (FindByGUID<AutofillProfile>(web_profiles_, profile.guid())) 363 if (FindByGUID<AutofillProfile>(web_profiles_, profile.guid()))
366 return; 364 return;
367 365
368 scoped_refptr<AutofillWebDataService> autofill_data( 366 if (!autofill_webdata_.get())
369 AutofillWebDataService::FromBrowserContext(browser_context_));
370 if (!autofill_data.get())
371 return; 367 return;
372 368
373 // Don't add a duplicate. 369 // Don't add a duplicate.
374 if (FindByContents(web_profiles_, profile)) 370 if (FindByContents(web_profiles_, profile))
375 return; 371 return;
376 372
377 // Add the new profile to the web database. 373 // Add the new profile to the web database.
378 autofill_data->AddAutofillProfile(profile); 374 autofill_webdata_->AddAutofillProfile(profile);
379 375
380 // Refresh our local cache and send notifications to observers. 376 // Refresh our local cache and send notifications to observers.
381 Refresh(); 377 Refresh();
382 } 378 }
383 379
384 void PersonalDataManager::UpdateProfile(const AutofillProfile& profile) { 380 void PersonalDataManager::UpdateProfile(const AutofillProfile& profile) {
385 if (browser_context_->IsOffTheRecord()) 381 if (browser_context_->IsOffTheRecord())
386 return; 382 return;
387 383
388 if (!FindByGUID<AutofillProfile>(web_profiles_, profile.guid())) 384 if (!FindByGUID<AutofillProfile>(web_profiles_, profile.guid()))
389 return; 385 return;
390 386
391 if (profile.IsEmpty(app_locale_)) { 387 if (profile.IsEmpty(app_locale_)) {
392 RemoveByGUID(profile.guid()); 388 RemoveByGUID(profile.guid());
393 return; 389 return;
394 } 390 }
395 391
396 scoped_refptr<AutofillWebDataService> autofill_data( 392 if (!autofill_webdata_.get())
397 AutofillWebDataService::FromBrowserContext(browser_context_));
398 if (!autofill_data.get())
399 return; 393 return;
400 394
401 // Make the update. 395 // Make the update.
402 autofill_data->UpdateAutofillProfile(profile); 396 autofill_webdata_->UpdateAutofillProfile(profile);
403 397
404 // Refresh our local cache and send notifications to observers. 398 // Refresh our local cache and send notifications to observers.
405 Refresh(); 399 Refresh();
406 } 400 }
407 401
408 AutofillProfile* PersonalDataManager::GetProfileByGUID( 402 AutofillProfile* PersonalDataManager::GetProfileByGUID(
409 const std::string& guid) { 403 const std::string& guid) {
410 const std::vector<AutofillProfile*>& profiles = GetProfiles(); 404 const std::vector<AutofillProfile*>& profiles = GetProfiles();
411 for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin(); 405 for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin();
412 iter != profiles.end(); ++iter) { 406 iter != profiles.end(); ++iter) {
413 if ((*iter)->guid() == guid) 407 if ((*iter)->guid() == guid)
414 return *iter; 408 return *iter;
415 } 409 }
416 return NULL; 410 return NULL;
417 } 411 }
418 412
419 void PersonalDataManager::AddCreditCard(const CreditCard& credit_card) { 413 void PersonalDataManager::AddCreditCard(const CreditCard& credit_card) {
420 if (browser_context_->IsOffTheRecord()) 414 if (browser_context_->IsOffTheRecord())
421 return; 415 return;
422 416
423 if (credit_card.IsEmpty(app_locale_)) 417 if (credit_card.IsEmpty(app_locale_))
424 return; 418 return;
425 419
426 if (FindByGUID<CreditCard>(credit_cards_, credit_card.guid())) 420 if (FindByGUID<CreditCard>(credit_cards_, credit_card.guid()))
427 return; 421 return;
428 422
429 scoped_refptr<AutofillWebDataService> autofill_data( 423 if (!autofill_webdata_.get())
430 AutofillWebDataService::FromBrowserContext(browser_context_));
431 if (!autofill_data.get())
432 return; 424 return;
433 425
434 // Don't add a duplicate. 426 // Don't add a duplicate.
435 if (FindByContents(credit_cards_, credit_card)) 427 if (FindByContents(credit_cards_, credit_card))
436 return; 428 return;
437 429
438 // Add the new credit card to the web database. 430 // Add the new credit card to the web database.
439 autofill_data->AddCreditCard(credit_card); 431 autofill_webdata_->AddCreditCard(credit_card);
440 432
441 // Refresh our local cache and send notifications to observers. 433 // Refresh our local cache and send notifications to observers.
442 Refresh(); 434 Refresh();
443 } 435 }
444 436
445 void PersonalDataManager::UpdateCreditCard(const CreditCard& credit_card) { 437 void PersonalDataManager::UpdateCreditCard(const CreditCard& credit_card) {
446 if (browser_context_->IsOffTheRecord()) 438 if (browser_context_->IsOffTheRecord())
447 return; 439 return;
448 440
449 if (!FindByGUID<CreditCard>(credit_cards_, credit_card.guid())) 441 if (!FindByGUID<CreditCard>(credit_cards_, credit_card.guid()))
450 return; 442 return;
451 443
452 if (credit_card.IsEmpty(app_locale_)) { 444 if (credit_card.IsEmpty(app_locale_)) {
453 RemoveByGUID(credit_card.guid()); 445 RemoveByGUID(credit_card.guid());
454 return; 446 return;
455 } 447 }
456 448
457 scoped_refptr<AutofillWebDataService> autofill_data( 449 if (!autofill_webdata_.get())
458 AutofillWebDataService::FromBrowserContext(browser_context_));
459 if (!autofill_data.get())
460 return; 450 return;
461 451
462 // Make the update. 452 // Make the update.
463 autofill_data->UpdateCreditCard(credit_card); 453 autofill_webdata_->UpdateCreditCard(credit_card);
464 454
465 // Refresh our local cache and send notifications to observers. 455 // Refresh our local cache and send notifications to observers.
466 Refresh(); 456 Refresh();
467 } 457 }
468 458
469 void PersonalDataManager::RemoveByGUID(const std::string& guid) { 459 void PersonalDataManager::RemoveByGUID(const std::string& guid) {
470 if (browser_context_->IsOffTheRecord()) 460 if (browser_context_->IsOffTheRecord())
471 return; 461 return;
472 462
473 bool is_credit_card = FindByGUID<CreditCard>(credit_cards_, guid); 463 bool is_credit_card = FindByGUID<CreditCard>(credit_cards_, guid);
474 bool is_profile = !is_credit_card && 464 bool is_profile = !is_credit_card &&
475 FindByGUID<AutofillProfile>(web_profiles_, guid); 465 FindByGUID<AutofillProfile>(web_profiles_, guid);
476 if (!is_credit_card && !is_profile) 466 if (!is_credit_card && !is_profile)
477 return; 467 return;
478 468
479 scoped_refptr<AutofillWebDataService> autofill_data( 469 if (!autofill_webdata_.get())
480 AutofillWebDataService::FromBrowserContext(browser_context_));
481 if (!autofill_data.get())
482 return; 470 return;
483 471
484 if (is_credit_card) 472 if (is_credit_card)
485 autofill_data->RemoveCreditCard(guid); 473 autofill_webdata_->RemoveCreditCard(guid);
486 else 474 else
487 autofill_data->RemoveAutofillProfile(guid); 475 autofill_webdata_->RemoveAutofillProfile(guid);
488 476
489 // Refresh our local cache and send notifications to observers. 477 // Refresh our local cache and send notifications to observers.
490 Refresh(); 478 Refresh();
491 } 479 }
492 480
493 CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) { 481 CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) {
494 for (std::vector<CreditCard*>::iterator iter = credit_cards_.begin(); 482 for (std::vector<CreditCard*>::iterator iter = credit_cards_.begin();
495 iter != credit_cards_.end(); ++iter) { 483 iter != credit_cards_.end(); ++iter) {
496 if ((*iter)->guid() == guid) 484 if ((*iter)->guid() == guid)
497 return *iter; 485 return *iter;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 738
751 // Ensure that profile labels are up to date. Currently, sync relies on 739 // Ensure that profile labels are up to date. Currently, sync relies on
752 // labels to identify a profile. 740 // labels to identify a profile.
753 // TODO(dhollowa): We need to deprecate labels and update the way sync 741 // TODO(dhollowa): We need to deprecate labels and update the way sync
754 // identifies profiles. 742 // identifies profiles.
755 std::vector<AutofillProfile*> profile_pointers(profiles->size()); 743 std::vector<AutofillProfile*> profile_pointers(profiles->size());
756 std::transform(profiles->begin(), profiles->end(), profile_pointers.begin(), 744 std::transform(profiles->begin(), profiles->end(), profile_pointers.begin(),
757 address_of<AutofillProfile>); 745 address_of<AutofillProfile>);
758 AutofillProfile::AdjustInferredLabels(&profile_pointers); 746 AutofillProfile::AdjustInferredLabels(&profile_pointers);
759 747
760 scoped_refptr<AutofillWebDataService> autofill_data( 748 if (!autofill_webdata_.get())
761 AutofillWebDataService::FromBrowserContext(browser_context_));
762 if (!autofill_data.get())
763 return; 749 return;
764 750
765 // Any profiles that are not in the new profile list should be removed from 751 // Any profiles that are not in the new profile list should be removed from
766 // the web database. 752 // the web database.
767 for (std::vector<AutofillProfile*>::const_iterator iter = 753 for (std::vector<AutofillProfile*>::const_iterator iter =
768 web_profiles_.begin(); 754 web_profiles_.begin();
769 iter != web_profiles_.end(); ++iter) { 755 iter != web_profiles_.end(); ++iter) {
770 if (!FindByGUID<AutofillProfile>(*profiles, (*iter)->guid())) 756 if (!FindByGUID<AutofillProfile>(*profiles, (*iter)->guid()))
771 autofill_data->RemoveAutofillProfile((*iter)->guid()); 757 autofill_webdata_->RemoveAutofillProfile((*iter)->guid());
772 } 758 }
773 759
774 // Update the web database with the existing profiles. 760 // Update the web database with the existing profiles.
775 for (std::vector<AutofillProfile>::iterator iter = profiles->begin(); 761 for (std::vector<AutofillProfile>::iterator iter = profiles->begin();
776 iter != profiles->end(); ++iter) { 762 iter != profiles->end(); ++iter) {
777 if (FindByGUID<AutofillProfile>(web_profiles_, iter->guid())) 763 if (FindByGUID<AutofillProfile>(web_profiles_, iter->guid()))
778 autofill_data->UpdateAutofillProfile(*iter); 764 autofill_webdata_->UpdateAutofillProfile(*iter);
779 } 765 }
780 766
781 // Add the new profiles to the web database. Don't add a duplicate. 767 // Add the new profiles to the web database. Don't add a duplicate.
782 for (std::vector<AutofillProfile>::iterator iter = profiles->begin(); 768 for (std::vector<AutofillProfile>::iterator iter = profiles->begin();
783 iter != profiles->end(); ++iter) { 769 iter != profiles->end(); ++iter) {
784 if (!FindByGUID<AutofillProfile>(web_profiles_, iter->guid()) && 770 if (!FindByGUID<AutofillProfile>(web_profiles_, iter->guid()) &&
785 !FindByContents(web_profiles_, *iter)) 771 !FindByContents(web_profiles_, *iter))
786 autofill_data->AddAutofillProfile(*iter); 772 autofill_webdata_->AddAutofillProfile(*iter);
787 } 773 }
788 774
789 // Copy in the new profiles. 775 // Copy in the new profiles.
790 web_profiles_.clear(); 776 web_profiles_.clear();
791 for (std::vector<AutofillProfile>::iterator iter = profiles->begin(); 777 for (std::vector<AutofillProfile>::iterator iter = profiles->begin();
792 iter != profiles->end(); ++iter) { 778 iter != profiles->end(); ++iter) {
793 web_profiles_.push_back(new AutofillProfile(*iter)); 779 web_profiles_.push_back(new AutofillProfile(*iter));
794 } 780 }
795 781
796 // Refresh our local cache and send notifications to observers. 782 // Refresh our local cache and send notifications to observers.
797 Refresh(); 783 Refresh();
798 } 784 }
799 785
800 void PersonalDataManager::SetCreditCards( 786 void PersonalDataManager::SetCreditCards(
801 std::vector<CreditCard>* credit_cards) { 787 std::vector<CreditCard>* credit_cards) {
802 if (browser_context_->IsOffTheRecord()) 788 if (browser_context_->IsOffTheRecord())
803 return; 789 return;
804 790
805 // Remove empty credit cards from input. 791 // Remove empty credit cards from input.
806 for (std::vector<CreditCard>::iterator it = credit_cards->begin(); 792 for (std::vector<CreditCard>::iterator it = credit_cards->begin();
807 it != credit_cards->end();) { 793 it != credit_cards->end();) {
808 if (it->IsEmpty(app_locale_)) 794 if (it->IsEmpty(app_locale_))
809 credit_cards->erase(it); 795 credit_cards->erase(it);
810 else 796 else
811 it++; 797 it++;
812 } 798 }
813 799
814 scoped_refptr<AutofillWebDataService> autofill_data( 800 if (!autofill_webdata_.get())
815 AutofillWebDataService::FromBrowserContext(browser_context_));
816 if (!autofill_data.get())
817 return; 801 return;
818 802
819 // Any credit cards that are not in the new credit card list should be 803 // Any credit cards that are not in the new credit card list should be
820 // removed. 804 // removed.
821 for (std::vector<CreditCard*>::const_iterator iter = credit_cards_.begin(); 805 for (std::vector<CreditCard*>::const_iterator iter = credit_cards_.begin();
822 iter != credit_cards_.end(); ++iter) { 806 iter != credit_cards_.end(); ++iter) {
823 if (!FindByGUID<CreditCard>(*credit_cards, (*iter)->guid())) 807 if (!FindByGUID<CreditCard>(*credit_cards, (*iter)->guid()))
824 autofill_data->RemoveCreditCard((*iter)->guid()); 808 autofill_webdata_->RemoveCreditCard((*iter)->guid());
825 } 809 }
826 810
827 // Update the web database with the existing credit cards. 811 // Update the web database with the existing credit cards.
828 for (std::vector<CreditCard>::iterator iter = credit_cards->begin(); 812 for (std::vector<CreditCard>::iterator iter = credit_cards->begin();
829 iter != credit_cards->end(); ++iter) { 813 iter != credit_cards->end(); ++iter) {
830 if (FindByGUID<CreditCard>(credit_cards_, iter->guid())) 814 if (FindByGUID<CreditCard>(credit_cards_, iter->guid()))
831 autofill_data->UpdateCreditCard(*iter); 815 autofill_webdata_->UpdateCreditCard(*iter);
832 } 816 }
833 817
834 // Add the new credit cards to the web database. Don't add a duplicate. 818 // Add the new credit cards to the web database. Don't add a duplicate.
835 for (std::vector<CreditCard>::iterator iter = credit_cards->begin(); 819 for (std::vector<CreditCard>::iterator iter = credit_cards->begin();
836 iter != credit_cards->end(); ++iter) { 820 iter != credit_cards->end(); ++iter) {
837 if (!FindByGUID<CreditCard>(credit_cards_, iter->guid()) && 821 if (!FindByGUID<CreditCard>(credit_cards_, iter->guid()) &&
838 !FindByContents(credit_cards_, *iter)) 822 !FindByContents(credit_cards_, *iter))
839 autofill_data->AddCreditCard(*iter); 823 autofill_webdata_->AddCreditCard(*iter);
840 } 824 }
841 825
842 // Copy in the new credit cards. 826 // Copy in the new credit cards.
843 credit_cards_.clear(); 827 credit_cards_.clear();
844 for (std::vector<CreditCard>::iterator iter = credit_cards->begin(); 828 for (std::vector<CreditCard>::iterator iter = credit_cards->begin();
845 iter != credit_cards->end(); ++iter) { 829 iter != credit_cards->end(); ++iter) {
846 credit_cards_.push_back(new CreditCard(*iter)); 830 credit_cards_.push_back(new CreditCard(*iter));
847 } 831 }
848 832
849 // Refresh our local cache and send notifications to observers. 833 // Refresh our local cache and send notifications to observers.
850 Refresh(); 834 Refresh();
851 } 835 }
852 836
853 void PersonalDataManager::LoadProfiles() { 837 void PersonalDataManager::LoadProfiles() {
854 scoped_refptr<AutofillWebDataService> autofill_data( 838 if (!autofill_webdata_.get()) {
855 AutofillWebDataService::FromBrowserContext(browser_context_));
856 if (!autofill_data.get()) {
857 NOTREACHED(); 839 NOTREACHED();
858 return; 840 return;
859 } 841 }
860 842
861 CancelPendingQuery(&pending_profiles_query_); 843 CancelPendingQuery(&pending_profiles_query_);
862 844
863 pending_profiles_query_ = autofill_data->GetAutofillProfiles(this); 845 pending_profiles_query_ = autofill_webdata_->GetAutofillProfiles(this);
864 } 846 }
865 847
866 // Win and Linux implementations do nothing. Mac and Android implementations 848 // Win and Linux implementations do nothing. Mac and Android implementations
867 // fill in the contents of |auxiliary_profiles_|. 849 // fill in the contents of |auxiliary_profiles_|.
868 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 850 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
869 void PersonalDataManager::LoadAuxiliaryProfiles() { 851 void PersonalDataManager::LoadAuxiliaryProfiles() {
870 } 852 }
871 #endif 853 #endif
872 854
873 void PersonalDataManager::LoadCreditCards() { 855 void PersonalDataManager::LoadCreditCards() {
874 scoped_refptr<AutofillWebDataService> autofill_data( 856 if (!autofill_webdata_.get()) {
875 AutofillWebDataService::FromBrowserContext(browser_context_));
876 if (!autofill_data.get()) {
877 NOTREACHED(); 857 NOTREACHED();
878 return; 858 return;
879 } 859 }
880 860
881 CancelPendingQuery(&pending_creditcards_query_); 861 CancelPendingQuery(&pending_creditcards_query_);
882 862
883 pending_creditcards_query_ = autofill_data->GetCreditCards(this); 863 pending_creditcards_query_ = autofill_webdata_->GetCreditCards(this);
884 } 864 }
885 865
886 void PersonalDataManager::ReceiveLoadedProfiles(WebDataServiceBase::Handle h, 866 void PersonalDataManager::ReceiveLoadedProfiles(WebDataServiceBase::Handle h,
887 const WDTypedResult* result) { 867 const WDTypedResult* result) {
888 DCHECK_EQ(pending_profiles_query_, h); 868 DCHECK_EQ(pending_profiles_query_, h);
889 869
890 pending_profiles_query_ = 0; 870 pending_profiles_query_ = 0;
891 web_profiles_.clear(); 871 web_profiles_.clear();
892 872
893 const WDResult<std::vector<AutofillProfile*> >* r = 873 const WDResult<std::vector<AutofillProfile*> >* r =
(...skipping 21 matching lines...) Expand all
915 std::vector<CreditCard*> credit_cards = r->GetValue(); 895 std::vector<CreditCard*> credit_cards = r->GetValue();
916 for (std::vector<CreditCard*>::iterator iter = credit_cards.begin(); 896 for (std::vector<CreditCard*>::iterator iter = credit_cards.begin();
917 iter != credit_cards.end(); ++iter) { 897 iter != credit_cards.end(); ++iter) {
918 credit_cards_.push_back(*iter); 898 credit_cards_.push_back(*iter);
919 } 899 }
920 } 900 }
921 901
922 void PersonalDataManager::CancelPendingQuery( 902 void PersonalDataManager::CancelPendingQuery(
923 WebDataServiceBase::Handle* handle) { 903 WebDataServiceBase::Handle* handle) {
924 if (*handle) { 904 if (*handle) {
925 scoped_refptr<AutofillWebDataService> autofill_data( 905 if (!autofill_webdata_.get()) {
926 AutofillWebDataService::FromBrowserContext(browser_context_));
927 if (!autofill_data.get()) {
928 NOTREACHED(); 906 NOTREACHED();
929 return; 907 return;
930 } 908 }
931 autofill_data->CancelRequest(*handle); 909 autofill_webdata_->CancelRequest(*handle);
932 } 910 }
933 *handle = 0; 911 *handle = 0;
934 } 912 }
935 913
936 void PersonalDataManager::SaveImportedProfile( 914 void PersonalDataManager::SaveImportedProfile(
937 const AutofillProfile& imported_profile) { 915 const AutofillProfile& imported_profile) {
938 if (browser_context_->IsOffTheRecord()) { 916 if (browser_context_->IsOffTheRecord()) {
939 // The |IsOffTheRecord| check should happen earlier in the import process, 917 // The |IsOffTheRecord| check should happen earlier in the import process,
940 // upon form submission. 918 // upon form submission.
941 NOTREACHED(); 919 NOTREACHED();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 const AutofillMetrics* metric_logger) { 981 const AutofillMetrics* metric_logger) {
1004 metric_logger_.reset(metric_logger); 982 metric_logger_.reset(metric_logger);
1005 } 983 }
1006 984
1007 void PersonalDataManager::set_browser_context( 985 void PersonalDataManager::set_browser_context(
1008 content::BrowserContext* context) { 986 content::BrowserContext* context) {
1009 browser_context_ = context; 987 browser_context_ = context;
1010 } 988 }
1011 989
1012 } // namespace autofill 990 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698