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

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

Powered by Google App Engine
This is Rietveld 408576698