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 <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
15 #include "base/prefs/pref_service.h" | |
15 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "components/autofill/core/browser/autofill_metrics.h" | |
16 #include "components/autofill/core/browser/autofill_profile.h" | 18 #include "components/autofill/core/browser/autofill_profile.h" |
17 #include "components/autofill/core/browser/credit_card.h" | 19 #include "components/autofill/core/browser/credit_card.h" |
18 #include "components/autofill/core/browser/field_types.h" | 20 #include "components/autofill/core/browser/field_types.h" |
21 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | |
Ilya Sherman
2013/11/14 23:45:55
These should remain as forward-declarations in the
blundell
2013/11/15 16:04:54
Done for PrefService. The other two changes are ne
| |
19 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse rver.h" | 22 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse rver.h" |
20 #include "components/webdata/common/web_data_service_consumer.h" | 23 #include "components/webdata/common/web_data_service_consumer.h" |
21 | 24 |
22 class PrefService; | |
23 class RemoveAutofillTester; | 25 class RemoveAutofillTester; |
24 | 26 |
25 namespace content { | |
26 class BrowserContext; | |
27 } | |
28 | |
29 namespace autofill { | 27 namespace autofill { |
30 class AutofillInteractiveTest; | 28 class AutofillInteractiveTest; |
31 class AutofillMetrics; | |
32 class AutofillTest; | 29 class AutofillTest; |
33 class FormStructure; | 30 class FormStructure; |
34 class PersonalDataManagerObserver; | 31 class PersonalDataManagerObserver; |
35 class PersonalDataManagerFactory; | 32 class PersonalDataManagerFactory; |
36 } // namespace autofill | 33 } // namespace autofill |
37 | 34 |
38 namespace autofill_helper { | 35 namespace autofill_helper { |
39 void SetProfiles(int, std::vector<autofill::AutofillProfile>*); | 36 void SetProfiles(int, std::vector<autofill::AutofillProfile>*); |
40 void SetCreditCards(int, std::vector<autofill::CreditCard>*); | 37 void SetCreditCards(int, std::vector<autofill::CreditCard>*); |
41 } // namespace autofill_helper | 38 } // namespace autofill_helper |
42 | 39 |
43 namespace autofill { | 40 namespace autofill { |
44 | 41 |
45 // Handles loading and saving Autofill profile information to the web database. | 42 // Handles loading and saving Autofill profile information to the web database. |
46 // This class also stores the profiles loaded from the database for use during | 43 // This class also stores the profiles loaded from the database for use during |
47 // Autofill. | 44 // Autofill. |
48 class PersonalDataManager : public WebDataServiceConsumer, | 45 class PersonalDataManager : public WebDataServiceConsumer, |
49 public AutofillWebDataServiceObserverOnUIThread { | 46 public AutofillWebDataServiceObserverOnUIThread { |
50 public: | 47 public: |
51 // A pair of GUID and variant index. Represents a single FormGroup and a | 48 // A pair of GUID and variant index. Represents a single FormGroup and a |
52 // specific data variant. | 49 // specific data variant. |
53 typedef std::pair<std::string, size_t> GUIDPair; | 50 typedef std::pair<std::string, size_t> GUIDPair; |
54 | 51 |
55 explicit PersonalDataManager(const std::string& app_locale); | 52 explicit PersonalDataManager(const std::string& app_locale); |
56 virtual ~PersonalDataManager(); | 53 virtual ~PersonalDataManager(); |
57 | 54 |
58 // Kicks off asynchronous loading of profiles and credit cards. |context| and | 55 // Kicks off asynchronous loading of profiles and credit cards. |
59 // |pref_service| must outlive this instance. |is_off_the_record| informs | 56 // |pref_service| must outlive this instance. |is_off_the_record| informs |
60 // this instance whether the user is currently operating in an off-the-record | 57 // this instance whether the user is currently operating in an off-the-record |
61 // context. | 58 // context. |
62 void Init(content::BrowserContext* context, | 59 void Init(scoped_refptr<AutofillWebDataService> database, |
63 PrefService* pref_service, | 60 PrefService* pref_service, |
64 bool is_off_the_record); | 61 bool is_off_the_record); |
65 | 62 |
66 // WebDataServiceConsumer: | 63 // WebDataServiceConsumer: |
67 virtual void OnWebDataServiceRequestDone( | 64 virtual void OnWebDataServiceRequestDone( |
68 WebDataServiceBase::Handle h, | 65 WebDataServiceBase::Handle h, |
69 const WDTypedResult* result) OVERRIDE; | 66 const WDTypedResult* result) OVERRIDE; |
70 | 67 |
71 // AutofillWebDataServiceObserverOnUIThread: | 68 // AutofillWebDataServiceObserverOnUIThread: |
72 virtual void AutofillMultipleChanged() OVERRIDE; | 69 virtual void AutofillMultipleChanged() OVERRIDE; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 void CancelPendingQuery(WebDataServiceBase::Handle* handle); | 249 void CancelPendingQuery(WebDataServiceBase::Handle* handle); |
253 | 250 |
254 // The first time this is called, logs an UMA metrics for the number of | 251 // The first time this is called, logs an UMA metrics for the number of |
255 // profiles the user has. On subsequent calls, does nothing. | 252 // profiles the user has. On subsequent calls, does nothing. |
256 void LogProfileCount() const; | 253 void LogProfileCount() const; |
257 | 254 |
258 // Returns the value of the AutofillEnabled pref. | 255 // Returns the value of the AutofillEnabled pref. |
259 virtual bool IsAutofillEnabled() const; | 256 virtual bool IsAutofillEnabled() const; |
260 | 257 |
261 // For tests. | 258 // For tests. |
262 const AutofillMetrics* metric_logger() const; | 259 const AutofillMetrics* metric_logger() const { return metric_logger_.get(); } |
263 void set_metric_logger(const AutofillMetrics* metric_logger); | |
264 void set_browser_context(content::BrowserContext* context); | |
265 void set_pref_service(PrefService* pref_service); | |
266 | 260 |
267 // The browser context this PersonalDataManager is in. | 261 void set_database(scoped_refptr<AutofillWebDataService> database) { |
268 content::BrowserContext* browser_context_; | 262 database_ = database; |
263 } | |
264 | |
265 void set_metric_logger(const AutofillMetrics* metric_logger) { | |
266 metric_logger_.reset(metric_logger); | |
267 } | |
268 | |
269 void set_pref_service(PrefService* pref_service) { | |
270 pref_service_ = pref_service; | |
271 } | |
272 | |
273 // The backing database that this PersonalDataManager uses. | |
274 scoped_refptr<AutofillWebDataService> database_; | |
269 | 275 |
270 // True if personal data has been loaded from the web database. | 276 // True if personal data has been loaded from the web database. |
271 bool is_data_loaded_; | 277 bool is_data_loaded_; |
272 | 278 |
273 // The loaded web profiles. | 279 // The loaded web profiles. |
274 ScopedVector<AutofillProfile> web_profiles_; | 280 ScopedVector<AutofillProfile> web_profiles_; |
275 | 281 |
276 // Auxiliary profiles. | 282 // Auxiliary profiles. |
277 mutable ScopedVector<AutofillProfile> auxiliary_profiles_; | 283 mutable ScopedVector<AutofillProfile> auxiliary_profiles_; |
278 | 284 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 | 321 |
316 // Whether we have already logged the number of profiles this session. | 322 // Whether we have already logged the number of profiles this session. |
317 mutable bool has_logged_profile_count_; | 323 mutable bool has_logged_profile_count_; |
318 | 324 |
319 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 325 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
320 }; | 326 }; |
321 | 327 |
322 } // namespace autofill | 328 } // namespace autofill |
323 | 329 |
324 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 330 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
OLD | NEW |