OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/personal_data_manager.h" | 5 #include "components/autofill/core/browser/personal_data_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
11 #include <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "base/i18n/case_conversion.h" | 14 #include "base/i18n/case_conversion.h" |
15 #include "base/i18n/timezone.h" | 15 #include "base/i18n/timezone.h" |
16 #include "base/metrics/user_metrics.h" | |
16 #include "base/profiler/scoped_tracker.h" | 17 #include "base/profiler/scoped_tracker.h" |
17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
21 #include "components/autofill/core/browser/address_i18n.h" | 22 #include "components/autofill/core/browser/address_i18n.h" |
22 #include "components/autofill/core/browser/autofill-inl.h" | 23 #include "components/autofill/core/browser/autofill-inl.h" |
23 #include "components/autofill/core/browser/autofill_country.h" | 24 #include "components/autofill/core/browser/autofill_country.h" |
24 #include "components/autofill/core/browser/autofill_experiments.h" | 25 #include "components/autofill/core/browser/autofill_experiments.h" |
25 #include "components/autofill/core/browser/autofill_field.h" | 26 #include "components/autofill/core/browser/autofill_field.h" |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
674 } | 675 } |
675 | 676 |
676 std::vector<Suggestion> PersonalDataManager::GetProfileSuggestions( | 677 std::vector<Suggestion> PersonalDataManager::GetProfileSuggestions( |
677 const AutofillType& type, | 678 const AutofillType& type, |
678 const base::string16& field_contents, | 679 const base::string16& field_contents, |
679 bool field_is_autofilled, | 680 bool field_is_autofilled, |
680 const std::vector<ServerFieldType>& other_field_types) { | 681 const std::vector<ServerFieldType>& other_field_types) { |
681 if (IsInAutofillSuggestionsDisabledExperiment()) | 682 if (IsInAutofillSuggestionsDisabledExperiment()) |
682 return std::vector<Suggestion>(); | 683 return std::vector<Suggestion>(); |
683 | 684 |
685 base::RecordAction( | |
686 base::UserMetricsAction("Autofill_PolledProfileSuggestions")); | |
Mathieu
2016/04/11 16:45:46
would prefer a static method into AutofillMetrics
sebsg
2016/04/12 14:40:59
Done.
| |
687 | |
684 base::string16 field_contents_canon = | 688 base::string16 field_contents_canon = |
685 AutofillProfile::CanonicalizeProfileString(field_contents); | 689 AutofillProfile::CanonicalizeProfileString(field_contents); |
686 | 690 |
687 std::vector<AutofillProfile*> profiles = GetProfiles(true); | 691 std::vector<AutofillProfile*> profiles = GetProfiles(true); |
688 | 692 |
689 // Rank the suggestions by frecency (see AutofillDataModel for details). | 693 // Rank the suggestions by frecency (see AutofillDataModel for details). |
690 base::Time comparison_time = base::Time::Now(); | 694 base::Time comparison_time = base::Time::Now(); |
691 std::sort(profiles.begin(), profiles.end(), | 695 std::sort(profiles.begin(), profiles.end(), |
692 [comparison_time](const AutofillDataModel* a, | 696 [comparison_time](const AutofillDataModel* a, |
693 const AutofillDataModel* b) { | 697 const AutofillDataModel* b) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
776 | 780 |
777 return unique_suggestions; | 781 return unique_suggestions; |
778 } | 782 } |
779 | 783 |
780 std::vector<Suggestion> PersonalDataManager::GetCreditCardSuggestions( | 784 std::vector<Suggestion> PersonalDataManager::GetCreditCardSuggestions( |
781 const AutofillType& type, | 785 const AutofillType& type, |
782 const base::string16& field_contents) { | 786 const base::string16& field_contents) { |
783 if (IsInAutofillSuggestionsDisabledExperiment()) | 787 if (IsInAutofillSuggestionsDisabledExperiment()) |
784 return std::vector<Suggestion>(); | 788 return std::vector<Suggestion>(); |
785 | 789 |
790 base::RecordAction( | |
791 base::UserMetricsAction("Autofill_PolledCreditCardSuggestions")); | |
792 | |
786 std::list<const CreditCard*> cards_to_suggest; | 793 std::list<const CreditCard*> cards_to_suggest; |
787 std::list<const CreditCard*> substring_matched_cards; | 794 std::list<const CreditCard*> substring_matched_cards; |
788 base::string16 field_contents_lower = base::i18n::ToLower(field_contents); | 795 base::string16 field_contents_lower = base::i18n::ToLower(field_contents); |
789 for (const CreditCard* credit_card : GetCreditCards()) { | 796 for (const CreditCard* credit_card : GetCreditCards()) { |
790 // The value of the stored data for this field type in the |credit_card|. | 797 // The value of the stored data for this field type in the |credit_card|. |
791 base::string16 creditcard_field_value = | 798 base::string16 creditcard_field_value = |
792 credit_card->GetInfo(type, app_locale_); | 799 credit_card->GetInfo(type, app_locale_); |
793 if (creditcard_field_value.empty()) | 800 if (creditcard_field_value.empty()) |
794 continue; | 801 continue; |
795 base::string16 creditcard_field_lower = | 802 base::string16 creditcard_field_lower = |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1488 profiles_.insert(profiles_.end(), web_profiles().begin(), | 1495 profiles_.insert(profiles_.end(), web_profiles().begin(), |
1489 web_profiles().end()); | 1496 web_profiles().end()); |
1490 if (pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { | 1497 if (pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { |
1491 profiles_.insert( | 1498 profiles_.insert( |
1492 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); | 1499 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); |
1493 } | 1500 } |
1494 return profiles_; | 1501 return profiles_; |
1495 } | 1502 } |
1496 | 1503 |
1497 } // namespace autofill | 1504 } // namespace autofill |
OLD | NEW |