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

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

Issue 12340111: Introduce //components/user_prefs, use to eliminate c/b/prefs dependency in Autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 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 <functional> 8 #include <functional>
9 #include <iterator> 9 #include <iterator>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/api/sync/profile_sync_service_base.h" 15 #include "chrome/browser/api/sync/profile_sync_service_base.h"
16 #include "chrome/browser/api/webdata/autofill_web_data_service.h" 16 #include "chrome/browser/api/webdata/autofill_web_data_service.h"
17 #include "chrome/browser/autofill/autofill-inl.h" 17 #include "chrome/browser/autofill/autofill-inl.h"
18 #include "chrome/browser/autofill/autofill_country.h" 18 #include "chrome/browser/autofill/autofill_country.h"
19 #include "chrome/browser/autofill/autofill_field.h" 19 #include "chrome/browser/autofill/autofill_field.h"
20 #include "chrome/browser/autofill/autofill_metrics.h" 20 #include "chrome/browser/autofill/autofill_metrics.h"
21 #include "chrome/browser/autofill/form_group.h" 21 #include "chrome/browser/autofill/form_group.h"
22 #include "chrome/browser/autofill/form_structure.h" 22 #include "chrome/browser/autofill/form_structure.h"
23 #include "chrome/browser/autofill/personal_data_manager_observer.h" 23 #include "chrome/browser/autofill/personal_data_manager_observer.h"
24 #include "chrome/browser/autofill/phone_number.h" 24 #include "chrome/browser/autofill/phone_number.h"
25 #include "chrome/browser/autofill/phone_number_i18n.h" 25 #include "chrome/browser/autofill/phone_number_i18n.h"
26 #include "chrome/browser/autofill/validation.h" 26 #include "chrome/browser/autofill/validation.h"
27 #include "chrome/common/chrome_notification_types.h" 27 #include "chrome/common/chrome_notification_types.h"
28 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
29 #include "components/user_prefs/user_prefs.h"
29 #include "content/public/browser/browser_context.h" 30 #include "content/public/browser/browser_context.h"
30 #include "content/public/browser/notification_source.h" 31 #include "content/public/browser/notification_source.h"
31 32
32 using content::BrowserContext; 33 using content::BrowserContext;
33 34
34 namespace { 35 namespace {
35 36
36 const string16::value_type kCreditCardPrefix[] = {'*', 0}; 37 const string16::value_type kCreditCardPrefix[] = {'*', 0};
37 38
38 template<typename T> 39 template<typename T>
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 iter != credit_cards_.end(); ++iter) { 489 iter != credit_cards_.end(); ++iter) {
489 (*iter)->GetNonEmptyTypes(app_locale, non_empty_types); 490 (*iter)->GetNonEmptyTypes(app_locale, non_empty_types);
490 } 491 }
491 } 492 }
492 493
493 bool PersonalDataManager::IsDataLoaded() const { 494 bool PersonalDataManager::IsDataLoaded() const {
494 return is_data_loaded_; 495 return is_data_loaded_;
495 } 496 }
496 497
497 const std::vector<AutofillProfile*>& PersonalDataManager::GetProfiles() { 498 const std::vector<AutofillProfile*>& PersonalDataManager::GetProfiles() {
498 if (!PrefServiceFromBrowserContext(browser_context_)->GetBoolean( 499 if (!components::UserPrefs::Get(browser_context_)->GetBoolean(
499 prefs::kAutofillAuxiliaryProfilesEnabled)) { 500 prefs::kAutofillAuxiliaryProfilesEnabled)) {
500 return web_profiles(); 501 return web_profiles();
501 } 502 }
502 503
503 profiles_.clear(); 504 profiles_.clear();
504 505
505 // Populates |auxiliary_profiles_|. 506 // Populates |auxiliary_profiles_|.
506 LoadAuxiliaryProfiles(); 507 LoadAuxiliaryProfiles();
507 508
508 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); 509 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end());
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 LoadProfiles(); 664 LoadProfiles();
664 LoadCreditCards(); 665 LoadCreditCards();
665 666
666 notification_registrar_.Add( 667 notification_registrar_.Add(
667 this, 668 this,
668 chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED, 669 chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED,
669 autofill_data->GetNotificationSource()); 670 autofill_data->GetNotificationSource());
670 } 671 }
671 672
672 bool PersonalDataManager::IsAutofillEnabled() const { 673 bool PersonalDataManager::IsAutofillEnabled() const {
673 return PrefServiceFromBrowserContext(browser_context_)->GetBoolean( 674 return components::UserPrefs::Get(browser_context_)->GetBoolean(
674 prefs::kAutofillEnabled); 675 prefs::kAutofillEnabled);
675 } 676 }
676 677
677 // static 678 // static
678 bool PersonalDataManager::IsValidLearnableProfile( 679 bool PersonalDataManager::IsValidLearnableProfile(
679 const AutofillProfile& profile) { 680 const AutofillProfile& profile) {
680 if (!IsMinimumAddress(profile)) 681 if (!IsMinimumAddress(profile))
681 return false; 682 return false;
682 683
683 string16 email = profile.GetRawInfo(EMAIL_ADDRESS); 684 string16 email = profile.GetRawInfo(EMAIL_ADDRESS);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 1024
1024 void PersonalDataManager::set_metric_logger( 1025 void PersonalDataManager::set_metric_logger(
1025 const AutofillMetrics* metric_logger) { 1026 const AutofillMetrics* metric_logger) {
1026 metric_logger_.reset(metric_logger); 1027 metric_logger_.reset(metric_logger);
1027 } 1028 }
1028 1029
1029 void PersonalDataManager::set_browser_context( 1030 void PersonalDataManager::set_browser_context(
1030 content::BrowserContext* context) { 1031 content::BrowserContext* context) {
1031 browser_context_ = context; 1032 browser_context_ = context;
1032 } 1033 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698