Chromium Code Reviews| 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 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 | 14 |
| 15 #include "base/i18n/case_conversion.h" | 15 #include "base/i18n/case_conversion.h" |
| 16 #include "base/i18n/timezone.h" | 16 #include "base/i18n/timezone.h" |
| 17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 18 #include "base/profiler/scoped_tracker.h" | 18 #include "base/profiler/scoped_tracker.h" |
| 19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "components/autofill/core/browser/address_i18n.h" | 23 #include "components/autofill/core/browser/address_i18n.h" |
| 24 #include "components/autofill/core/browser/autofill-inl.h" | 24 #include "components/autofill/core/browser/autofill-inl.h" |
| 25 #include "components/autofill/core/browser/autofill_country.h" | 25 #include "components/autofill/core/browser/autofill_country.h" |
| 26 #include "components/autofill/core/browser/autofill_experiments.h" | 26 #include "components/autofill/core/browser/autofill_experiments.h" |
| 27 #include "components/autofill/core/browser/autofill_field.h" | 27 #include "components/autofill/core/browser/autofill_field.h" |
| 28 #include "components/autofill/core/browser/autofill_metrics.h" | |
| 29 #include "components/autofill/core/browser/autofill_profile_comparator.h" | 28 #include "components/autofill/core/browser/autofill_profile_comparator.h" |
| 29 #include "components/autofill/core/browser/autofill_ukm.h" | |
| 30 #include "components/autofill/core/browser/country_data.h" | 30 #include "components/autofill/core/browser/country_data.h" |
| 31 #include "components/autofill/core/browser/country_names.h" | 31 #include "components/autofill/core/browser/country_names.h" |
| 32 #include "components/autofill/core/browser/form_structure.h" | 32 #include "components/autofill/core/browser/form_structure.h" |
| 33 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 33 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 34 #include "components/autofill/core/browser/phone_number.h" | 34 #include "components/autofill/core/browser/phone_number.h" |
| 35 #include "components/autofill/core/browser/phone_number_i18n.h" | 35 #include "components/autofill/core/browser/phone_number_i18n.h" |
| 36 #include "components/autofill/core/browser/validation.h" | 36 #include "components/autofill/core/browser/validation.h" |
| 37 #include "components/autofill/core/common/autofill_clock.h" | 37 #include "components/autofill/core/common/autofill_clock.h" |
| 38 #include "components/autofill/core/common/autofill_pref_names.h" | 38 #include "components/autofill/core/common/autofill_pref_names.h" |
| 39 #include "components/autofill/core/common/autofill_switches.h" | 39 #include "components/autofill/core/common/autofill_switches.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 } | 247 } |
| 248 | 248 |
| 249 return false; | 249 return false; |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace | 252 } // namespace |
| 253 | 253 |
| 254 const char kFrecencyFieldTrialName[] = "AutofillProfileOrderByFrecency"; | 254 const char kFrecencyFieldTrialName[] = "AutofillProfileOrderByFrecency"; |
| 255 const char kFrecencyFieldTrialLimitParam[] = "limit"; | 255 const char kFrecencyFieldTrialLimitParam[] = "limit"; |
| 256 | 256 |
| 257 PersonalDataManager::PersonalDataManager(const std::string& app_locale) | 257 PersonalDataManager::PersonalDataManager(const std::string& app_locale, |
| 258 ukm::UkmService* ukm_service) | |
| 258 : database_(nullptr), | 259 : database_(nullptr), |
| 259 is_data_loaded_(false), | 260 is_data_loaded_(false), |
| 260 pending_profiles_query_(0), | 261 pending_profiles_query_(0), |
| 261 pending_server_profiles_query_(0), | 262 pending_server_profiles_query_(0), |
| 262 pending_creditcards_query_(0), | 263 pending_creditcards_query_(0), |
| 263 pending_server_creditcards_query_(0), | 264 pending_server_creditcards_query_(0), |
| 264 app_locale_(app_locale), | 265 app_locale_(app_locale), |
| 265 pref_service_(nullptr), | 266 pref_service_(nullptr), |
| 266 account_tracker_(nullptr), | 267 account_tracker_(nullptr), |
| 267 is_off_the_record_(false), | 268 is_off_the_record_(false), |
| 268 has_logged_profile_count_(false), | 269 has_logged_profile_count_(false), |
| 269 has_logged_local_credit_card_count_(false), | 270 has_logged_local_credit_card_count_(false), |
| 270 has_logged_server_credit_card_counts_(false) {} | 271 has_logged_server_credit_card_counts_(false), |
| 272 autofill_ukm_( | |
|
Mathieu
2017/03/08 22:33:49
autofill_ukm_(base::MakeUnique<AutofillUkm>(ukm_se
| |
| 273 std::unique_ptr<AutofillUkm>(new AutofillUkm(ukm_service))) {} | |
| 271 | 274 |
| 272 void PersonalDataManager::Init(scoped_refptr<AutofillWebDataService> database, | 275 void PersonalDataManager::Init(scoped_refptr<AutofillWebDataService> database, |
| 273 PrefService* pref_service, | 276 PrefService* pref_service, |
| 274 AccountTrackerService* account_tracker, | 277 AccountTrackerService* account_tracker, |
| 275 SigninManagerBase* signin_manager, | 278 SigninManagerBase* signin_manager, |
| 276 bool is_off_the_record) { | 279 bool is_off_the_record) { |
| 277 CountryNames::SetLocaleString(app_locale_); | 280 CountryNames::SetLocaleString(app_locale_); |
| 278 | 281 |
| 279 database_ = database; | 282 database_ = database; |
| 280 SetPrefService(pref_service); | 283 SetPrefService(pref_service); |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 910 bool a_is_expired = a->IsExpired(comparison_time); | 913 bool a_is_expired = a->IsExpired(comparison_time); |
| 911 if (a_is_expired != b->IsExpired(comparison_time)) | 914 if (a_is_expired != b->IsExpired(comparison_time)) |
| 912 return !a_is_expired; | 915 return !a_is_expired; |
| 913 | 916 |
| 914 return a->CompareFrecency(b, comparison_time); | 917 return a->CompareFrecency(b, comparison_time); |
| 915 }); | 918 }); |
| 916 | 919 |
| 917 return cards_to_suggest; | 920 return cards_to_suggest; |
| 918 } | 921 } |
| 919 | 922 |
| 923 void PersonalDataManager::SetCardUploadDecisionMetricUrlUkm(const GURL& url) { | |
| 924 autofill_ukm_->SetCardUploadDecisionMetricUrl(url); | |
| 925 } | |
| 926 | |
| 927 void PersonalDataManager::LogCardUploadDecisionMetricUkm( | |
| 928 AutofillMetrics::CardUploadDecisionMetric upload_decision) { | |
| 929 autofill_ukm_->LogCardUploadDecisionMetric(upload_decision); | |
| 930 } | |
| 931 | |
| 920 std::vector<Suggestion> PersonalDataManager::GetCreditCardSuggestions( | 932 std::vector<Suggestion> PersonalDataManager::GetCreditCardSuggestions( |
| 921 const AutofillType& type, | 933 const AutofillType& type, |
| 922 const base::string16& field_contents) { | 934 const base::string16& field_contents) { |
| 923 if (IsInAutofillSuggestionsDisabledExperiment()) | 935 if (IsInAutofillSuggestionsDisabledExperiment()) |
| 924 return std::vector<Suggestion>(); | 936 return std::vector<Suggestion>(); |
| 925 | 937 |
| 926 return GetSuggestionsForCards(type, field_contents, | 938 return GetSuggestionsForCards(type, field_contents, |
| 927 GetCreditCardsToSuggest()); | 939 GetCreditCardsToSuggest()); |
| 928 } | 940 } |
| 929 | 941 |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1939 existing_profiles->back().SetRawInfo(EMAIL_ADDRESS, email); | 1951 existing_profiles->back().SetRawInfo(EMAIL_ADDRESS, email); |
| 1940 | 1952 |
| 1941 AutofillMetrics::LogWalletAddressConversionType( | 1953 AutofillMetrics::LogWalletAddressConversionType( |
| 1942 AutofillMetrics::CONVERTED_ADDRESS_ADDED); | 1954 AutofillMetrics::CONVERTED_ADDRESS_ADDED); |
| 1943 } | 1955 } |
| 1944 | 1956 |
| 1945 return guid; | 1957 return guid; |
| 1946 } | 1958 } |
| 1947 | 1959 |
| 1948 } // namespace autofill | 1960 } // namespace autofill |
| OLD | NEW |