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

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: Pure merge of LKGR 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 iter != credit_cards_.end(); ++iter) { 511 iter != credit_cards_.end(); ++iter) {
511 (*iter)->GetNonEmptyTypes(app_locale, non_empty_types); 512 (*iter)->GetNonEmptyTypes(app_locale, non_empty_types);
512 } 513 }
513 } 514 }
514 515
515 bool PersonalDataManager::IsDataLoaded() const { 516 bool PersonalDataManager::IsDataLoaded() const {
516 return is_data_loaded_; 517 return is_data_loaded_;
517 } 518 }
518 519
519 const std::vector<AutofillProfile*>& PersonalDataManager::GetProfiles() { 520 const std::vector<AutofillProfile*>& PersonalDataManager::GetProfiles() {
520 if (!PrefServiceFromBrowserContext(browser_context_)->GetBoolean( 521 if (!components::UserPrefs::Get(browser_context_)->GetBoolean(
521 prefs::kAutofillAuxiliaryProfilesEnabled)) { 522 prefs::kAutofillAuxiliaryProfilesEnabled)) {
522 return web_profiles(); 523 return web_profiles();
523 } 524 }
524 525
525 profiles_.clear(); 526 profiles_.clear();
526 527
527 // Populates |auxiliary_profiles_|. 528 // Populates |auxiliary_profiles_|.
528 LoadAuxiliaryProfiles(); 529 LoadAuxiliaryProfiles();
529 530
530 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); 531 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end());
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 658
658 values->push_back(creditcard_field_value); 659 values->push_back(creditcard_field_value);
659 labels->push_back(label); 660 labels->push_back(label);
660 icons->push_back(UTF8ToUTF16(credit_card->type())); 661 icons->push_back(UTF8ToUTF16(credit_card->type()));
661 guid_pairs->push_back(GUIDPair(credit_card->guid(), 0)); 662 guid_pairs->push_back(GUIDPair(credit_card->guid(), 0));
662 } 663 }
663 } 664 }
664 } 665 }
665 666
666 bool PersonalDataManager::IsAutofillEnabled() const { 667 bool PersonalDataManager::IsAutofillEnabled() const {
667 return PrefServiceFromBrowserContext(browser_context_)->GetBoolean( 668 return components::UserPrefs::Get(browser_context_)->GetBoolean(
668 prefs::kAutofillEnabled); 669 prefs::kAutofillEnabled);
669 } 670 }
670 671
671 // static 672 // static
672 bool PersonalDataManager::IsValidLearnableProfile( 673 bool PersonalDataManager::IsValidLearnableProfile(
673 const AutofillProfile& profile) { 674 const AutofillProfile& profile) {
674 if (!IsMinimumAddress(profile)) 675 if (!IsMinimumAddress(profile))
675 return false; 676 return false;
676 677
677 string16 email = profile.GetRawInfo(EMAIL_ADDRESS); 678 string16 email = profile.GetRawInfo(EMAIL_ADDRESS);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 1018
1018 void PersonalDataManager::set_metric_logger( 1019 void PersonalDataManager::set_metric_logger(
1019 const AutofillMetrics* metric_logger) { 1020 const AutofillMetrics* metric_logger) {
1020 metric_logger_.reset(metric_logger); 1021 metric_logger_.reset(metric_logger);
1021 } 1022 }
1022 1023
1023 void PersonalDataManager::set_browser_context( 1024 void PersonalDataManager::set_browser_context(
1024 content::BrowserContext* context) { 1025 content::BrowserContext* context) {
1025 browser_context_ = context; 1026 browser_context_ = context;
1026 } 1027 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698