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

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

Issue 9585020: Cull autofill entries older than 60 days. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed clang Created 8 years, 9 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 "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"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/autofill/autofill-inl.h" 13 #include "chrome/browser/autofill/autofill-inl.h"
14 #include "chrome/browser/autofill/autofill_field.h" 14 #include "chrome/browser/autofill/autofill_field.h"
15 #include "chrome/browser/autofill/autofill_metrics.h" 15 #include "chrome/browser/autofill/autofill_metrics.h"
16 #include "chrome/browser/autofill/autofill_regexes.h" 16 #include "chrome/browser/autofill/autofill_regexes.h"
17 #include "chrome/browser/autofill/form_structure.h" 17 #include "chrome/browser/autofill/form_structure.h"
18 #include "chrome/browser/autofill/personal_data_manager_observer.h" 18 #include "chrome/browser/autofill/personal_data_manager_observer.h"
19 #include "chrome/browser/autofill/phone_number.h" 19 #include "chrome/browser/autofill/phone_number.h"
20 #include "chrome/browser/autofill/phone_number_i18n.h" 20 #include "chrome/browser/autofill/phone_number_i18n.h"
21 #include "chrome/browser/autofill/select_control_handler.h" 21 #include "chrome/browser/autofill/select_control_handler.h"
22 #include "chrome/browser/prefs/pref_service.h" 22 #include "chrome/browser/prefs/pref_service.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/sync/profile_sync_service.h" 24 #include "chrome/browser/sync/profile_sync_service.h"
25 #include "chrome/browser/sync/profile_sync_service_factory.h" 25 #include "chrome/browser/sync/profile_sync_service_factory.h"
26 #include "chrome/browser/webdata/autofill_entry.h"
26 #include "chrome/browser/webdata/web_data_service.h" 27 #include "chrome/browser/webdata/web_data_service.h"
27 #include "chrome/common/chrome_notification_types.h" 28 #include "chrome/common/chrome_notification_types.h"
28 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
29 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/notification_source.h" 31 #include "content/public/browser/notification_source.h"
31 32
32 namespace { 33 namespace {
33 34
34 template<typename T> 35 template<typename T>
35 class FormGroupMatchesByGUIDFunctor { 36 class FormGroupMatchesByGUIDFunctor {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 155
155 // If both requests have responded, then all personal data is loaded. 156 // If both requests have responded, then all personal data is loaded.
156 if (pending_profiles_query_ == 0 && pending_creditcards_query_ == 0) { 157 if (pending_profiles_query_ == 0 && pending_creditcards_query_ == 0) {
157 is_data_loaded_ = true; 158 is_data_loaded_ = true;
158 std::vector<AutofillProfile*> profile_pointers(web_profiles_.size()); 159 std::vector<AutofillProfile*> profile_pointers(web_profiles_.size());
159 std::copy(web_profiles_.begin(), web_profiles_.end(), 160 std::copy(web_profiles_.begin(), web_profiles_.end(),
160 profile_pointers.begin()); 161 profile_pointers.begin());
161 AutofillProfile::AdjustInferredLabels(&profile_pointers); 162 AutofillProfile::AdjustInferredLabels(&profile_pointers);
162 FOR_EACH_OBSERVER(PersonalDataManagerObserver, observers_, 163 FOR_EACH_OBSERVER(PersonalDataManagerObserver, observers_,
163 OnPersonalDataChanged()); 164 OnPersonalDataChanged());
165
166 // As all Autofill data is ready, the Autocomplete data is ready as well.
167 // If sync is not set, cull older entries of the autocomplete. Otherwise,
168 // the entries will be culled when sync is connected.
169 ProfileSyncService* sync_service =
170 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
171 if (sync_service && (!sync_service->HasSyncSetupCompleted() ||
172 !profile_->GetPrefs()->GetBoolean(prefs::kSyncAutofill))) {
173 WebDataService* wds =
174 profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
175 if (wds) {
176 wds->RemoveFormElementsAccessedBefore(
Ilya Sherman 2012/03/15 21:00:41 nit: Can we make this interface simply be "wds->Re
GeorgeY 2012/03/17 00:36:16 Yes, done
177 base::Time::Now() -
178 base::TimeDelta::FromDays(
179 AutofillEntry::kExpirationPeriodInDays));
180 }
181 }
164 } 182 }
165 } 183 }
166 184
167 void PersonalDataManager::SetObserver(PersonalDataManagerObserver* observer) { 185 void PersonalDataManager::SetObserver(PersonalDataManagerObserver* observer) {
168 // TODO(dhollowa): RemoveObserver is for compatibility with old code, it 186 // TODO(dhollowa): RemoveObserver is for compatibility with old code, it
169 // should be nuked. 187 // should be nuked.
170 observers_.RemoveObserver(observer); 188 observers_.RemoveObserver(observer);
171 observers_.AddObserver(observer); 189 observers_.AddObserver(observer);
172 } 190 }
173 191
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 } 934 }
917 935
918 const AutofillMetrics* PersonalDataManager::metric_logger() const { 936 const AutofillMetrics* PersonalDataManager::metric_logger() const {
919 return metric_logger_.get(); 937 return metric_logger_.get();
920 } 938 }
921 939
922 void PersonalDataManager::set_metric_logger( 940 void PersonalDataManager::set_metric_logger(
923 const AutofillMetrics* metric_logger) { 941 const AutofillMetrics* metric_logger) {
924 metric_logger_.reset(metric_logger); 942 metric_logger_.reset(metric_logger);
925 } 943 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698