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

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

Issue 10910071: Extract abstract base to API directory for ProfileSyncService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge LKGR Created 8 years, 3 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/api/prefs/pref_service_base.h"
14 #include "chrome/browser/api/sync/profile_sync_service_base.h"
13 #include "chrome/browser/autofill/autofill-inl.h" 15 #include "chrome/browser/autofill/autofill-inl.h"
14 #include "chrome/browser/autofill/autofill_field.h" 16 #include "chrome/browser/autofill/autofill_field.h"
15 #include "chrome/browser/autofill/autofill_metrics.h" 17 #include "chrome/browser/autofill/autofill_metrics.h"
16 #include "chrome/browser/autofill/autofill_regexes.h" 18 #include "chrome/browser/autofill/autofill_regexes.h"
17 #include "chrome/browser/autofill/form_structure.h" 19 #include "chrome/browser/autofill/form_structure.h"
18 #include "chrome/browser/autofill/personal_data_manager_observer.h" 20 #include "chrome/browser/autofill/personal_data_manager_observer.h"
19 #include "chrome/browser/autofill/phone_number.h" 21 #include "chrome/browser/autofill/phone_number.h"
20 #include "chrome/browser/autofill/phone_number_i18n.h" 22 #include "chrome/browser/autofill/phone_number_i18n.h"
21 #include "chrome/browser/autofill/select_control_handler.h" 23 #include "chrome/browser/autofill/select_control_handler.h"
22 #include "chrome/browser/api/prefs/pref_service_base.h"
23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/sync/profile_sync_service.h"
25 #include "chrome/browser/sync/profile_sync_service_factory.h"
26 #include "chrome/common/chrome_notification_types.h" 24 #include "chrome/common/chrome_notification_types.h"
27 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "content/public/browser/browser_context.h"
28 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/notification_source.h" 28 #include "content/public/browser/notification_source.h"
30 29
31 using content::BrowserContext; 30 using content::BrowserContext;
32 31
33 namespace { 32 namespace {
34 33
35 template<typename T> 34 template<typename T>
36 class FormGroupMatchesByGUIDFunctor { 35 class FormGroupMatchesByGUIDFunctor {
37 public: 36 public:
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 std::vector<AutofillProfile*> profile_pointers(web_profiles_.size()); 158 std::vector<AutofillProfile*> profile_pointers(web_profiles_.size());
160 std::copy(web_profiles_.begin(), web_profiles_.end(), 159 std::copy(web_profiles_.begin(), web_profiles_.end(),
161 profile_pointers.begin()); 160 profile_pointers.begin());
162 AutofillProfile::AdjustInferredLabels(&profile_pointers); 161 AutofillProfile::AdjustInferredLabels(&profile_pointers);
163 FOR_EACH_OBSERVER(PersonalDataManagerObserver, observers_, 162 FOR_EACH_OBSERVER(PersonalDataManagerObserver, observers_,
164 OnPersonalDataChanged()); 163 OnPersonalDataChanged());
165 164
166 // As all Autofill data is ready, the Autocomplete data is ready as well. 165 // 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, 166 // If sync is not set, cull older entries of the autocomplete. Otherwise,
168 // the entries will be culled when sync is connected. 167 // the entries will be culled when sync is connected.
169 ProfileSyncService* sync_service = 168 ProfileSyncServiceBase* sync_service =
170 ProfileSyncServiceFactory::GetInstance()->GetForProfile( 169 ProfileSyncServiceBase::ForContext(browser_context_);
171 static_cast<Profile*>(browser_context_));
172 if (sync_service && (!sync_service->HasSyncSetupCompleted() || 170 if (sync_service && (!sync_service->HasSyncSetupCompleted() ||
173 !PrefServiceBase::ForContext( 171 !PrefServiceBase::ForContext(
174 browser_context_)->GetBoolean( 172 browser_context_)->GetBoolean(
175 prefs::kSyncAutofill))) { 173 prefs::kSyncAutofill))) {
176 scoped_refptr<WebDataServiceBase> service = 174 scoped_refptr<WebDataServiceBase> service =
177 WebDataServiceBase::ForContext(browser_context_); 175 WebDataServiceBase::ForContext(browser_context_);
178 if (service) { 176 if (service) {
179 AutofillWebData::ForService(service)->RemoveExpiredFormElements(); 177 AutofillWebData::ForService(service)->RemoveExpiredFormElements();
180 } 178 }
181 } 179 }
(...skipping 19 matching lines...) Expand all
201 if (!browser_context_ || browser_context_->IsOffTheRecord()) 199 if (!browser_context_ || browser_context_->IsOffTheRecord())
202 return; 200 return;
203 201
204 scoped_refptr<WebDataServiceBase> web_data_service = 202 scoped_refptr<WebDataServiceBase> web_data_service =
205 WebDataServiceBase::ForContext(browser_context_); 203 WebDataServiceBase::ForContext(browser_context_);
206 if (!web_data_service.get()) { 204 if (!web_data_service.get()) {
207 NOTREACHED(); 205 NOTREACHED();
208 return; 206 return;
209 } 207 }
210 208
211 ProfileSyncService* sync_service = 209 ProfileSyncServiceBase* sync_service =
212 ProfileSyncServiceFactory::GetInstance()->GetForProfile( 210 ProfileSyncServiceBase::ForContext(browser_context_);
213 static_cast<Profile*>(browser_context_));
214 if (!sync_service) 211 if (!sync_service)
215 return; 212 return;
216 213
217 if (sync_service->ShouldPushChanges()) { 214 if (sync_service->ShouldPushChanges()) {
218 AutofillWebData::ForService(web_data_service)->EmptyMigrationTrash(true); 215 AutofillWebData::ForService(web_data_service)->EmptyMigrationTrash(true);
219 sync_service->RemoveObserver(this); 216 sync_service->RemoveObserver(this);
220 } 217 }
221 } 218 }
222 219
223 void PersonalDataManager::Shutdown() { 220 void PersonalDataManager::Shutdown() {
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 if (!browser_context_ || browser_context_->IsOffTheRecord()) 915 if (!browser_context_ || browser_context_->IsOffTheRecord())
919 return; 916 return;
920 917
921 scoped_refptr<WebDataServiceBase> web_data_service = 918 scoped_refptr<WebDataServiceBase> web_data_service =
922 WebDataServiceBase::ForContext(browser_context_); 919 WebDataServiceBase::ForContext(browser_context_);
923 if (!web_data_service.get()) { 920 if (!web_data_service.get()) {
924 NOTREACHED(); 921 NOTREACHED();
925 return; 922 return;
926 } 923 }
927 924
928 ProfileSyncService* sync_service = 925 ProfileSyncServiceBase* sync_service =
929 ProfileSyncServiceFactory::GetInstance()->GetForProfile( 926 ProfileSyncServiceBase::ForContext(browser_context_);
930 static_cast<Profile*>(browser_context_));
931 if (!sync_service) 927 if (!sync_service)
932 return; 928 return;
933 929
934 AutofillWebData* autofill_data = 930 AutofillWebData* autofill_data =
935 AutofillWebData::ForService(web_data_service); 931 AutofillWebData::ForService(web_data_service);
936 if (!sync_service->HasSyncSetupCompleted()) { 932 if (!sync_service->HasSyncSetupCompleted()) {
937 autofill_data->EmptyMigrationTrash(false); 933 autofill_data->EmptyMigrationTrash(false);
938 } else if (sync_service->ShouldPushChanges()) { 934 } else if (sync_service->ShouldPushChanges()) {
939 autofill_data->EmptyMigrationTrash(true); 935 autofill_data->EmptyMigrationTrash(true);
940 } else { 936 } else {
(...skipping 12 matching lines...) Expand all
953 } 949 }
954 950
955 const AutofillMetrics* PersonalDataManager::metric_logger() const { 951 const AutofillMetrics* PersonalDataManager::metric_logger() const {
956 return metric_logger_.get(); 952 return metric_logger_.get();
957 } 953 }
958 954
959 void PersonalDataManager::set_metric_logger( 955 void PersonalDataManager::set_metric_logger(
960 const AutofillMetrics* metric_logger) { 956 const AutofillMetrics* metric_logger) {
961 metric_logger_.reset(metric_logger); 957 metric_logger_.reset(metric_logger);
962 } 958 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698