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

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

Issue 6931029: Set datapresent string to contain precisely those field types available in stored Autofill data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't SetInfo() for read-only fields Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 558
559 CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) { 559 CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) {
560 for (std::vector<CreditCard*>::iterator iter = credit_cards_.begin(); 560 for (std::vector<CreditCard*>::iterator iter = credit_cards_.begin();
561 iter != credit_cards_.end(); ++iter) { 561 iter != credit_cards_.end(); ++iter) {
562 if ((*iter)->guid() == guid) 562 if ((*iter)->guid() == guid)
563 return *iter; 563 return *iter;
564 } 564 }
565 return NULL; 565 return NULL;
566 } 566 }
567 567
568 void PersonalDataManager::GetPossibleFieldTypes(const string16& text, 568 void PersonalDataManager::GetPossibleFieldTypes(
569 FieldTypeSet* possible_types) { 569 const string16& text,
570 FieldTypeSet* possible_types) const {
570 string16 clean_info = StringToLowerASCII(CollapseWhitespace(text, false)); 571 string16 clean_info = StringToLowerASCII(CollapseWhitespace(text, false));
571 if (clean_info.empty()) { 572 if (clean_info.empty()) {
572 possible_types->insert(EMPTY_TYPE); 573 possible_types->insert(EMPTY_TYPE);
573 return; 574 return;
574 } 575 }
575 576
576 const std::vector<AutofillProfile*>& profiles = this->profiles(); 577 const std::vector<AutofillProfile*>& profiles = this->profiles();
577 for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin(); 578 for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin();
578 iter != profiles.end(); ++iter) { 579 iter != profiles.end(); ++iter) {
579 const FormGroup* profile = *iter; 580 const FormGroup* profile = *iter;
580 if (!profile) { 581 if (!profile) {
581 DLOG(ERROR) << "NULL information in profiles list"; 582 DLOG(ERROR) << "NULL information in profiles list";
582 continue; 583 continue;
583 } 584 }
584 585
585 profile->GetPossibleFieldTypes(clean_info, possible_types); 586 profile->GetPossibleFieldTypes(clean_info, possible_types);
586 } 587 }
587 588
588 for (ScopedVector<CreditCard>::iterator iter = credit_cards_.begin(); 589 for (ScopedVector<CreditCard>::const_iterator iter = credit_cards_.begin();
589 iter != credit_cards_.end(); ++iter) { 590 iter != credit_cards_.end(); ++iter) {
590 const FormGroup* credit_card = *iter; 591 const FormGroup* credit_card = *iter;
591 if (!credit_card) { 592 if (!credit_card) {
592 DLOG(ERROR) << "NULL information in credit cards list"; 593 DLOG(ERROR) << "NULL information in credit cards list";
593 continue; 594 continue;
594 } 595 }
595 596
596 credit_card->GetPossibleFieldTypes(clean_info, possible_types); 597 credit_card->GetPossibleFieldTypes(clean_info, possible_types);
597 } 598 }
598 599
599 if (possible_types->empty()) 600 if (possible_types->empty())
600 possible_types->insert(UNKNOWN_TYPE); 601 possible_types->insert(UNKNOWN_TYPE);
601 } 602 }
602 603
604 void PersonalDataManager::GetAvailableFieldTypes(
605 FieldTypeSet* available_types) const {
606 const std::vector<AutofillProfile*>& profiles = this->profiles();
607 for (std::vector<AutofillProfile*>::const_iterator iter = profiles.begin();
608 iter != profiles.end(); ++iter) {
609 (*iter)->GetAvailableFieldTypes(available_types);
610 }
611
612 for (ScopedVector<CreditCard>::const_iterator iter = credit_cards_.begin();
613 iter != credit_cards_.end(); ++iter) {
614 (*iter)->GetAvailableFieldTypes(available_types);
615 }
616 }
617
618
dhollowa 2011/05/06 03:06:20 nit: remove extra line.
Ilya Sherman 2011/05/06 03:33:07 Done.
603 bool PersonalDataManager::HasPassword() { 619 bool PersonalDataManager::HasPassword() {
604 return !password_hash_.empty(); 620 return !password_hash_.empty();
605 } 621 }
606 622
607 bool PersonalDataManager::IsDataLoaded() const { 623 bool PersonalDataManager::IsDataLoaded() const {
608 return is_data_loaded_; 624 return is_data_loaded_;
609 } 625 }
610 626
611 const std::vector<AutofillProfile*>& PersonalDataManager::profiles() { 627 const std::vector<AutofillProfile*>& PersonalDataManager::profiles() const {
612 // |profile_| is NULL in AutofillManagerTest. 628 // |profile_| is NULL in AutofillManagerTest.
613 bool auxiliary_profiles_enabled = profile_ ? profile_->GetPrefs()->GetBoolean( 629 bool auxiliary_profiles_enabled = profile_ ? profile_->GetPrefs()->GetBoolean(
614 prefs::kAutofillAuxiliaryProfilesEnabled) : false; 630 prefs::kAutofillAuxiliaryProfilesEnabled) : false;
615 if (!auxiliary_profiles_enabled) 631 if (!auxiliary_profiles_enabled)
616 return web_profiles(); 632 return web_profiles();
617 633
618 #if !defined(OS_MACOSX) 634 #if !defined(OS_MACOSX)
619 NOTREACHED() << "Auxiliary profiles supported on Mac only"; 635 NOTREACHED() << "Auxiliary profiles supported on Mac only";
620 #endif 636 #endif
621 637
622 profiles_.clear(); 638 profiles_.clear();
623 639
624 // Populates |auxiliary_profiles_|. 640 // Populates |auxiliary_profiles_|.
625 LoadAuxiliaryProfiles(); 641 LoadAuxiliaryProfiles();
626 642
627 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); 643 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end());
628 profiles_.insert(profiles_.end(), 644 profiles_.insert(profiles_.end(),
629 auxiliary_profiles_.begin(), auxiliary_profiles_.end()); 645 auxiliary_profiles_.begin(), auxiliary_profiles_.end());
630 return profiles_; 646 return profiles_;
631 } 647 }
632 648
633 const std::vector<AutofillProfile*>& PersonalDataManager::web_profiles() { 649 const std::vector<AutofillProfile*>& PersonalDataManager::web_profiles() const {
634 return web_profiles_.get(); 650 return web_profiles_.get();
635 } 651 }
636 652
637 const std::vector<CreditCard*>& PersonalDataManager::credit_cards() { 653 const std::vector<CreditCard*>& PersonalDataManager::credit_cards() const {
638 return credit_cards_.get(); 654 return credit_cards_.get();
639 } 655 }
640 656
641 void PersonalDataManager::Refresh() { 657 void PersonalDataManager::Refresh() {
642 LoadProfiles(); 658 LoadProfiles();
643 LoadCreditCards(); 659 LoadCreditCards();
644 } 660 }
645 661
646 PersonalDataManager::PersonalDataManager() 662 PersonalDataManager::PersonalDataManager()
647 : profile_(NULL), 663 : profile_(NULL),
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 } 772 }
757 773
758 CancelPendingQuery(&pending_profiles_query_); 774 CancelPendingQuery(&pending_profiles_query_);
759 775
760 pending_profiles_query_ = web_data_service->GetAutofillProfiles(this); 776 pending_profiles_query_ = web_data_service->GetAutofillProfiles(this);
761 } 777 }
762 778
763 // Win and Linux implementations do nothing. Mac implementation fills in the 779 // Win and Linux implementations do nothing. Mac implementation fills in the
764 // contents of |auxiliary_profiles_|. 780 // contents of |auxiliary_profiles_|.
765 #if !defined(OS_MACOSX) 781 #if !defined(OS_MACOSX)
766 void PersonalDataManager::LoadAuxiliaryProfiles() { 782 void PersonalDataManager::LoadAuxiliaryProfiles() const {
767 } 783 }
768 #endif 784 #endif
769 785
770 void PersonalDataManager::LoadCreditCards() { 786 void PersonalDataManager::LoadCreditCards() {
771 WebDataService* web_data_service = 787 WebDataService* web_data_service =
772 profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); 788 profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
773 if (!web_data_service) { 789 if (!web_data_service) {
774 NOTREACHED(); 790 NOTREACHED();
775 return; 791 return;
776 } 792 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 } 939 }
924 940
925 const AutofillMetrics* PersonalDataManager::metric_logger() const { 941 const AutofillMetrics* PersonalDataManager::metric_logger() const {
926 return metric_logger_.get(); 942 return metric_logger_.get();
927 } 943 }
928 944
929 void PersonalDataManager::set_metric_logger( 945 void PersonalDataManager::set_metric_logger(
930 const AutofillMetrics* metric_logger) { 946 const AutofillMetrics* metric_logger) {
931 metric_logger_.reset(metric_logger); 947 metric_logger_.reset(metric_logger);
932 } 948 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698