1 // Copyright 2014 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PERSONAL_DATA_MANAGER_FACTORY_H
6 #define PERSONAL_DATA_MANAGER_FACTORY_H
8 #if defined(TIZEN_AUTOFILL_SUPPORT)
9 #include "base/id_map.h"
10 #include "base/strings/string16.h"
11 #include "base/compiler_specific.h"
12 #include "base/basictypes.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/singleton.h"
15 #include "components/autofill/core/browser/personal_data_manager_observer.h"
18 template <typename T> struct DefaultSingletonTraits;
27 typedef void (*Ewk_Context_Form_Autofill_Profile_Changed_Callback)(void *data);
29 class PersonalDataManager;
30 class AutofillProfile;
33 class PersonalDataManagerFactory : public PersonalDataManagerObserver {
35 static PersonalDataManagerFactory* GetInstance();
37 void PersonalDataManagerAdd(content::BrowserContext* ctx);
38 void PersonalDataManagerRemove(content::BrowserContext* ctx);
39 PersonalDataManager* PersonalDataManagerForContext(
40 content::BrowserContext* ctx);
42 // Returns the number of web and auxiliary profiles.
43 int GetProfileCount(content::BrowserContext* mgr);
45 // Returns the profile with specified |index|
46 AutofillProfile* GetProfileByIndex(content::BrowserContext* mgr, int index);
48 // Adds |profile| to the web database.
49 void AddProfile(content::BrowserContext* mgr, const AutofillProfile& profile);
51 // Updates |profile| which already exists in the web database.
52 void UpdateProfile(content::BrowserContext* mgr,
53 const AutofillProfile& profile);
55 // Removes the profile or credit card represented by |guid|.
56 void RemoveByGUID(content::BrowserContext* mgr, const std::string& guid);
58 // Returns the profile with the specified |guid|, or NULL if there is no
59 // profile with the specified |guid|. Both web and auxiliary profiles may
61 AutofillProfile* GetProfileByGUID(content::BrowserContext* mgr,
62 const std::string& guid);
64 // Returns the number of web and auxiliary CC.
65 int GetCreditCardCount(content::BrowserContext* mgr);
67 // Returns the credit card with specified |index|
68 CreditCard* GetCreditCardByIndex(content::BrowserContext* mgr, int index);
70 // Adds |credit_card| to the web database.
71 void AddCreditCard(content::BrowserContext* mgr,
72 const CreditCard& credit_card);
74 // Updates |credit_card| which already exists in the web database.
75 void UpdateCreditCard(content::BrowserContext* mgr,
76 const CreditCard& credit_card);
78 // Returns the credit card with the specified |guid|, or NULL if there is
79 // no credit card with the specified |guid|.
80 CreditCard* GetCreditCardByGUID(content::BrowserContext* mgr,
81 const std::string& guid);
83 void SetCallback(Ewk_Context_Form_Autofill_Profile_Changed_Callback callback,
86 // content::BrowserContextObserver:
87 void OnPersonalDataChanged() override;
90 friend struct base::DefaultSingletonTraits<PersonalDataManagerFactory>;
92 PersonalDataManagerFactory();
93 ~PersonalDataManagerFactory();
95 IDMap<PersonalDataManager, IDMapOwnPointer> personal_data_manager_id_map_;
97 DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerFactory);
98 Ewk_Context_Form_Autofill_Profile_Changed_Callback callback_;
99 void* callback_user_data_;
102 } // namespace autofill
103 #endif // TIZEN_AUTOFILL_SUPPORT
104 #endif // PERSONAL_DATA_MANAGER_FACTORY_H