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.
5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h"
13 #include "components/webdata/common/web_data_service_base.h"
22 class WebDataServiceConsumer
;
27 class AutofillProfile
;
31 // Pure virtual interface for retrieving Autofill data. API users
32 // should use AutofillWebDataService.
33 class AutofillWebData
{
35 virtual ~AutofillWebData() {}
37 // Schedules a task to add form fields to the web database.
38 virtual void AddFormFields(
39 const std::vector
<FormFieldData
>& fields
) = 0;
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
,
49 WebDataServiceConsumer
* consumer
) = 0;
51 // Checks if there are any form elements in the database.
52 virtual WebDataServiceBase::Handle
HasFormElements(
53 WebDataServiceConsumer
* consumer
) = 0;
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;
59 virtual void RemoveFormValueForElementName(const base::string16
& name
,
60 const base::string16
& value
) = 0;
62 // Schedules a task to add an Autofill profile to the web database.
63 virtual void AddAutofillProfile(const AutofillProfile
& profile
) = 0;
65 // Schedules a task to update an Autofill profile in the web database.
66 virtual void UpdateAutofillProfile(const AutofillProfile
& profile
) = 0;
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;
72 // Initiates the request for local/server 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 virtual WebDataServiceBase::Handle
GetServerProfiles(
79 WebDataServiceConsumer
* consumer
) = 0;
81 // Schedules a task to update autofill entries in the web database.
82 virtual void UpdateAutofillEntries(
83 const std::vector
<AutofillEntry
>& autofill_entries
) = 0;
85 // Schedules a task to add credit card to the web database.
86 virtual void AddCreditCard(const CreditCard
& credit_card
) = 0;
88 // Schedules a task to update credit card in the web database.
89 virtual void UpdateCreditCard(const CreditCard
& credit_card
) = 0;
91 // Schedules a task to remove a credit card from the web database.
92 // |guid| is identifer of the credit card to remove.
93 virtual void RemoveCreditCard(const std::string
& guid
) = 0;
95 // Initiates the request for local/server credit cards. The method
96 // OnWebDataServiceRequestDone of |consumer| gets called when the request is
97 // finished, with the credit cards included in the argument |result|. The
98 // consumer owns the credit cards.
99 virtual WebDataServiceBase::Handle
GetCreditCards(
100 WebDataServiceConsumer
* consumer
) = 0;
101 virtual WebDataServiceBase::Handle
GetServerCreditCards(
102 WebDataServiceConsumer
* consumer
) = 0;
104 // Toggles the record for a server credit card between masked (only last 4
105 // digits) and full (all digits).
106 virtual void UnmaskServerCreditCard(const CreditCard
& credit_card
,
107 const base::string16
& full_number
) = 0;
108 virtual void MaskServerCreditCard(const std::string
& id
) = 0;
110 // Updates the use count and last use date for a server card (masked or not).
111 virtual void UpdateServerCardUsageStats(const CreditCard
& credit_card
) = 0;
113 // Updates the use count and last use date for a server address.
114 virtual void UpdateServerAddressUsageStats(const AutofillProfile
& profile
)
117 // Removes Autofill records from the database.
118 virtual void RemoveAutofillDataModifiedBetween(
119 const base::Time
& delete_begin
, const base::Time
& delete_end
) = 0;
121 // Removes origin URLs associated with Autofill profiles and credit cards from
123 virtual void RemoveOriginURLsModifiedBetween(
124 const base::Time
& delete_begin
, const base::Time
& delete_end
) = 0;
127 } // namespace autofill
129 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_WEBDATA_H_