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

Side by Side Diff: components/autofill/core/browser/personal_data_manager.h

Issue 2740633002: [Autofill] Add upstreaming UKM (Closed)
Patch Set: Created 3 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
OLDNEW
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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <unordered_map> 12 #include <unordered_map>
13 #include <unordered_set> 13 #include <unordered_set>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/observer_list.h" 18 #include "base/observer_list.h"
19 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
20 #include "build/build_config.h" 20 #include "build/build_config.h"
21 #include "components/autofill/core/browser/autofill_metrics.h"
21 #include "components/autofill/core/browser/autofill_profile.h" 22 #include "components/autofill/core/browser/autofill_profile.h"
22 #include "components/autofill/core/browser/credit_card.h" 23 #include "components/autofill/core/browser/credit_card.h"
23 #include "components/autofill/core/browser/field_types.h" 24 #include "components/autofill/core/browser/field_types.h"
24 #include "components/autofill/core/browser/suggestion.h" 25 #include "components/autofill/core/browser/suggestion.h"
25 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" 26 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
26 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse rver.h" 27 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse rver.h"
27 #include "components/keyed_service/core/keyed_service.h" 28 #include "components/keyed_service/core/keyed_service.h"
28 #include "components/prefs/pref_member.h" 29 #include "components/prefs/pref_member.h"
29 #include "components/webdata/common/web_data_service_consumer.h" 30 #include "components/webdata/common/web_data_service_consumer.h"
30 #if defined(OS_ANDROID) 31 #if defined(OS_ANDROID)
31 #include "net/url_request/url_request_context_getter.h" 32 #include "net/url_request/url_request_context_getter.h"
32 #endif 33 #endif
33 34
34 class AccountTrackerService; 35 class AccountTrackerService;
35 class Browser; 36 class Browser;
36 class PrefService; 37 class PrefService;
37 class RemoveAutofillTester; 38 class RemoveAutofillTester;
38 class SigninManagerBase; 39 class SigninManagerBase;
39 40
40 namespace autofill { 41 namespace autofill {
41 class AutofillInteractiveTest; 42 class AutofillInteractiveTest;
42 class AutofillTest; 43 class AutofillTest;
44 class AutofillUkm;
43 class FormStructure; 45 class FormStructure;
44 class PersonalDataManagerObserver; 46 class PersonalDataManagerObserver;
45 class PersonalDataManagerFactory; 47 class PersonalDataManagerFactory;
46 } // namespace autofill 48 } // namespace autofill
47 49
48 namespace autofill_helper { 50 namespace autofill_helper {
49 void SetProfiles(int, std::vector<autofill::AutofillProfile>*); 51 void SetProfiles(int, std::vector<autofill::AutofillProfile>*);
50 void SetCreditCards(int, std::vector<autofill::CreditCard>*); 52 void SetCreditCards(int, std::vector<autofill::CreditCard>*);
51 } // namespace autofill_helper 53 } // namespace autofill_helper
52 54
53 namespace syncer { 55 namespace syncer {
54 class SyncService; 56 class SyncService;
55 } // namespace syncer 57 } // namespace syncer
56 58
59 namespace ukm {
60 class UkmService;
61 } // namespace ukm
62
57 namespace autofill { 63 namespace autofill {
58 64
59 extern const char kFrecencyFieldTrialName[]; 65 extern const char kFrecencyFieldTrialName[];
60 extern const char kFrecencyFieldTrialStateEnabled[]; 66 extern const char kFrecencyFieldTrialStateEnabled[];
61 extern const char kFrecencyFieldTrialLimitParam[]; 67 extern const char kFrecencyFieldTrialLimitParam[];
62 68
63 // Handles loading and saving Autofill profile information to the web database. 69 // Handles loading and saving Autofill profile information to the web database.
64 // This class also stores the profiles loaded from the database for use during 70 // This class also stores the profiles loaded from the database for use during
65 // Autofill. 71 // Autofill.
66 class PersonalDataManager : public KeyedService, 72 class PersonalDataManager : public KeyedService,
67 public WebDataServiceConsumer, 73 public WebDataServiceConsumer,
68 public AutofillWebDataServiceObserverOnUIThread { 74 public AutofillWebDataServiceObserverOnUIThread {
69 public: 75 public:
70 explicit PersonalDataManager(const std::string& app_locale); 76 explicit PersonalDataManager(const std::string& app_locale,
77 ukm::UkmService* ukm_service);
71 ~PersonalDataManager() override; 78 ~PersonalDataManager() override;
72 79
73 // Kicks off asynchronous loading of profiles and credit cards. 80 // Kicks off asynchronous loading of profiles and credit cards.
74 // |pref_service| must outlive this instance. |is_off_the_record| informs 81 // |pref_service| must outlive this instance. |is_off_the_record| informs
75 // this instance whether the user is currently operating in an off-the-record 82 // this instance whether the user is currently operating in an off-the-record
76 // context. 83 // context.
77 void Init(scoped_refptr<AutofillWebDataService> database, 84 void Init(scoped_refptr<AutofillWebDataService> database,
78 PrefService* pref_service, 85 PrefService* pref_service,
79 AccountTrackerService* account_tracker, 86 AccountTrackerService* account_tracker,
80 SigninManagerBase* signin_manager, 87 SigninManagerBase* signin_manager,
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // inputting a new address. The value is calculated once and cached, so it 269 // inputting a new address. The value is calculated once and cached, so it
263 // will only update when Chrome is restarted. 270 // will only update when Chrome is restarted.
264 virtual const std::string& GetDefaultCountryCodeForNewAddress() const; 271 virtual const std::string& GetDefaultCountryCodeForNewAddress() const;
265 272
266 // De-dupe credit card to suggest. Full server cards are preferred over their 273 // De-dupe credit card to suggest. Full server cards are preferred over their
267 // local duplicates, and local cards are preferred over their masked server 274 // local duplicates, and local cards are preferred over their masked server
268 // card duplicate. 275 // card duplicate.
269 static void DedupeCreditCardToSuggest( 276 static void DedupeCreditCardToSuggest(
270 std::list<CreditCard*>* cards_to_suggest); 277 std::list<CreditCard*>* cards_to_suggest);
271 278
279 // Sets the URL to be used when logging the next card upload decision metric.
280 void SetCardUploadDecisionMetricUrlUkm(const GURL& url);
281
282 // Logs the card upload decision metric based on the set URL. Does nothing if
283 // no URL is set. Resets the URL after the log.
284 void LogCardUploadDecisionMetricUkm(
285 AutofillMetrics::CardUploadDecisionMetric upload_decision);
286
272 // Notifies test observers that personal data has changed. 287 // Notifies test observers that personal data has changed.
273 void NotifyPersonalDataChangedForTest() { 288 void NotifyPersonalDataChangedForTest() {
274 NotifyPersonalDataChanged(); 289 NotifyPersonalDataChanged();
275 } 290 }
276 291
277 #if defined(OS_ANDROID) 292 #if defined(OS_ANDROID)
278 // Sets the URL request context getter to be used when normalizing addresses 293 // Sets the URL request context getter to be used when normalizing addresses
279 // with libaddressinput's address validator. 294 // with libaddressinput's address validator.
280 void SetURLRequestContextGetter( 295 void SetURLRequestContextGetter(
281 net::URLRequestContextGetter* context_getter) { 296 net::URLRequestContextGetter* context_getter) {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 582
568 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled. 583 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled.
569 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_; 584 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_;
570 585
571 // True if autofill profile cleanup needs to be performed. 586 // True if autofill profile cleanup needs to be performed.
572 bool is_autofill_profile_cleanup_pending_ = false; 587 bool is_autofill_profile_cleanup_pending_ = false;
573 588
574 // Whether new information was received from the sync server. 589 // Whether new information was received from the sync server.
575 bool has_synced_new_data_ = false; 590 bool has_synced_new_data_ = false;
576 591
592 std::unique_ptr<AutofillUkm> autofill_ukm_;
593
577 #if defined(OS_ANDROID) 594 #if defined(OS_ANDROID)
578 // The context for the request to be used to fetch libaddressinput's address 595 // The context for the request to be used to fetch libaddressinput's address
579 // validation rules. 596 // validation rules.
580 scoped_refptr<net::URLRequestContextGetter> context_getter_; 597 scoped_refptr<net::URLRequestContextGetter> context_getter_;
581 #endif 598 #endif
582 599
583 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); 600 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager);
584 }; 601 };
585 602
586 } // namespace autofill 603 } // namespace autofill
587 604
588 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ 605 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698