[M47_2526] Chromium upversion to m47_2526 branch
[platform/framework/web/chromium-efl.git] / tizen_src / ewk / efl_integration / browser / autofill / personal_data_manager_factory.h
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.
4
5 #ifndef PERSONAL_DATA_MANAGER_FACTORY_H
6 #define PERSONAL_DATA_MANAGER_FACTORY_H
7
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"
16
17 namespace base {
18 template <typename T> struct DefaultSingletonTraits;
19 }
20
21 namespace content {
22 class BrowserContext;
23 }
24
25 namespace autofill {
26
27 typedef void (*Ewk_Context_Form_Autofill_Profile_Changed_Callback)(void *data);
28
29 class PersonalDataManager;
30 class AutofillProfile;
31 class CreditCard;
32
33 class PersonalDataManagerFactory : public PersonalDataManagerObserver {
34  public:
35   static PersonalDataManagerFactory* GetInstance();
36
37   void PersonalDataManagerAdd(content::BrowserContext* ctx);
38   void PersonalDataManagerRemove(content::BrowserContext* ctx);
39   PersonalDataManager* PersonalDataManagerForContext(
40       content::BrowserContext* ctx);
41
42   // Returns the number of web and auxiliary profiles.
43   int GetProfileCount(content::BrowserContext* mgr);
44
45   // Returns the profile with specified |index|
46   AutofillProfile* GetProfileByIndex(content::BrowserContext* mgr, int index);
47
48  // Adds |profile| to the web database.
49   void AddProfile(content::BrowserContext* mgr, const AutofillProfile& profile);
50
51   // Updates |profile| which already exists in the web database.
52   void UpdateProfile(content::BrowserContext* mgr,
53       const AutofillProfile& profile);
54
55   // Removes the profile or credit card represented by |guid|.
56   void RemoveByGUID(content::BrowserContext* mgr, const std::string& guid);
57
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
60   // be returned.
61   AutofillProfile* GetProfileByGUID(content::BrowserContext* mgr,
62       const std::string& guid);
63
64   // Returns the number of web and auxiliary CC.
65   int GetCreditCardCount(content::BrowserContext* mgr);
66
67   // Returns the credit card with specified |index|
68   CreditCard* GetCreditCardByIndex(content::BrowserContext* mgr, int index);
69
70   // Adds |credit_card| to the web database.
71   void AddCreditCard(content::BrowserContext* mgr,
72       const CreditCard& credit_card);
73
74   // Updates |credit_card| which already exists in the web database.
75   void UpdateCreditCard(content::BrowserContext* mgr,
76       const CreditCard& credit_card);
77
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);
82
83   void SetCallback(Ewk_Context_Form_Autofill_Profile_Changed_Callback callback,
84       void* user_data);
85
86   // content::BrowserContextObserver:
87   void OnPersonalDataChanged() override;
88
89  private:
90   friend struct base::DefaultSingletonTraits<PersonalDataManagerFactory>;
91
92   PersonalDataManagerFactory();
93   ~PersonalDataManagerFactory();
94
95   IDMap<PersonalDataManager, IDMapOwnPointer> personal_data_manager_id_map_;
96
97   DISALLOW_COPY_AND_ASSIGN(PersonalDataManagerFactory);
98   Ewk_Context_Form_Autofill_Profile_Changed_Callback callback_;
99   void* callback_user_data_;
100 };
101
102 }  // namespace autofill
103 #endif // TIZEN_AUTOFILL_SUPPORT
104 #endif // PERSONAL_DATA_MANAGER_FACTORY_H