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/strings/string16.h" | 15 #include "base/strings/string16.h" |
16 #include "components/autofill/core/browser/autofill_profile.h" | 16 #include "components/autofill/core/browser/autofill_profile.h" |
17 #include "components/autofill/core/browser/credit_card.h" | 17 #include "components/autofill/core/browser/credit_card.h" |
18 #include "components/autofill/core/browser/field_types.h" | 18 #include "components/autofill/core/browser/field_types.h" |
19 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse
rver.h" | 19 #include "components/autofill/core/browser/webdata/autofill_webdata_service_obse
rver.h" |
20 #include "components/webdata/common/web_data_service_consumer.h" | 20 #include "components/webdata/common/web_data_service_consumer.h" |
21 | 21 |
| 22 class PrefService; |
22 class RemoveAutofillTester; | 23 class RemoveAutofillTester; |
23 | 24 |
24 namespace content { | 25 namespace content { |
25 class BrowserContext; | 26 class BrowserContext; |
26 } | 27 } |
27 | 28 |
28 namespace autofill { | 29 namespace autofill { |
29 class AutofillInteractiveTest; | 30 class AutofillInteractiveTest; |
30 class AutofillMetrics; | 31 class AutofillMetrics; |
31 class AutofillTest; | 32 class AutofillTest; |
(...skipping 15 matching lines...) Expand all Loading... |
47 class PersonalDataManager : public WebDataServiceConsumer, | 48 class PersonalDataManager : public WebDataServiceConsumer, |
48 public AutofillWebDataServiceObserverOnUIThread { | 49 public AutofillWebDataServiceObserverOnUIThread { |
49 public: | 50 public: |
50 // A pair of GUID and variant index. Represents a single FormGroup and a | 51 // A pair of GUID and variant index. Represents a single FormGroup and a |
51 // specific data variant. | 52 // specific data variant. |
52 typedef std::pair<std::string, size_t> GUIDPair; | 53 typedef std::pair<std::string, size_t> GUIDPair; |
53 | 54 |
54 explicit PersonalDataManager(const std::string& app_locale); | 55 explicit PersonalDataManager(const std::string& app_locale); |
55 virtual ~PersonalDataManager(); | 56 virtual ~PersonalDataManager(); |
56 | 57 |
57 // Kicks off asynchronous loading of profiles and credit cards. | 58 // Kicks off asynchronous loading of profiles and credit cards. |context| and |
58 void Init(content::BrowserContext* context); | 59 // |pref_service| must outlive this instance. |
| 60 void Init(content::BrowserContext* context, PrefService* pref_service); |
59 | 61 |
60 // WebDataServiceConsumer: | 62 // WebDataServiceConsumer: |
61 virtual void OnWebDataServiceRequestDone( | 63 virtual void OnWebDataServiceRequestDone( |
62 WebDataServiceBase::Handle h, | 64 WebDataServiceBase::Handle h, |
63 const WDTypedResult* result) OVERRIDE; | 65 const WDTypedResult* result) OVERRIDE; |
64 | 66 |
65 // AutofillWebDataServiceObserverOnUIThread: | 67 // AutofillWebDataServiceObserverOnUIThread: |
66 virtual void AutofillMultipleChanged() OVERRIDE; | 68 virtual void AutofillMultipleChanged() OVERRIDE; |
67 | 69 |
68 // Adds a listener to be notified of PersonalDataManager events. | 70 // Adds a listener to be notified of PersonalDataManager events. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 // profiles the user has. On subsequent calls, does nothing. | 251 // profiles the user has. On subsequent calls, does nothing. |
250 void LogProfileCount() const; | 252 void LogProfileCount() const; |
251 | 253 |
252 // Returns the value of the AutofillEnabled pref. | 254 // Returns the value of the AutofillEnabled pref. |
253 virtual bool IsAutofillEnabled() const; | 255 virtual bool IsAutofillEnabled() const; |
254 | 256 |
255 // For tests. | 257 // For tests. |
256 const AutofillMetrics* metric_logger() const; | 258 const AutofillMetrics* metric_logger() const; |
257 void set_metric_logger(const AutofillMetrics* metric_logger); | 259 void set_metric_logger(const AutofillMetrics* metric_logger); |
258 void set_browser_context(content::BrowserContext* context); | 260 void set_browser_context(content::BrowserContext* context); |
| 261 void set_pref_service(PrefService* pref_service); |
259 | 262 |
260 // The browser context this PersonalDataManager is in. | 263 // The browser context this PersonalDataManager is in. |
261 content::BrowserContext* browser_context_; | 264 content::BrowserContext* browser_context_; |
262 | 265 |
263 // True if personal data has been loaded from the web database. | 266 // True if personal data has been loaded from the web database. |
264 bool is_data_loaded_; | 267 bool is_data_loaded_; |
265 | 268 |
266 // The loaded web profiles. | 269 // The loaded web profiles. |
267 ScopedVector<AutofillProfile> web_profiles_; | 270 ScopedVector<AutofillProfile> web_profiles_; |
268 | 271 |
(...skipping 23 matching lines...) Expand all Loading... |
292 std::string MostCommonCountryCodeFromProfiles() const; | 295 std::string MostCommonCountryCodeFromProfiles() const; |
293 | 296 |
294 const std::string app_locale_; | 297 const std::string app_locale_; |
295 | 298 |
296 // The default country code for new addresses. | 299 // The default country code for new addresses. |
297 mutable std::string default_country_code_; | 300 mutable std::string default_country_code_; |
298 | 301 |
299 // For logging UMA metrics. Overridden by metrics tests. | 302 // For logging UMA metrics. Overridden by metrics tests. |
300 scoped_ptr<const AutofillMetrics> metric_logger_; | 303 scoped_ptr<const AutofillMetrics> metric_logger_; |
301 | 304 |
| 305 // The PrefService that this instance uses. Must outlive this instance. |
| 306 PrefService* pref_service_; |
| 307 |
302 // Whether we have already logged the number of profiles this session. | 308 // Whether we have already logged the number of profiles this session. |
303 mutable bool has_logged_profile_count_; | 309 mutable bool has_logged_profile_count_; |
304 | 310 |
305 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); | 311 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); |
306 }; | 312 }; |
307 | 313 |
308 } // namespace autofill | 314 } // namespace autofill |
309 | 315 |
310 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ | 316 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ |
OLD | NEW |