OLD | NEW |
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_WEBDATA_AUTOFILL_WEB_DATA_SERVICE_IMPL_H_ | 5 #ifndef CHROME_BROWSER_WEBDATA_AUTOFILL_WEB_DATA_SERVICE_IMPL_H_ |
6 #define CHROME_BROWSER_WEBDATA_AUTOFILL_WEB_DATA_SERVICE_IMPL_H_ | 6 #define CHROME_BROWSER_WEBDATA_AUTOFILL_WEB_DATA_SERVICE_IMPL_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "chrome/browser/api/webdata/autofill_web_data_service.h" | 9 #include "chrome/browser/api/webdata/autofill_web_data_service.h" |
| 10 #include "chrome/browser/api/webdata/web_data_results.h" |
| 11 #include "chrome/browser/api/webdata/web_data_service_base.h" |
| 12 #include "chrome/browser/api/webdata/web_data_service_consumer.h" |
| 13 #include "chrome/browser/webdata/web_database.h" |
10 | 14 |
11 class WebDataService; | 15 class AutofillChange; |
| 16 class WebDatabaseService; |
12 | 17 |
13 // This aggregates a WebDataService and delegates all method calls to | 18 // This aggregates a WebDataService and delegates all method calls to |
14 // it. | 19 // it. |
15 class AutofillWebDataServiceImpl : public AutofillWebDataService { | 20 class AutofillWebDataServiceImpl : public AutofillWebDataService { |
16 public: | 21 public: |
17 explicit AutofillWebDataServiceImpl(scoped_refptr<WebDataService> service); | 22 AutofillWebDataServiceImpl(scoped_refptr<WebDatabaseService> wdbs, |
| 23 const ProfileErrorCallback& callback); |
| 24 |
| 25 // WebDataServiceBase overrides: |
| 26 virtual content::NotificationSource GetNotificationSource() OVERRIDE; |
18 | 27 |
19 // AutofillWebData implementation. | 28 // AutofillWebData implementation. |
20 virtual void AddFormFields( | 29 virtual void AddFormFields( |
21 const std::vector<FormFieldData>& fields) OVERRIDE; | 30 const std::vector<FormFieldData>& fields) OVERRIDE; |
22 virtual WebDataServiceBase::Handle GetFormValuesForElementName( | 31 virtual WebDataServiceBase::Handle GetFormValuesForElementName( |
23 const string16& name, | 32 const string16& name, |
24 const string16& prefix, | 33 const string16& prefix, |
25 int limit, | 34 int limit, |
26 WebDataServiceConsumer* consumer) OVERRIDE; | 35 WebDataServiceConsumer* consumer) OVERRIDE; |
27 virtual void RemoveExpiredFormElements() OVERRIDE; | 36 virtual void RemoveExpiredFormElements() OVERRIDE; |
28 virtual void RemoveFormValueForElementName(const string16& name, | 37 virtual void RemoveFormValueForElementName(const string16& name, |
29 const string16& value) OVERRIDE; | 38 const string16& value) OVERRIDE; |
30 virtual void AddAutofillProfile(const AutofillProfile& profile) OVERRIDE; | 39 virtual void AddAutofillProfile(const AutofillProfile& profile) OVERRIDE; |
31 virtual void UpdateAutofillProfile(const AutofillProfile& profile) OVERRIDE; | 40 virtual void UpdateAutofillProfile(const AutofillProfile& profile) OVERRIDE; |
32 virtual void RemoveAutofillProfile(const std::string& guid) OVERRIDE; | 41 virtual void RemoveAutofillProfile(const std::string& guid) OVERRIDE; |
33 virtual WebDataServiceBase::Handle GetAutofillProfiles( | 42 virtual WebDataServiceBase::Handle GetAutofillProfiles( |
34 WebDataServiceConsumer* consumer) OVERRIDE; | 43 WebDataServiceConsumer* consumer) OVERRIDE; |
35 virtual void AddCreditCard(const CreditCard& credit_card) OVERRIDE; | 44 virtual void AddCreditCard(const CreditCard& credit_card) OVERRIDE; |
36 virtual void UpdateCreditCard(const CreditCard& credit_card) OVERRIDE; | 45 virtual void UpdateCreditCard(const CreditCard& credit_card) OVERRIDE; |
37 virtual void RemoveCreditCard(const std::string& guid) OVERRIDE; | 46 virtual void RemoveCreditCard(const std::string& guid) OVERRIDE; |
38 virtual WebDataServiceBase::Handle | 47 virtual WebDataServiceBase::Handle |
39 GetCreditCards(WebDataServiceConsumer* consumer) OVERRIDE; | 48 GetCreditCards(WebDataServiceConsumer* consumer) OVERRIDE; |
40 | 49 |
41 // WebDataServiceBase overrides. | |
42 // TODO(caitkp): remove these when we decouple | |
43 // WebDatabaseService life cycle from WebData). | |
44 virtual void CancelRequest(Handle h) OVERRIDE; | |
45 virtual content::NotificationSource GetNotificationSource() OVERRIDE; | |
46 virtual bool IsDatabaseLoaded() OVERRIDE; | |
47 virtual WebDatabase* GetDatabase() OVERRIDE; | |
48 | |
49 | |
50 protected: | 50 protected: |
51 virtual ~AutofillWebDataServiceImpl(); | 51 virtual ~AutofillWebDataServiceImpl(); |
52 | 52 |
53 private: | 53 private: |
| 54 WebDatabase::State AddFormElementsImpl( |
| 55 const std::vector<FormFieldData>& fields, WebDatabase* db); |
| 56 scoped_ptr<WDTypedResult> GetFormValuesForElementNameImpl( |
| 57 const string16& name, const string16& prefix, int limit, WebDatabase* db); |
| 58 WebDatabase::State RemoveFormElementsAddedBetweenImpl( |
| 59 const base::Time& delete_begin, const base::Time& delete_end, |
| 60 WebDatabase* db); |
| 61 WebDatabase::State RemoveExpiredFormElementsImpl(WebDatabase* db); |
| 62 WebDatabase::State RemoveFormValueForElementNameImpl( |
| 63 const string16& name, const string16& value, WebDatabase* db); |
| 64 WebDatabase::State AddAutofillProfileImpl( |
| 65 const AutofillProfile& profile, WebDatabase* db); |
| 66 WebDatabase::State UpdateAutofillProfileImpl( |
| 67 const AutofillProfile& profile, WebDatabase* db); |
| 68 WebDatabase::State RemoveAutofillProfileImpl( |
| 69 const std::string& guid, WebDatabase* db); |
| 70 scoped_ptr<WDTypedResult> GetAutofillProfilesImpl(WebDatabase* db); |
| 71 WebDatabase::State AddCreditCardImpl( |
| 72 const CreditCard& credit_card, WebDatabase* db); |
| 73 WebDatabase::State UpdateCreditCardImpl( |
| 74 const CreditCard& credit_card, WebDatabase* db); |
| 75 WebDatabase::State RemoveCreditCardImpl( |
| 76 const std::string& guid, WebDatabase* db); |
| 77 scoped_ptr<WDTypedResult> GetCreditCardsImpl(WebDatabase* db); |
| 78 |
| 79 // Callbacks to ensure that sensitive info is destroyed if request is |
| 80 // cancelled. |
| 81 void DestroyAutofillProfileResult(const WDTypedResult* result); |
| 82 void DestroyAutofillCreditCardResult(const WDTypedResult* result); |
| 83 |
54 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataServiceImpl); | 84 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataServiceImpl); |
55 | |
56 const scoped_refptr<WebDataService> service_; | |
57 }; | 85 }; |
58 | 86 |
59 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_WEB_DATA_SERVICE_IMPL_H_ | 87 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_WEB_DATA_SERVICE_IMPL_H_ |
OLD | NEW |