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( |
| 23 scoped_refptr<WebDatabaseService> wdbs, |
| 24 const ProfileErrorCallback& callback); |
| 25 |
| 26 // WebDataServiceBase overrides: |
| 27 virtual content::NotificationSource GetNotificationSource() OVERRIDE; |
18 | 28 |
19 // AutofillWebData implementation. | 29 // AutofillWebData implementation. |
20 virtual void AddFormFields( | 30 virtual void AddFormFields( |
21 const std::vector<FormFieldData>& fields) OVERRIDE; | 31 const std::vector<FormFieldData>& fields) OVERRIDE; |
22 virtual WebDataServiceBase::Handle GetFormValuesForElementName( | 32 virtual WebDataServiceBase::Handle GetFormValuesForElementName( |
23 const string16& name, | 33 const string16& name, |
24 const string16& prefix, | 34 const string16& prefix, |
25 int limit, | 35 int limit, |
26 WebDataServiceConsumer* consumer) OVERRIDE; | 36 WebDataServiceConsumer* consumer) OVERRIDE; |
27 virtual void RemoveExpiredFormElements() OVERRIDE; | 37 virtual void RemoveExpiredFormElements() OVERRIDE; |
28 virtual void RemoveFormValueForElementName(const string16& name, | 38 virtual void RemoveFormValueForElementName(const string16& name, |
29 const string16& value) OVERRIDE; | 39 const string16& value) OVERRIDE; |
30 virtual void AddAutofillProfile(const AutofillProfile& profile) OVERRIDE; | 40 virtual void AddAutofillProfile(const AutofillProfile& profile) OVERRIDE; |
31 virtual void UpdateAutofillProfile(const AutofillProfile& profile) OVERRIDE; | 41 virtual void UpdateAutofillProfile(const AutofillProfile& profile) OVERRIDE; |
32 virtual void RemoveAutofillProfile(const std::string& guid) OVERRIDE; | 42 virtual void RemoveAutofillProfile(const std::string& guid) OVERRIDE; |
33 virtual WebDataServiceBase::Handle GetAutofillProfiles( | 43 virtual WebDataServiceBase::Handle GetAutofillProfiles( |
34 WebDataServiceConsumer* consumer) OVERRIDE; | 44 WebDataServiceConsumer* consumer) OVERRIDE; |
35 virtual void AddCreditCard(const CreditCard& credit_card) OVERRIDE; | 45 virtual void AddCreditCard(const CreditCard& credit_card) OVERRIDE; |
36 virtual void UpdateCreditCard(const CreditCard& credit_card) OVERRIDE; | 46 virtual void UpdateCreditCard(const CreditCard& credit_card) OVERRIDE; |
37 virtual void RemoveCreditCard(const std::string& guid) OVERRIDE; | 47 virtual void RemoveCreditCard(const std::string& guid) OVERRIDE; |
38 virtual WebDataServiceBase::Handle | 48 virtual WebDataServiceBase::Handle |
39 GetCreditCards(WebDataServiceConsumer* consumer) OVERRIDE; | 49 GetCreditCards(WebDataServiceConsumer* consumer) OVERRIDE; |
40 | 50 |
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: | 51 protected: |
51 virtual ~AutofillWebDataServiceImpl(); | 52 virtual ~AutofillWebDataServiceImpl(); |
52 | 53 |
53 private: | 54 private: |
| 55 WebDatabase::State AddFormElementsImpl( |
| 56 const std::vector<FormFieldData>& fields, WebDatabase* db); |
| 57 scoped_ptr<WDTypedResult> GetFormValuesForElementNameImpl( |
| 58 const string16& name, const string16& prefix, int limit, WebDatabase* db); |
| 59 WebDatabase::State RemoveFormElementsAddedBetweenImpl( |
| 60 const base::Time& delete_begin, const base::Time& delete_end, |
| 61 WebDatabase* db); |
| 62 WebDatabase::State RemoveExpiredFormElementsImpl(WebDatabase* db); |
| 63 WebDatabase::State RemoveFormValueForElementNameImpl( |
| 64 const string16& name, const string16& value, WebDatabase* db); |
| 65 WebDatabase::State AddAutofillProfileImpl( |
| 66 const AutofillProfile& profile, WebDatabase* db); |
| 67 WebDatabase::State UpdateAutofillProfileImpl( |
| 68 const AutofillProfile& profile, WebDatabase* db); |
| 69 WebDatabase::State RemoveAutofillProfileImpl( |
| 70 const std::string& guid, WebDatabase* db); |
| 71 scoped_ptr<WDTypedResult> GetAutofillProfilesImpl(WebDatabase* db); |
| 72 WebDatabase::State AddCreditCardImpl( |
| 73 const CreditCard& credit_card, WebDatabase* db); |
| 74 WebDatabase::State UpdateCreditCardImpl( |
| 75 const CreditCard& credit_card, WebDatabase* db); |
| 76 WebDatabase::State RemoveCreditCardImpl( |
| 77 const std::string& guid, WebDatabase* db); |
| 78 scoped_ptr<WDTypedResult> GetCreditCardsImpl(WebDatabase* db); |
| 79 |
| 80 // Callbacks to ensure that sensitive info is destroyed if request is |
| 81 // cancelled. |
| 82 void DestroyAutofillProfileResult(const WDTypedResult* result); |
| 83 void DestroyAutofillCreditCardResult(const WDTypedResult* result); |
| 84 |
54 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataServiceImpl); | 85 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataServiceImpl); |
55 | |
56 const scoped_refptr<WebDataService> service_; | |
57 }; | 86 }; |
58 | 87 |
59 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_WEB_DATA_SERVICE_IMPL_H_ | 88 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_WEB_DATA_SERVICE_IMPL_H_ |
OLD | NEW |