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 #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 <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "components/autofill/core/browser/autofill_profile.h" | 18 #include "components/autofill/core/browser/autofill_profile.h" |
19 #include "components/autofill/core/browser/credit_card.h" | 19 #include "components/autofill/core/browser/credit_card.h" |
20 #include "components/autofill/core/browser/field_types.h" | 20 #include "components/autofill/core/browser/field_types.h" |
21 #include "components/autofill/core/browser/suggestion.h" | 21 #include "components/autofill/core/browser/suggestion.h" |
22 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 22 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
23 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse
rver.h" | 23 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse
rver.h" |
24 #include "components/keyed_service/core/keyed_service.h" | 24 #include "components/keyed_service/core/keyed_service.h" |
25 #include "components/prefs/pref_member.h" | 25 #include "components/prefs/pref_member.h" |
26 #include "components/webdata/common/web_data_service_consumer.h" | 26 #include "components/webdata/common/web_data_service_consumer.h" |
| 27 #include "net/url_request/url_fetcher_delegate.h" |
27 | 28 |
28 class AccountTrackerService; | 29 class AccountTrackerService; |
29 class Browser; | 30 class Browser; |
30 class PrefService; | 31 class PrefService; |
31 class RemoveAutofillTester; | 32 class RemoveAutofillTester; |
32 class SigninManagerBase; | 33 class SigninManagerBase; |
33 | 34 |
| 35 namespace net { |
| 36 class URLFetcher; |
| 37 class URLRequestContextGetter; |
| 38 } |
| 39 |
34 namespace sync_driver { | 40 namespace sync_driver { |
35 class SyncService; | 41 class SyncService; |
36 } | 42 } |
37 | 43 |
38 namespace autofill { | 44 namespace autofill { |
39 class AutofillInteractiveTest; | 45 class AutofillInteractiveTest; |
40 class AutofillTest; | 46 class AutofillTest; |
41 class FormStructure; | 47 class FormStructure; |
42 class PersonalDataManagerObserver; | 48 class PersonalDataManagerObserver; |
43 class PersonalDataManagerFactory; | 49 class PersonalDataManagerFactory; |
(...skipping 10 matching lines...) Expand all Loading... |
54 extern const char kFrecencyFieldTrialStateEnabled[]; | 60 extern const char kFrecencyFieldTrialStateEnabled[]; |
55 extern const char kFrecencyFieldTrialLimitParam[]; | 61 extern const char kFrecencyFieldTrialLimitParam[]; |
56 | 62 |
57 // Handles loading and saving Autofill profile information to the web database. | 63 // Handles loading and saving Autofill profile information to the web database. |
58 // This class also stores the profiles loaded from the database for use during | 64 // This class also stores the profiles loaded from the database for use during |
59 // Autofill. | 65 // Autofill. |
60 class PersonalDataManager : public KeyedService, | 66 class PersonalDataManager : public KeyedService, |
61 public WebDataServiceConsumer, | 67 public WebDataServiceConsumer, |
62 public AutofillWebDataServiceObserverOnUIThread { | 68 public AutofillWebDataServiceObserverOnUIThread { |
63 public: | 69 public: |
64 explicit PersonalDataManager(const std::string& app_locale); | 70 explicit PersonalDataManager(const std::string& app_locale, |
| 71 net::URLRequestContextGetter* context_getter); |
65 ~PersonalDataManager() override; | 72 ~PersonalDataManager() override; |
66 | 73 |
67 // Kicks off asynchronous loading of profiles and credit cards. | 74 // Kicks off asynchronous loading of profiles and credit cards. |
68 // |pref_service| must outlive this instance. |is_off_the_record| informs | 75 // |pref_service| must outlive this instance. |is_off_the_record| informs |
69 // this instance whether the user is currently operating in an off-the-record | 76 // this instance whether the user is currently operating in an off-the-record |
70 // context. | 77 // context. |
71 void Init(scoped_refptr<AutofillWebDataService> database, | 78 void Init(scoped_refptr<AutofillWebDataService> database, |
72 PrefService* pref_service, | 79 PrefService* pref_service, |
73 AccountTrackerService* account_tracker, | 80 AccountTrackerService* account_tracker, |
74 SigninManagerBase* signin_manager, | 81 SigninManagerBase* signin_manager, |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 // local duplicates, and local cards are preferred over their masked server | 260 // local duplicates, and local cards are preferred over their masked server |
254 // card duplicate. | 261 // card duplicate. |
255 static void DedupeCreditCardToSuggest( | 262 static void DedupeCreditCardToSuggest( |
256 std::list<CreditCard*>* cards_to_suggest); | 263 std::list<CreditCard*>* cards_to_suggest); |
257 | 264 |
258 // Notifies test observers that personal data has changed. | 265 // Notifies test observers that personal data has changed. |
259 void NotifyPersonalDataChangedForTest() { | 266 void NotifyPersonalDataChangedForTest() { |
260 NotifyPersonalDataChanged(); | 267 NotifyPersonalDataChanged(); |
261 } | 268 } |
262 | 269 |
| 270 // Returns the class used to fetch the address validation rules. |
| 271 net::URLRequestContextGetter* GetURLRequestContextGetter() const { |
| 272 return context_getter_.get(); |
| 273 } |
| 274 |
263 protected: | 275 protected: |
264 // Only PersonalDataManagerFactory and certain tests can create instances of | 276 // Only PersonalDataManagerFactory and certain tests can create instances of |
265 // PersonalDataManager. | 277 // PersonalDataManager. |
266 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FirstMiddleLast); | 278 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, FirstMiddleLast); |
267 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtStartup); | 279 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutofillIsEnabledAtStartup); |
268 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 280 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
269 DedupeProfiles_ProfilesToDelete); | 281 DedupeProfiles_ProfilesToDelete); |
270 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, ApplyProfileUseDatesFix); | 282 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, ApplyProfileUseDatesFix); |
271 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, | 283 FRIEND_TEST_ALL_PREFIXES(PersonalDataManagerTest, |
272 ApplyProfileUseDatesFix_NotAppliedTwice); | 284 ApplyProfileUseDatesFix_NotAppliedTwice); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 // An observer to listen for changes to prefs::kAutofillEnabled. | 498 // An observer to listen for changes to prefs::kAutofillEnabled. |
487 std::unique_ptr<BooleanPrefMember> enabled_pref_; | 499 std::unique_ptr<BooleanPrefMember> enabled_pref_; |
488 | 500 |
489 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled. | 501 // An observer to listen for changes to prefs::kAutofillWalletImportEnabled. |
490 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_; | 502 std::unique_ptr<BooleanPrefMember> wallet_enabled_pref_; |
491 | 503 |
492 // Set to true if autofill profile deduplication is enabled and needs to be | 504 // Set to true if autofill profile deduplication is enabled and needs to be |
493 // performed on the next data refresh. | 505 // performed on the next data refresh. |
494 bool is_autofill_profile_dedupe_pending_ = false; | 506 bool is_autofill_profile_dedupe_pending_ = false; |
495 | 507 |
| 508 // The context for the request to be used to fetch libaddressinput's address |
| 509 // validation rules. |
| 510 scoped_refptr<net::URLRequestContextGetter> context_getter_; |
| 511 |
496 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 512 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
497 }; | 513 }; |
498 | 514 |
499 } // namespace autofill | 515 } // namespace autofill |
500 | 516 |
501 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 517 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
OLD | NEW |