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

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::GetInstance()->Lookup(
499 prefs::kAutofillAuxiliaryProfilesEnabled)) { 500 browser_context_)->GetBoolean(
501 prefs::kAutofillAuxiliaryProfilesEnabled)) {
500 return web_profiles(); 502 return web_profiles();
501 } 503 }
502 504
503 profiles_.clear(); 505 profiles_.clear();
504 506
505 // Populates |auxiliary_profiles_|. 507 // Populates |auxiliary_profiles_|.
506 LoadAuxiliaryProfiles(); 508 LoadAuxiliaryProfiles();
507 509
508 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); 510 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end());
509 profiles_.insert(profiles_.end(), 511 profiles_.insert(profiles_.end(),
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 LoadProfiles(); 665 LoadProfiles();
664 LoadCreditCards(); 666 LoadCreditCards();
665 667
666 notification_registrar_.Add( 668 notification_registrar_.Add(
667 this, 669 this,
668 chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED, 670 chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED,
669 autofill_data->GetNotificationSource()); 671 autofill_data->GetNotificationSource());
670 } 672 }
671 673
672 bool PersonalDataManager::IsAutofillEnabled() const { 674 bool PersonalDataManager::IsAutofillEnabled() const {
673 return PrefServiceFromBrowserContext(browser_context_)->GetBoolean( 675 return components::UserPrefs::GetInstance()->Lookup(
674 prefs::kAutofillEnabled); 676 browser_context_)->GetBoolean(prefs::kAutofillEnabled);
675 } 677 }
676 678
677 // static 679 // static
678 bool PersonalDataManager::IsValidLearnableProfile( 680 bool PersonalDataManager::IsValidLearnableProfile(
679 const AutofillProfile& profile) { 681 const AutofillProfile& profile) {
680 if (!IsMinimumAddress(profile)) 682 if (!IsMinimumAddress(profile))
681 return false; 683 return false;
682 684
683 string16 email = profile.GetRawInfo(EMAIL_ADDRESS); 685 string16 email = profile.GetRawInfo(EMAIL_ADDRESS);
684 if (!email.empty() && !autofill::IsValidEmailAddress(email)) 686 if (!email.empty() && !autofill::IsValidEmailAddress(email))
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 1025
1024 void PersonalDataManager::set_metric_logger( 1026 void PersonalDataManager::set_metric_logger(
1025 const AutofillMetrics* metric_logger) { 1027 const AutofillMetrics* metric_logger) {
1026 metric_logger_.reset(metric_logger); 1028 metric_logger_.reset(metric_logger);
1027 } 1029 }
1028 1030
1029 void PersonalDataManager::set_browser_context( 1031 void PersonalDataManager::set_browser_context(
1030 content::BrowserContext* context) { 1032 content::BrowserContext* context) {
1031 browser_context_ = context; 1033 browser_context_ = context;
1032 } 1034 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698