Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / components / autofill / core / browser / autofill_manager_delegate.h
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_AUTOFILL_MANAGER_DELEGATE_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_
7
8 #include <vector>
9
10 #include "base/callback_forward.h"
11 #include "base/i18n/rtl.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string16.h"
14
15 namespace gfx {
16 class Rect;
17 class RectF;
18 }
19
20 class GURL;
21 class InfoBarService;
22 class PrefService;
23
24 namespace autofill {
25
26 class AutofillMetrics;
27 class AutofillPopupDelegate;
28 class AutofillWebDataService;
29 class CreditCard;
30 class FormStructure;
31 class PasswordGenerator;
32 class PersonalDataManager;
33 struct FormData;
34 struct PasswordForm;
35
36 // A delegate interface that needs to be supplied to AutofillManager
37 // by the embedder.
38 //
39 // Each delegate instance is associated with a given context within
40 // which an AutofillManager is used (e.g. a single tab), so when we
41 // say "for the delegate" below, we mean "in the execution context the
42 // delegate is associated with" (e.g. for the tab the AutofillManager is
43 // attached to).
44 class AutofillManagerDelegate {
45  public:
46   // Copy of blink::WebFormElement::AutocompleteResult.
47   enum RequestAutocompleteResult {
48       AutocompleteResultSuccess,
49       AutocompleteResultErrorDisabled,
50       AutocompleteResultErrorCancel,
51       AutocompleteResultErrorInvalid,
52   };
53
54   typedef base::Callback<
55       void(RequestAutocompleteResult,
56            const base::string16&,
57            const FormStructure*)> ResultCallback;
58
59   virtual ~AutofillManagerDelegate() {}
60
61   // Gets the PersonalDataManager instance associated with the delegate.
62   virtual PersonalDataManager* GetPersonalDataManager() = 0;
63
64   // Gets the AutofillWebDataService instance associated with the delegate.
65   virtual scoped_refptr<AutofillWebDataService> GetDatabase() = 0;
66
67   // Gets the preferences associated with the delegate.
68   virtual PrefService* GetPrefs() = 0;
69
70   // Hides the associated request autocomplete dialog (if it exists).
71   virtual void HideRequestAutocompleteDialog() = 0;
72
73   // Causes the Autofill settings UI to be shown.
74   virtual void ShowAutofillSettings() = 0;
75
76   // Run |save_card_callback| if the credit card should be imported as personal
77   // data. |metric_logger| can be used to log user actions.
78   virtual void ConfirmSaveCreditCard(
79       const AutofillMetrics& metric_logger,
80       const base::Closure& save_card_callback) = 0;
81
82   // Causes the dialog for request autocomplete feature to be shown.
83   virtual void ShowRequestAutocompleteDialog(
84       const FormData& form,
85       const GURL& source_url,
86       const ResultCallback& callback) = 0;
87
88   // Shows an Autofill popup with the given |values|, |labels|, |icons|, and
89   // |identifiers| for the element at |element_bounds|. |delegate| will be
90   // notified of popup events.
91   virtual void ShowAutofillPopup(
92       const gfx::RectF& element_bounds,
93       base::i18n::TextDirection text_direction,
94       const std::vector<base::string16>& values,
95       const std::vector<base::string16>& labels,
96       const std::vector<base::string16>& icons,
97       const std::vector<int>& identifiers,
98       base::WeakPtr<AutofillPopupDelegate> delegate) = 0;
99
100   // Update the data list values shown by the Autofill popup, if visible.
101   virtual void UpdateAutofillPopupDataListValues(
102       const std::vector<base::string16>& values,
103       const std::vector<base::string16>& labels) = 0;
104
105   // Hide the Autofill popup if one is currently showing.
106   virtual void HideAutofillPopup() = 0;
107
108   // Whether the Autocomplete feature of Autofill should be enabled.
109   virtual bool IsAutocompleteEnabled() = 0;
110
111   // Pass the form structures to the password generation manager to detect
112   // account creation forms.
113   virtual void DetectAccountCreationForms(
114       const std::vector<autofill::FormStructure*>& forms) = 0;
115
116   // Inform the delegate that the field has been filled.
117   virtual void DidFillOrPreviewField(
118       const base::string16& autofilled_value,
119       const base::string16& profile_full_name) = 0;
120
121 };
122
123 }  // namespace autofill
124
125 #endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_