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

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

Issue 10828345: Extract PrefServiceBase into chrome/browser/api. Use in api and autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head Created 8 years, 4 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/api/prefs/pref_service_base.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/autofill_entry.h"
27 #include "chrome/browser/webdata/web_data_service.h" 27 #include "chrome/browser/webdata/web_data_service.h"
28 #include "chrome/browser/webdata/web_data_service_factory.h" 28 #include "chrome/browser/webdata/web_data_service_factory.h"
29 #include "chrome/common/chrome_notification_types.h" 29 #include "chrome/common/chrome_notification_types.h"
30 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
31 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/notification_source.h" 32 #include "content/public/browser/notification_source.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 AutofillProfile::AdjustInferredLabels(&profile_pointers); 163 AutofillProfile::AdjustInferredLabels(&profile_pointers);
164 FOR_EACH_OBSERVER(PersonalDataManagerObserver, observers_, 164 FOR_EACH_OBSERVER(PersonalDataManagerObserver, observers_,
165 OnPersonalDataChanged()); 165 OnPersonalDataChanged());
166 166
167 // As all Autofill data is ready, the Autocomplete data is ready as well. 167 // As all Autofill data is ready, the Autocomplete data is ready as well.
168 // If sync is not set, cull older entries of the autocomplete. Otherwise, 168 // If sync is not set, cull older entries of the autocomplete. Otherwise,
169 // the entries will be culled when sync is connected. 169 // the entries will be culled when sync is connected.
170 ProfileSyncService* sync_service = 170 ProfileSyncService* sync_service =
171 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); 171 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
172 if (sync_service && (!sync_service->HasSyncSetupCompleted() || 172 if (sync_service && (!sync_service->HasSyncSetupCompleted() ||
173 !profile_->GetPrefs()->GetBoolean(prefs::kSyncAutofill))) { 173 !PrefServiceBase::ForProfile(profile_)->GetBoolean(
174 prefs::kSyncAutofill))) {
174 scoped_refptr<WebDataService> web_data_service = 175 scoped_refptr<WebDataService> web_data_service =
175 WebDataServiceFactory::GetForProfile(profile_, 176 WebDataServiceFactory::GetForProfile(profile_,
176 Profile::EXPLICIT_ACCESS); 177 Profile::EXPLICIT_ACCESS);
177 if (web_data_service) 178 if (web_data_service)
178 web_data_service->RemoveExpiredFormElements(); 179 web_data_service->RemoveExpiredFormElements();
179 } 180 }
180 } 181 }
181 } 182 }
182 183
183 void PersonalDataManager::SetObserver(PersonalDataManagerObserver* observer) { 184 void PersonalDataManager::SetObserver(PersonalDataManagerObserver* observer) {
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 (*iter)->GetNonEmptyTypes(non_empty_types); 527 (*iter)->GetNonEmptyTypes(non_empty_types);
527 } 528 }
528 } 529 }
529 530
530 bool PersonalDataManager::IsDataLoaded() const { 531 bool PersonalDataManager::IsDataLoaded() const {
531 return is_data_loaded_; 532 return is_data_loaded_;
532 } 533 }
533 534
534 const std::vector<AutofillProfile*>& PersonalDataManager::profiles() const { 535 const std::vector<AutofillProfile*>& PersonalDataManager::profiles() const {
535 // |profile_| is NULL in AutofillManagerTest. 536 // |profile_| is NULL in AutofillManagerTest.
536 bool auxiliary_profiles_enabled = profile_ ? profile_->GetPrefs()->GetBoolean( 537 bool auxiliary_profiles_enabled = profile_ ?
537 prefs::kAutofillAuxiliaryProfilesEnabled) : false; 538 PrefServiceBase::ForProfile(profile_)->GetBoolean(
539 prefs::kAutofillAuxiliaryProfilesEnabled) :
540 false;
538 if (!auxiliary_profiles_enabled) 541 if (!auxiliary_profiles_enabled)
539 return web_profiles(); 542 return web_profiles();
540 543
541 #if !defined(OS_MACOSX) 544 #if !defined(OS_MACOSX)
542 NOTREACHED() << "Auxiliary profiles supported on Mac only"; 545 NOTREACHED() << "Auxiliary profiles supported on Mac only";
543 #endif 546 #endif
544 547
545 profiles_.clear(); 548 profiles_.clear();
546 549
547 // Populates |auxiliary_profiles_|. 550 // Populates |auxiliary_profiles_|.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 LoadProfiles(); 591 LoadProfiles();
589 LoadCreditCards(); 592 LoadCreditCards();
590 593
591 notification_registrar_.Add( 594 notification_registrar_.Add(
592 this, 595 this,
593 chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED, 596 chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED,
594 content::Source<WebDataService>(web_data_service)); 597 content::Source<WebDataService>(web_data_service));
595 } 598 }
596 599
597 bool PersonalDataManager::IsAutofillEnabled() const { 600 bool PersonalDataManager::IsAutofillEnabled() const {
598 return profile_->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); 601 return PrefServiceBase::ForProfile(profile_)->GetBoolean(
602 prefs::kAutofillEnabled);
599 } 603 }
600 604
601 // static 605 // static
602 bool PersonalDataManager::IsValidLearnableProfile( 606 bool PersonalDataManager::IsValidLearnableProfile(
603 const AutofillProfile& profile) { 607 const AutofillProfile& profile) {
604 if (!IsMinimumAddress(profile)) 608 if (!IsMinimumAddress(profile))
605 return false; 609 return false;
606 610
607 string16 email = profile.GetInfo(EMAIL_ADDRESS); 611 string16 email = profile.GetInfo(EMAIL_ADDRESS);
608 if (!email.empty() && !IsValidEmail(email)) 612 if (!email.empty() && !IsValidEmail(email))
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 } 945 }
942 946
943 const AutofillMetrics* PersonalDataManager::metric_logger() const { 947 const AutofillMetrics* PersonalDataManager::metric_logger() const {
944 return metric_logger_.get(); 948 return metric_logger_.get();
945 } 949 }
946 950
947 void PersonalDataManager::set_metric_logger( 951 void PersonalDataManager::set_metric_logger(
948 const AutofillMetrics* metric_logger) { 952 const AutofillMetrics* metric_logger) {
949 metric_logger_.reset(metric_logger); 953 metric_logger_.reset(metric_logger);
950 } 954 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager_unittest.cc ('k') | chrome/browser/captive_portal/captive_portal_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698