| 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_H_ |
| 6 #define CHROME_BROWSER_WEBDATA_AUTOFILL_WEB_DATA_SERVICE_IMPL_H_ | 6 #define CHROME_BROWSER_WEBDATA_AUTOFILL_WEB_DATA_SERVICE_H_ |
| 7 |
| 8 #include <vector> |
| 7 | 9 |
| 8 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 9 #include "chrome/browser/api/webdata/autofill_web_data_service.h" | 11 #include "chrome/browser/api/webdata/autofill_web_data.h" |
| 10 #include "chrome/browser/api/webdata/web_data_results.h" | 12 #include "chrome/browser/api/webdata/web_data_results.h" |
| 11 #include "chrome/browser/api/webdata/web_data_service_base.h" | 13 #include "chrome/browser/api/webdata/web_data_service_base.h" |
| 12 #include "chrome/browser/api/webdata/web_data_service_consumer.h" | 14 #include "chrome/browser/api/webdata/web_data_service_consumer.h" |
| 13 #include "chrome/browser/webdata/web_database.h" | 15 #include "chrome/browser/webdata/web_database.h" |
| 14 | 16 |
| 15 class AutofillChange; | 17 class AutofillChange; |
| 16 class WebDatabaseService; | 18 class WebDatabaseService; |
| 17 | 19 |
| 18 // This aggregates a WebDataService and delegates all method calls to | 20 namespace content { |
| 19 // it. | 21 class BrowserContext; |
| 20 class AutofillWebDataServiceImpl : public AutofillWebDataService { | 22 } |
| 23 |
| 24 typedef std::vector<AutofillChange> AutofillChangeList; |
| 25 |
| 26 // API for Autofill web data. |
| 27 class AutofillWebDataService |
| 28 : public AutofillWebData, |
| 29 public WebDataServiceBase { |
| 21 public: | 30 public: |
| 22 AutofillWebDataServiceImpl(scoped_refptr<WebDatabaseService> wdbs, | 31 AutofillWebDataService(); |
| 23 const ProfileErrorCallback& callback); | 32 |
| 33 AutofillWebDataService(scoped_refptr<WebDatabaseService> wdbs, |
| 34 const ProfileErrorCallback& callback); |
| 35 |
| 36 // Retrieve an AutofillWebDataService for the given context. |
| 37 // Can return NULL in some contexts. |
| 38 static scoped_refptr<AutofillWebDataService> FromBrowserContext( |
| 39 content::BrowserContext* context); |
| 40 |
| 41 // Notifies listeners on the UI thread that multiple changes have been made to |
| 42 // to Autofill records of the database. |
| 43 // NOTE: This method is intended to be called from the DB thread. It |
| 44 // it asynchronously notifies listeners on the UI thread. |
| 45 // |web_data_service| may be NULL for testing purposes. |
| 46 static void NotifyOfMultipleAutofillChanges( |
| 47 AutofillWebDataService* web_data_service); |
| 24 | 48 |
| 25 // WebDataServiceBase overrides: | 49 // WebDataServiceBase overrides: |
| 26 virtual content::NotificationSource GetNotificationSource() OVERRIDE; | 50 virtual content::NotificationSource GetNotificationSource() OVERRIDE; |
| 27 | 51 |
| 28 // AutofillWebData implementation. | 52 // AutofillWebData implementation. |
| 29 virtual void AddFormFields( | 53 virtual void AddFormFields( |
| 30 const std::vector<FormFieldData>& fields) OVERRIDE; | 54 const std::vector<FormFieldData>& fields) OVERRIDE; |
| 31 virtual WebDataServiceBase::Handle GetFormValuesForElementName( | 55 virtual WebDataServiceBase::Handle GetFormValuesForElementName( |
| 32 const string16& name, | 56 const string16& name, |
| 33 const string16& prefix, | 57 const string16& prefix, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 46 virtual void AddCreditCard(const CreditCard& credit_card) OVERRIDE; | 70 virtual void AddCreditCard(const CreditCard& credit_card) OVERRIDE; |
| 47 virtual void UpdateCreditCard(const CreditCard& credit_card) OVERRIDE; | 71 virtual void UpdateCreditCard(const CreditCard& credit_card) OVERRIDE; |
| 48 virtual void RemoveCreditCard(const std::string& guid) OVERRIDE; | 72 virtual void RemoveCreditCard(const std::string& guid) OVERRIDE; |
| 49 virtual WebDataServiceBase::Handle GetCreditCards( | 73 virtual WebDataServiceBase::Handle GetCreditCards( |
| 50 WebDataServiceConsumer* consumer) OVERRIDE; | 74 WebDataServiceConsumer* consumer) OVERRIDE; |
| 51 virtual void RemoveAutofillDataModifiedBetween( | 75 virtual void RemoveAutofillDataModifiedBetween( |
| 52 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; | 76 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; |
| 53 | 77 |
| 54 | 78 |
| 55 protected: | 79 protected: |
| 56 virtual ~AutofillWebDataServiceImpl(); | 80 virtual ~AutofillWebDataService(); |
| 57 | 81 |
| 58 private: | 82 private: |
| 59 WebDatabase::State AddFormElementsImpl( | 83 WebDatabase::State AddFormElementsImpl( |
| 60 const std::vector<FormFieldData>& fields, WebDatabase* db); | 84 const std::vector<FormFieldData>& fields, WebDatabase* db); |
| 61 scoped_ptr<WDTypedResult> GetFormValuesForElementNameImpl( | 85 scoped_ptr<WDTypedResult> GetFormValuesForElementNameImpl( |
| 62 const string16& name, const string16& prefix, int limit, WebDatabase* db); | 86 const string16& name, const string16& prefix, int limit, WebDatabase* db); |
| 63 WebDatabase::State RemoveFormElementsAddedBetweenImpl( | 87 WebDatabase::State RemoveFormElementsAddedBetweenImpl( |
| 64 const base::Time& delete_begin, const base::Time& delete_end, | 88 const base::Time& delete_begin, const base::Time& delete_end, |
| 65 WebDatabase* db); | 89 WebDatabase* db); |
| 66 WebDatabase::State RemoveExpiredFormElementsImpl(WebDatabase* db); | 90 WebDatabase::State RemoveExpiredFormElementsImpl(WebDatabase* db); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 82 scoped_ptr<WDTypedResult> GetCreditCardsImpl(WebDatabase* db); | 106 scoped_ptr<WDTypedResult> GetCreditCardsImpl(WebDatabase* db); |
| 83 WebDatabase::State RemoveAutofillDataModifiedBetweenImpl( | 107 WebDatabase::State RemoveAutofillDataModifiedBetweenImpl( |
| 84 const base::Time& delete_begin, const base::Time& delete_end, | 108 const base::Time& delete_begin, const base::Time& delete_end, |
| 85 WebDatabase* db); | 109 WebDatabase* db); |
| 86 | 110 |
| 87 // Callbacks to ensure that sensitive info is destroyed if request is | 111 // Callbacks to ensure that sensitive info is destroyed if request is |
| 88 // cancelled. | 112 // cancelled. |
| 89 void DestroyAutofillProfileResult(const WDTypedResult* result); | 113 void DestroyAutofillProfileResult(const WDTypedResult* result); |
| 90 void DestroyAutofillCreditCardResult(const WDTypedResult* result); | 114 void DestroyAutofillCreditCardResult(const WDTypedResult* result); |
| 91 | 115 |
| 92 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataServiceImpl); | 116 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataService); |
| 93 }; | 117 }; |
| 94 | 118 |
| 95 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_WEB_DATA_SERVICE_IMPL_H_ | 119 #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_WEB_DATA_SERVICE_H_ |
| OLD | NEW |