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

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

Issue 71683003: Have AutofillManagerDelegate supply the AutofillWebDataService to core code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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 <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 PrefService;
23 class RemoveAutofillTester; 23 class RemoveAutofillTester;
24 24
25 namespace content {
26 class BrowserContext;
27 }
28
29 namespace autofill { 25 namespace autofill {
30 class AutofillInteractiveTest; 26 class AutofillInteractiveTest;
31 class AutofillMetrics; 27 class AutofillMetrics;
32 class AutofillTest; 28 class AutofillTest;
29 class AutofillWebDataService;
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 // |autofill_webdata| and |pref_service| must outlive this instance.
60 // this instance whether the user is currently operating in an off-the-record 57 // |is_off_the_record| informs this instance whether the user is currently
61 // context. 58 // operating in an off-the-record context.
62 void Init(content::BrowserContext* context, 59 void Init(scoped_refptr<AutofillWebDataService> autofill_webdata,
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
260 void set_autofill_webdata_service(
261 scoped_refptr<AutofillWebDataService> webdata);
Ilya Sherman 2013/11/14 02:22:02 nit: This ought to be inlined.
Ilya Sherman 2013/11/14 02:22:02 nit: You're using three different names here: "aut
blundell 2013/11/14 16:46:30 Done.
blundell 2013/11/14 16:46:30 Done.
263 void set_metric_logger(const AutofillMetrics* metric_logger); 262 void set_metric_logger(const AutofillMetrics* metric_logger);
264 void set_browser_context(content::BrowserContext* context);
265 void set_pref_service(PrefService* pref_service); 263 void set_pref_service(PrefService* pref_service);
266 264
267 // The browser context this PersonalDataManager is in. 265 // The AutofillWebDataService that this PersonalDataManager uses.
Ilya Sherman 2013/11/14 02:22:02 nit: Might be more useful to document as the backi
blundell 2013/11/14 16:46:30 Done.
268 content::BrowserContext* browser_context_; 266 scoped_refptr<AutofillWebDataService> autofill_webdata_;
Ilya Sherman 2013/11/14 02:22:02 nit: The "autofill_" prefix seems quite redundant
blundell 2013/11/14 16:46:30 Done.
269 267
270 // True if personal data has been loaded from the web database. 268 // True if personal data has been loaded from the web database.
271 bool is_data_loaded_; 269 bool is_data_loaded_;
272 270
273 // The loaded web profiles. 271 // The loaded web profiles.
274 ScopedVector<AutofillProfile> web_profiles_; 272 ScopedVector<AutofillProfile> web_profiles_;
275 273
276 // Auxiliary profiles. 274 // Auxiliary profiles.
277 mutable ScopedVector<AutofillProfile> auxiliary_profiles_; 275 mutable ScopedVector<AutofillProfile> auxiliary_profiles_;
278 276
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 313
316 // Whether we have already logged the number of profiles this session. 314 // Whether we have already logged the number of profiles this session.
317 mutable bool has_logged_profile_count_; 315 mutable bool has_logged_profile_count_;
318 316
319 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); 317 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager);
320 }; 318 };
321 319
322 } // namespace autofill 320 } // namespace autofill
323 321
324 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_ 322 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_PERSONAL_DATA_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698