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

Side by Side Diff: chrome/browser/autofill/personal_data_manager.h

Issue 10919066: Use BrowserContext as key in API. Switch Autofill to use BC in place of Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to parent Created 8 years, 3 months 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 | Annotate | Revision Log
OLDNEW
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 CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ 5 #ifndef CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_
6 #define CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ 6 #define CHROME_BROWSER_AUTOFILL_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/string16.h" 15 #include "base/string16.h"
16 #include "chrome/browser/autofill/autofill_profile.h" 16 #include "chrome/browser/autofill/autofill_profile.h"
17 #include "chrome/browser/autofill/credit_card.h" 17 #include "chrome/browser/autofill/credit_card.h"
18 #include "chrome/browser/autofill/field_types.h" 18 #include "chrome/browser/autofill/field_types.h"
19 #include "chrome/browser/api/webdata/autofill_web_data_service.h" 19 #include "chrome/browser/api/webdata/autofill_web_data_service.h"
20 #include "chrome/browser/api/webdata/web_data_service_consumer.h" 20 #include "chrome/browser/api/webdata/web_data_service_consumer.h"
21 21
22 #include "chrome/browser/profiles/profile_keyed_service.h" 22 #include "chrome/browser/profiles/profile_keyed_service.h"
23 #include "chrome/browser/sync/profile_sync_service_observer.h" 23 #include "chrome/browser/sync/profile_sync_service_observer.h"
24 #include "content/public/browser/notification_observer.h" 24 #include "content/public/browser/notification_observer.h"
25 #include "content/public/browser/notification_registrar.h" 25 #include "content/public/browser/notification_registrar.h"
26 26
27 class AutofillMetrics; 27 class AutofillMetrics;
28 class FormStructure; 28 class FormStructure;
29 class PersonalDataManagerObserver; 29 class PersonalDataManagerObserver;
30 class Profile;
31 30
32 namespace autofill_helper { 31 namespace autofill_helper {
33 void SetProfiles(int, std::vector<AutofillProfile>*); 32 void SetProfiles(int, std::vector<AutofillProfile>*);
34 void SetCreditCards(int, std::vector<CreditCard>*); 33 void SetCreditCards(int, std::vector<CreditCard>*);
35 } 34 }
36 35
36 namespace content {
37 class BrowserContext;
38 }
39
37 // Handles loading and saving Autofill profile information to the web database. 40 // Handles loading and saving Autofill profile information to the web database.
38 // This class also stores the profiles loaded from the database for use during 41 // This class also stores the profiles loaded from the database for use during
39 // Autofill. 42 // Autofill.
40 class PersonalDataManager 43 class PersonalDataManager
41 : public WebDataServiceConsumer, 44 : public WebDataServiceConsumer,
42 public ProfileSyncServiceObserver, 45 public ProfileSyncServiceObserver,
43 public ProfileKeyedService, 46 public ProfileKeyedService,
44 public content::NotificationObserver { 47 public content::NotificationObserver {
45 public: 48 public:
46 // WebDataServiceConsumer: 49 // WebDataServiceConsumer:
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // profiles the user has. On subsequent calls, does nothing. 216 // profiles the user has. On subsequent calls, does nothing.
214 void LogProfileCount() const; 217 void LogProfileCount() const;
215 218
216 // Returns the value of the AutofillEnabled pref. 219 // Returns the value of the AutofillEnabled pref.
217 virtual bool IsAutofillEnabled() const; 220 virtual bool IsAutofillEnabled() const;
218 221
219 // For tests. 222 // For tests.
220 const AutofillMetrics* metric_logger() const; 223 const AutofillMetrics* metric_logger() const;
221 void set_metric_logger(const AutofillMetrics* metric_logger); 224 void set_metric_logger(const AutofillMetrics* metric_logger);
222 225
223 // The profile hosting this PersonalDataManager. 226 // The browser context this PersonalDataManager is in.
224 Profile* profile_; 227 content::BrowserContext* browser_context_;
225 228
226 // True if personal data has been loaded from the web database. 229 // True if personal data has been loaded from the web database.
227 bool is_data_loaded_; 230 bool is_data_loaded_;
228 231
229 // The loaded web profiles. 232 // The loaded web profiles.
230 ScopedVector<AutofillProfile> web_profiles_; 233 ScopedVector<AutofillProfile> web_profiles_;
231 234
232 // Auxiliary profiles. 235 // Auxiliary profiles.
233 mutable ScopedVector<AutofillProfile> auxiliary_profiles_; 236 mutable ScopedVector<AutofillProfile> auxiliary_profiles_;
234 237
235 // Storage for combined web and auxiliary profiles. Contents are weak 238 // Storage for combined web and auxiliary profiles. Contents are weak
236 // references. Lifetime managed by |web_profiles_| and |auxiliary_profiles_|. 239 // references. Lifetime managed by |web_profiles_| and |auxiliary_profiles_|.
237 mutable std::vector<AutofillProfile*> profiles_; 240 mutable std::vector<AutofillProfile*> profiles_;
238 241
239 // The loaded credit cards. 242 // The loaded credit cards.
240 ScopedVector<CreditCard> credit_cards_; 243 ScopedVector<CreditCard> credit_cards_;
241 244
242 // When the manager makes a request from WebDataServiceBase, the database 245 // When the manager makes a request from WebDataServiceBase, the database
243 // is queried on another thread, we record the query handle until we 246 // is queried on another thread, we record the query handle until we
244 // get called back. We store handles for both profile and credit card queries 247 // get called back. We store handles for both profile and credit card queries
245 // so they can be loaded at the same time. 248 // so they can be loaded at the same time.
246 WebDataServiceBase::Handle pending_profiles_query_; 249 WebDataServiceBase::Handle pending_profiles_query_;
247 WebDataServiceBase::Handle pending_creditcards_query_; 250 WebDataServiceBase::Handle pending_creditcards_query_;
248 251
249 // The observers. 252 // The observers.
250 ObserverList<PersonalDataManagerObserver> observers_; 253 ObserverList<PersonalDataManagerObserver> observers_;
251 254
252 private: 255 private:
253 // Kicks off asynchronous loading of profiles and credit cards. 256 // Kicks off asynchronous loading of profiles and credit cards.
254 void Init(Profile* profile); 257 void Init(content::BrowserContext* context);
255 258
256 // For logging UMA metrics. Overridden by metrics tests. 259 // For logging UMA metrics. Overridden by metrics tests.
257 scoped_ptr<const AutofillMetrics> metric_logger_; 260 scoped_ptr<const AutofillMetrics> metric_logger_;
258 261
259 // Whether we have already logged the number of profiles this session. 262 // Whether we have already logged the number of profiles this session.
260 mutable bool has_logged_profile_count_; 263 mutable bool has_logged_profile_count_;
261 264
262 // Manages registration lifetime for NotificationObserver implementation. 265 // Manages registration lifetime for NotificationObserver implementation.
263 content::NotificationRegistrar notification_registrar_; 266 content::NotificationRegistrar notification_registrar_;
264 267
265 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager); 268 DISALLOW_COPY_AND_ASSIGN(PersonalDataManager);
266 }; 269 };
267 270
268 #endif // CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_ 271 #endif // CHROME_BROWSER_AUTOFILL_PERSONAL_DATA_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager_unittest.cc ('k') | chrome/browser/autofill/personal_data_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698