Home | History | Annotate | Download | only in webdata
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_H_
      6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "base/memory/scoped_ptr.h"
     12 #include "base/strings/string16.h"
     13 #include "components/webdata/common/web_data_service_base.h"
     14 
     15 namespace base {
     16 
     17 class Time;
     18 
     19 }  // namespace base
     20 
     21 class Profile;
     22 class WebDataServiceConsumer;
     23 
     24 namespace autofill {
     25 
     26 class AutofillProfile;
     27 class CreditCard;
     28 struct FormFieldData;
     29 
     30 // Pure virtual interface for retrieving Autofill data.  API users
     31 // should use AutofillWebDataService.
     32 class AutofillWebData {
     33  public:
     34   virtual ~AutofillWebData() {}
     35 
     36   // Schedules a task to add form fields to the web database.
     37   virtual void AddFormFields(
     38       const std::vector<FormFieldData>& fields) = 0;
     39 
     40   // Initiates the request for a vector of values which have been entered in
     41   // form input fields named |name|.  The method OnWebDataServiceRequestDone of
     42   // |consumer| gets called back when the request is finished, with the vector
     43   // included in the argument |result|.
     44   virtual WebDataServiceBase::Handle GetFormValuesForElementName(
     45       const base::string16& name,
     46       const base::string16& prefix,
     47       int limit,
     48       WebDataServiceConsumer* consumer) = 0;
     49 
     50   // Checks if there are any form elements in the database.
     51   virtual WebDataServiceBase::Handle HasFormElements(
     52       WebDataServiceConsumer* consumer) = 0;
     53 
     54   // Removes form elements recorded for Autocomplete from the database.
     55   virtual void RemoveFormElementsAddedBetween(
     56       const base::Time& delete_begin, const base::Time& delete_end) = 0;
     57 
     58   virtual void RemoveFormValueForElementName(const base::string16& name,
     59                                              const base::string16& value) = 0;
     60 
     61   // Schedules a task to add an Autofill profile to the web database.
     62   virtual void AddAutofillProfile(const AutofillProfile& profile) = 0;
     63 
     64   // Schedules a task to update an Autofill profile in the web database.
     65   virtual void UpdateAutofillProfile(const AutofillProfile& profile) = 0;
     66 
     67   // Schedules a task to remove an Autofill profile from the web database.
     68   // |guid| is the identifer of the profile to remove.
     69   virtual void RemoveAutofillProfile(const std::string& guid) = 0;
     70 
     71   // Initiates the request for all Autofill profiles.  The method
     72   // OnWebDataServiceRequestDone of |consumer| gets called when the request is
     73   // finished, with the profiles included in the argument |result|.  The
     74   // consumer owns the profiles.
     75   virtual WebDataServiceBase::Handle GetAutofillProfiles(
     76       WebDataServiceConsumer* consumer) = 0;
     77 
     78   // Schedules a task to add credit card to the web database.
     79   virtual void AddCreditCard(const CreditCard& credit_card) = 0;
     80 
     81   // Schedules a task to update credit card in the web database.
     82   virtual void UpdateCreditCard(const CreditCard& credit_card) = 0;
     83 
     84   // Schedules a task to remove a credit card from the web database.
     85   // |guid| is identifer of the credit card to remove.
     86   virtual void RemoveCreditCard(const std::string& guid) = 0;
     87 
     88   // Initiates the request for all credit cards.  The method
     89   // OnWebDataServiceRequestDone of |consumer| gets called when the request is
     90   // finished, with the credit cards included in the argument |result|.  The
     91   // consumer owns the credit cards.
     92   virtual WebDataServiceBase::Handle GetCreditCards(
     93       WebDataServiceConsumer* consumer) = 0;
     94 
     95   // Removes Autofill records from the database.
     96   virtual void RemoveAutofillDataModifiedBetween(
     97       const base::Time& delete_begin, const base::Time& delete_end) = 0;
     98 
     99   // Removes origin URLs associated with Autofill profiles and credit cards from
    100   // the database.
    101   virtual void RemoveOriginURLsModifiedBetween(
    102       const base::Time& delete_begin, const base::Time& delete_end) = 0;
    103 };
    104 
    105 }  // namespace autofill
    106 
    107 #endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_H_
    108