• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 AutofillEntry;
27 class AutofillProfile;
28 class CreditCard;
29 struct FormFieldData;
30 
31 // Pure virtual interface for retrieving Autofill data.  API users
32 // should use AutofillWebDataService.
33 class AutofillWebData {
34  public:
~AutofillWebData()35   virtual ~AutofillWebData() {}
36 
37   // Schedules a task to add form fields to the web database.
38   virtual void AddFormFields(
39       const std::vector<FormFieldData>& fields) = 0;
40 
41   // Initiates the request for a vector of values which have been entered in
42   // form input fields named |name|.  The method OnWebDataServiceRequestDone of
43   // |consumer| gets called back when the request is finished, with the vector
44   // included in the argument |result|.
45   virtual WebDataServiceBase::Handle GetFormValuesForElementName(
46       const base::string16& name,
47       const base::string16& prefix,
48       int limit,
49       WebDataServiceConsumer* consumer) = 0;
50 
51   // Checks if there are any form elements in the database.
52   virtual WebDataServiceBase::Handle HasFormElements(
53       WebDataServiceConsumer* consumer) = 0;
54 
55   // Removes form elements recorded for Autocomplete from the database.
56   virtual void RemoveFormElementsAddedBetween(
57       const base::Time& delete_begin, const base::Time& delete_end) = 0;
58 
59   virtual void RemoveFormValueForElementName(const base::string16& name,
60                                              const base::string16& value) = 0;
61 
62   // Schedules a task to add an Autofill profile to the web database.
63   virtual void AddAutofillProfile(const AutofillProfile& profile) = 0;
64 
65   // Schedules a task to update an Autofill profile in the web database.
66   virtual void UpdateAutofillProfile(const AutofillProfile& profile) = 0;
67 
68   // Schedules a task to remove an Autofill profile from the web database.
69   // |guid| is the identifer of the profile to remove.
70   virtual void RemoveAutofillProfile(const std::string& guid) = 0;
71 
72   // Initiates the request for all Autofill profiles.  The method
73   // OnWebDataServiceRequestDone of |consumer| gets called when the request is
74   // finished, with the profiles included in the argument |result|.  The
75   // consumer owns the profiles.
76   virtual WebDataServiceBase::Handle GetAutofillProfiles(
77       WebDataServiceConsumer* consumer) = 0;
78 
79   // Schedules a task to update autofill entries in the web database.
80   virtual void UpdateAutofillEntries(
81       const std::vector<AutofillEntry>& autofill_entries) = 0;
82 
83   // Schedules a task to add credit card to the web database.
84   virtual void AddCreditCard(const CreditCard& credit_card) = 0;
85 
86   // Schedules a task to update credit card in the web database.
87   virtual void UpdateCreditCard(const CreditCard& credit_card) = 0;
88 
89   // Schedules a task to remove a credit card from the web database.
90   // |guid| is identifer of the credit card to remove.
91   virtual void RemoveCreditCard(const std::string& guid) = 0;
92 
93   // Initiates the request for all credit cards.  The method
94   // OnWebDataServiceRequestDone of |consumer| gets called when the request is
95   // finished, with the credit cards included in the argument |result|.  The
96   // consumer owns the credit cards.
97   virtual WebDataServiceBase::Handle GetCreditCards(
98       WebDataServiceConsumer* consumer) = 0;
99 
100   // Removes Autofill records from the database.
101   virtual void RemoveAutofillDataModifiedBetween(
102       const base::Time& delete_begin, const base::Time& delete_end) = 0;
103 
104   // Removes origin URLs associated with Autofill profiles and credit cards from
105   // the database.
106   virtual void RemoveOriginURLsModifiedBetween(
107       const base::Time& delete_begin, const base::Time& delete_end) = 0;
108 };
109 
110 }  // namespace autofill
111 
112 #endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_H_
113