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

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

Issue 14392005: Allowing PersonalDataManagerFactory to create a service while incognito. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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
« no previous file with comments | « chrome/browser/autofill/personal_data_manager_factory.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 void PersonalDataManager::Init(BrowserContext* browser_context) { 143 void PersonalDataManager::Init(BrowserContext* browser_context) {
144 browser_context_ = browser_context; 144 browser_context_ = browser_context;
145 metric_logger_->LogIsAutofillEnabledAtStartup(IsAutofillEnabled()); 145 metric_logger_->LogIsAutofillEnabledAtStartup(IsAutofillEnabled());
146 146
147 scoped_refptr<AutofillWebDataService> autofill_data( 147 scoped_refptr<AutofillWebDataService> autofill_data(
148 AutofillWebDataService::FromBrowserContext(browser_context_)); 148 AutofillWebDataService::FromBrowserContext(browser_context_));
149 149
150 // WebDataService may not be available in tests. 150 // WebDataService may not be available in tests.
151 if (!autofill_data.get()) 151 if (!autofill_data.get())
152 return; 152 return;
Ilya Sherman 2013/04/25 04:12:52 If I'm jumping through code correctly, it looks li
Dan Beam 2013/04/25 05:30:34 so, if the first part of this maybe isn't right (a
Dan Beam 2013/04/25 06:37:11 so if you're not worried about ^ this, CQ da patch
153 153
154 LoadProfiles(); 154 LoadProfiles();
155 LoadCreditCards(); 155 LoadCreditCards();
156 156
157 autofill_data->AddObserver(this); 157 autofill_data->AddObserver(this);
158 } 158 }
159 159
160 PersonalDataManager::~PersonalDataManager() { 160 PersonalDataManager::~PersonalDataManager() {
161 CancelPendingQuery(&pending_profiles_query_); 161 CancelPendingQuery(&pending_profiles_query_);
162 CancelPendingQuery(&pending_creditcards_query_); 162 CancelPendingQuery(&pending_creditcards_query_);
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 (*iter)->GetNonEmptyTypes(app_locale_, non_empty_types); 513 (*iter)->GetNonEmptyTypes(app_locale_, non_empty_types);
514 } 514 }
515 } 515 }
516 516
517 bool PersonalDataManager::IsDataLoaded() const { 517 bool PersonalDataManager::IsDataLoaded() const {
518 return is_data_loaded_; 518 return is_data_loaded_;
519 } 519 }
520 520
521 const std::vector<AutofillProfile*>& PersonalDataManager::GetProfiles() { 521 const std::vector<AutofillProfile*>& PersonalDataManager::GetProfiles() {
522 if (!components::UserPrefs::Get(browser_context_)->GetBoolean( 522 if (!components::UserPrefs::Get(browser_context_)->GetBoolean(
523 prefs::kAutofillAuxiliaryProfilesEnabled)) { 523 prefs::kAutofillAuxiliaryProfilesEnabled)) {
Ilya Sherman 2013/04/25 04:12:52 Will this do the right thing if browser_context_ i
Dan Beam 2013/04/25 05:30:34 this seems to be agnostic to whether the profile i
524 return web_profiles(); 524 return web_profiles();
525 } 525 }
526 526
527 profiles_.clear(); 527 profiles_.clear();
528 528
529 // Populates |auxiliary_profiles_|. 529 // Populates |auxiliary_profiles_|.
530 LoadAuxiliaryProfiles(); 530 LoadAuxiliaryProfiles();
531 531
532 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); 532 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end());
533 profiles_.insert(profiles_.end(), 533 profiles_.insert(profiles_.end(),
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 values->push_back(creditcard_field_value); 665 values->push_back(creditcard_field_value);
666 labels->push_back(label); 666 labels->push_back(label);
667 icons->push_back(UTF8ToUTF16(credit_card->type())); 667 icons->push_back(UTF8ToUTF16(credit_card->type()));
668 guid_pairs->push_back(GUIDPair(credit_card->guid(), 0)); 668 guid_pairs->push_back(GUIDPair(credit_card->guid(), 0));
669 } 669 }
670 } 670 }
671 } 671 }
672 672
673 bool PersonalDataManager::IsAutofillEnabled() const { 673 bool PersonalDataManager::IsAutofillEnabled() const {
674 return components::UserPrefs::Get(browser_context_)->GetBoolean( 674 return components::UserPrefs::Get(browser_context_)->GetBoolean(
675 prefs::kAutofillEnabled); 675 prefs::kAutofillEnabled);
Ilya Sherman 2013/04/25 04:12:52 Will this do the right thing if browser_context_ i
Dan Beam 2013/04/25 05:30:34 this code seems to agnostic to OTR-ness as well, a
676 } 676 }
677 677
678 // static 678 // static
679 bool PersonalDataManager::IsValidLearnableProfile( 679 bool PersonalDataManager::IsValidLearnableProfile(
680 const AutofillProfile& profile, 680 const AutofillProfile& profile,
681 const std::string& app_locale) { 681 const std::string& app_locale) {
682 if (!IsMinimumAddress(profile, app_locale)) 682 if (!IsMinimumAddress(profile, app_locale))
683 return false; 683 return false;
684 684
685 base::string16 email = profile.GetRawInfo(EMAIL_ADDRESS); 685 base::string16 email = profile.GetRawInfo(EMAIL_ADDRESS);
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 NOTREACHED(); 929 NOTREACHED();
930 return; 930 return;
931 } 931 }
932 autofill_data->CancelRequest(*handle); 932 autofill_data->CancelRequest(*handle);
933 } 933 }
934 *handle = 0; 934 *handle = 0;
935 } 935 }
936 936
937 void PersonalDataManager::SaveImportedProfile( 937 void PersonalDataManager::SaveImportedProfile(
938 const AutofillProfile& imported_profile) { 938 const AutofillProfile& imported_profile) {
939 if (browser_context_->IsOffTheRecord()) { 939 if (browser_context_->IsOffTheRecord())
940 // The |IsOffTheRecord| check should happen earlier in the import process,
941 // upon form submission.
942 NOTREACHED();
943 return; 940 return;
944 }
945 941
946 // Don't save a web profile if the data in the profile is a subset of an 942 // Don't save a web profile if the data in the profile is a subset of an
947 // auxiliary profile. 943 // auxiliary profile.
948 for (std::vector<AutofillProfile*>::const_iterator iter = 944 for (std::vector<AutofillProfile*>::const_iterator iter =
949 auxiliary_profiles_.begin(); 945 auxiliary_profiles_.begin();
950 iter != auxiliary_profiles_.end(); ++iter) { 946 iter != auxiliary_profiles_.end(); ++iter) {
951 if (imported_profile.IsSubsetOf(**iter, app_locale_)) 947 if (imported_profile.IsSubsetOf(**iter, app_locale_))
952 return; 948 return;
953 } 949 }
954 950
955 std::vector<AutofillProfile> profiles; 951 std::vector<AutofillProfile> profiles;
956 MergeProfile(imported_profile, web_profiles_.get(), app_locale_, &profiles); 952 MergeProfile(imported_profile, web_profiles_.get(), app_locale_, &profiles);
957 SetProfiles(&profiles); 953 SetProfiles(&profiles);
958 } 954 }
959 955
960 956
961 void PersonalDataManager::SaveImportedCreditCard( 957 void PersonalDataManager::SaveImportedCreditCard(
962 const CreditCard& imported_card) { 958 const CreditCard& imported_card) {
963 DCHECK(!imported_card.number().empty()); 959 DCHECK(!imported_card.number().empty());
964 if (browser_context_->IsOffTheRecord()) { 960 if (browser_context_->IsOffTheRecord())
965 // The |IsOffTheRecord| check should happen earlier in the import process,
966 // upon form submission.
967 NOTREACHED();
968 return; 961 return;
969 }
970 962
971 // Set to true if |imported_card| is merged into the credit card list. 963 // Set to true if |imported_card| is merged into the credit card list.
972 bool merged = false; 964 bool merged = false;
973 965
974 std::vector<CreditCard> credit_cards; 966 std::vector<CreditCard> credit_cards;
975 for (std::vector<CreditCard*>::const_iterator card = credit_cards_.begin(); 967 for (std::vector<CreditCard*>::const_iterator card = credit_cards_.begin();
976 card != credit_cards_.end(); 968 card != credit_cards_.end();
977 ++card) { 969 ++card) {
978 // If |imported_card| has not yet been merged, check whether it should be 970 // If |imported_card| has not yet been merged, check whether it should be
979 // with the current |card|. 971 // with the current |card|.
(...skipping 24 matching lines...) Expand all
1004 const AutofillMetrics* metric_logger) { 996 const AutofillMetrics* metric_logger) {
1005 metric_logger_.reset(metric_logger); 997 metric_logger_.reset(metric_logger);
1006 } 998 }
1007 999
1008 void PersonalDataManager::set_browser_context( 1000 void PersonalDataManager::set_browser_context(
1009 content::BrowserContext* context) { 1001 content::BrowserContext* context) {
1010 browser_context_ = context; 1002 browser_context_ = context;
1011 } 1003 }
1012 1004
1013 } // namespace autofill 1005 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/autofill/personal_data_manager_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698