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