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