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