| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_PERSONAL_DATA_MANAGER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_PERSONAL_DATA_MANAGER_H_ |
| 6 #define COMPONENTS_AUTOFILL_BROWSER_PERSONAL_DATA_MANAGER_H_ | 6 #define COMPONENTS_AUTOFILL_BROWSER_PERSONAL_DATA_MANAGER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 class PersonalDataManagerFactory; | 33 class PersonalDataManagerFactory; |
| 34 } // namespace autofill | 34 } // namespace autofill |
| 35 | 35 |
| 36 namespace autofill_helper { | 36 namespace autofill_helper { |
| 37 void SetProfiles(int, std::vector<autofill::AutofillProfile>*); | 37 void SetProfiles(int, std::vector<autofill::AutofillProfile>*); |
| 38 void SetCreditCards(int, std::vector<autofill::CreditCard>*); | 38 void SetCreditCards(int, std::vector<autofill::CreditCard>*); |
| 39 } // namespace autofill_helper | 39 } // namespace autofill_helper |
| 40 | 40 |
| 41 namespace autofill { | 41 namespace autofill { |
| 42 | 42 |
| 43 class AutofillWebDataService; |
| 44 |
| 43 // Handles loading and saving Autofill profile information to the web database. | 45 // Handles loading and saving Autofill profile information to the web database. |
| 44 // This class also stores the profiles loaded from the database for use during | 46 // This class also stores the profiles loaded from the database for use during |
| 45 // Autofill. | 47 // Autofill. |
| 46 class PersonalDataManager : public WebDataServiceConsumer, | 48 class AUTOFILL_EXPORT PersonalDataManager |
| 47 public AutofillWebDataServiceObserverOnUIThread { | 49 : public WebDataServiceConsumer, |
| 50 public AutofillWebDataServiceObserverOnUIThread { |
| 48 public: | 51 public: |
| 49 // A pair of GUID and variant index. Represents a single FormGroup and a | 52 // A pair of GUID and variant index. Represents a single FormGroup and a |
| 50 // specific data variant. | 53 // specific data variant. |
| 51 typedef std::pair<std::string, size_t> GUIDPair; | 54 typedef std::pair<std::string, size_t> GUIDPair; |
| 52 | 55 |
| 53 explicit PersonalDataManager(const std::string& app_locale); | 56 explicit PersonalDataManager(const std::string& app_locale); |
| 54 virtual ~PersonalDataManager(); | 57 virtual ~PersonalDataManager(); |
| 55 | 58 |
| 56 // Kicks off asynchronous loading of profiles and credit cards. | 59 // Kicks off asynchronous loading of profiles and credit cards. |
| 57 void Init(content::BrowserContext* context); | 60 void Init(content::BrowserContext* context, |
| 61 AutofillWebDataService* autofill_webdata); |
| 58 | 62 |
| 59 // WebDataServiceConsumer: | 63 // WebDataServiceConsumer: |
| 60 virtual void OnWebDataServiceRequestDone( | 64 virtual void OnWebDataServiceRequestDone( |
| 61 WebDataServiceBase::Handle h, | 65 WebDataServiceBase::Handle h, |
| 62 const WDTypedResult* result) OVERRIDE; | 66 const WDTypedResult* result) OVERRIDE; |
| 63 | 67 |
| 64 // AutofillWebDataServiceObserverOnUIThread: | 68 // AutofillWebDataServiceObserverOnUIThread: |
| 65 virtual void AutofillMultipleChanged() OVERRIDE; | 69 virtual void AutofillMultipleChanged() OVERRIDE; |
| 66 | 70 |
| 67 // Adds a listener to be notified of PersonalDataManager events. | 71 // Adds a listener to be notified of PersonalDataManager events. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // so they can be loaded at the same time. | 274 // so they can be loaded at the same time. |
| 271 WebDataServiceBase::Handle pending_profiles_query_; | 275 WebDataServiceBase::Handle pending_profiles_query_; |
| 272 WebDataServiceBase::Handle pending_creditcards_query_; | 276 WebDataServiceBase::Handle pending_creditcards_query_; |
| 273 | 277 |
| 274 // The observers. | 278 // The observers. |
| 275 ObserverList<PersonalDataManagerObserver> observers_; | 279 ObserverList<PersonalDataManagerObserver> observers_; |
| 276 | 280 |
| 277 private: | 281 private: |
| 278 std::string app_locale_; | 282 std::string app_locale_; |
| 279 | 283 |
| 284 scoped_refptr<AutofillWebDataService> autofill_webdata_; |
| 285 |
| 280 // For logging UMA metrics. Overridden by metrics tests. | 286 // For logging UMA metrics. Overridden by metrics tests. |
| 281 scoped_ptr<const AutofillMetrics> metric_logger_; | 287 scoped_ptr<const AutofillMetrics> metric_logger_; |
| 282 | 288 |
| 283 // Whether we have already logged the number of profiles this session. | 289 // Whether we have already logged the number of profiles this session. |
| 284 mutable bool has_logged_profile_count_; | 290 mutable bool has_logged_profile_count_; |
| 285 | 291 |
| 286 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 292 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
| 287 }; | 293 }; |
| 288 | 294 |
| 289 } // namespace autofill | 295 } // namespace autofill |
| 290 | 296 |
| 291 #endif // COMPONENTS_AUTOFILL_BROWSER_PERSONAL_DATA_MANAGER_H_ | 297 #endif // COMPONENTS_AUTOFILL_BROWSER_PERSONAL_DATA_MANAGER_H_ |
| OLD | NEW |