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

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 metric_logger_->LogIsAutofillEnabledAtStartup(IsAutofillEnabled());
Ilya Sherman 2013/04/25 06:10:02 nit: Let's not log this in Incognito mode.
Dan Beam 2013/04/25 06:33:34 Done.
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;
153 153
154 LoadProfiles(); 154 LoadProfiles();
155 LoadCreditCards(); 155 LoadCreditCards();
(...skipping 773 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

Powered by Google App Engine
This is Rietveld 408576698