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

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
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 : browser_context_(NULL), 135 : browser_context_(NULL),
136 is_data_loaded_(false), 136 is_data_loaded_(false),
137 pending_profiles_query_(0), 137 pending_profiles_query_(0),
138 pending_creditcards_query_(0), 138 pending_creditcards_query_(0),
139 app_locale_(app_locale), 139 app_locale_(app_locale),
140 metric_logger_(new AutofillMetrics), 140 metric_logger_(new AutofillMetrics),
141 has_logged_profile_count_(false) {} 141 has_logged_profile_count_(false) {}
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
146 if (!browser_context_->IsOffTheRecord())
147 metric_logger_->LogIsAutofillEnabledAtStartup(IsAutofillEnabled());
146 148
147 scoped_refptr<AutofillWebDataService> autofill_data( 149 scoped_refptr<AutofillWebDataService> autofill_data(
148 AutofillWebDataService::FromBrowserContext(browser_context_)); 150 AutofillWebDataService::FromBrowserContext(browser_context_));
149 151
150 // WebDataService may not be available in tests. 152 // WebDataService may not be available in tests.
151 if (!autofill_data.get()) 153 if (!autofill_data.get())
152 return; 154 return;
153 155
154 LoadProfiles(); 156 LoadProfiles();
155 LoadCreditCards(); 157 LoadCreditCards();
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 NOTREACHED(); 931 NOTREACHED();
930 return; 932 return;
931 } 933 }
932 autofill_data->CancelRequest(*handle); 934 autofill_data->CancelRequest(*handle);
933 } 935 }
934 *handle = 0; 936 *handle = 0;
935 } 937 }
936 938
937 void PersonalDataManager::SaveImportedProfile( 939 void PersonalDataManager::SaveImportedProfile(
938 const AutofillProfile& imported_profile) { 940 const AutofillProfile& imported_profile) {
939 if (browser_context_->IsOffTheRecord()) { 941 if (browser_context_->IsOffTheRecord())
940 // The |IsOffTheRecord| check should happen earlier in the import process,
941 // upon form submission.
942 NOTREACHED();
943 return; 942 return;
944 }
945 943
946 // Don't save a web profile if the data in the profile is a subset of an 944 // Don't save a web profile if the data in the profile is a subset of an
947 // auxiliary profile. 945 // auxiliary profile.
948 for (std::vector<AutofillProfile*>::const_iterator iter = 946 for (std::vector<AutofillProfile*>::const_iterator iter =
949 auxiliary_profiles_.begin(); 947 auxiliary_profiles_.begin();
950 iter != auxiliary_profiles_.end(); ++iter) { 948 iter != auxiliary_profiles_.end(); ++iter) {
951 if (imported_profile.IsSubsetOf(**iter, app_locale_)) 949 if (imported_profile.IsSubsetOf(**iter, app_locale_))
952 return; 950 return;
953 } 951 }
954 952
955 std::vector<AutofillProfile> profiles; 953 std::vector<AutofillProfile> profiles;
956 MergeProfile(imported_profile, web_profiles_.get(), app_locale_, &profiles); 954 MergeProfile(imported_profile, web_profiles_.get(), app_locale_, &profiles);
957 SetProfiles(&profiles); 955 SetProfiles(&profiles);
958 } 956 }
959 957
960 958
961 void PersonalDataManager::SaveImportedCreditCard( 959 void PersonalDataManager::SaveImportedCreditCard(
962 const CreditCard& imported_card) { 960 const CreditCard& imported_card) {
963 DCHECK(!imported_card.number().empty()); 961 DCHECK(!imported_card.number().empty());
964 if (browser_context_->IsOffTheRecord()) { 962 if (browser_context_->IsOffTheRecord())
965 // The |IsOffTheRecord| check should happen earlier in the import process,
966 // upon form submission.
967 NOTREACHED();
968 return; 963 return;
969 }
970 964
971 // Set to true if |imported_card| is merged into the credit card list. 965 // Set to true if |imported_card| is merged into the credit card list.
972 bool merged = false; 966 bool merged = false;
973 967
974 std::vector<CreditCard> credit_cards; 968 std::vector<CreditCard> credit_cards;
975 for (std::vector<CreditCard*>::const_iterator card = credit_cards_.begin(); 969 for (std::vector<CreditCard*>::const_iterator card = credit_cards_.begin();
976 card != credit_cards_.end(); 970 card != credit_cards_.end();
977 ++card) { 971 ++card) {
978 // If |imported_card| has not yet been merged, check whether it should be 972 // If |imported_card| has not yet been merged, check whether it should be
979 // with the current |card|. 973 // with the current |card|.
(...skipping 24 matching lines...) Expand all
1004 const AutofillMetrics* metric_logger) { 998 const AutofillMetrics* metric_logger) {
1005 metric_logger_.reset(metric_logger); 999 metric_logger_.reset(metric_logger);
1006 } 1000 }
1007 1001
1008 void PersonalDataManager::set_browser_context( 1002 void PersonalDataManager::set_browser_context(
1009 content::BrowserContext* context) { 1003 content::BrowserContext* context) {
1010 browser_context_ = context; 1004 browser_context_ = context;
1011 } 1005 }
1012 1006
1013 } // namespace autofill 1007 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698