OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ | |
6 #define COMPONENTS_AUTOFILL_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 content { | |
16 struct PasswordForm; | |
17 struct SSLStatus; | |
18 } | |
19 | |
20 namespace gfx { | |
21 class Rect; | |
22 class RectF; | |
23 } | |
24 | |
25 class GURL; | |
26 class InfoBarService; | |
27 class PrefService; | |
28 | |
29 namespace autofill { | |
30 | |
31 class AutofillMetrics; | |
32 class AutofillPopupDelegate; | |
33 class CreditCard; | |
34 class FormStructure; | |
35 class PasswordGenerator; | |
36 class PersonalDataManager; | |
37 struct FormData; | |
38 | |
39 namespace autocheckout { | |
40 class WhitelistManager; | |
41 } | |
42 | |
43 enum DialogType { | |
44 // Autofill dialog for the Autocheckout feature. | |
45 DIALOG_TYPE_AUTOCHECKOUT, | |
46 // Autofill dialog for the requestAutocomplete feature. | |
47 DIALOG_TYPE_REQUEST_AUTOCOMPLETE, | |
48 }; | |
49 | |
50 // A delegate interface that needs to be supplied to AutofillManager | |
51 // by the embedder. | |
52 // | |
53 // Each delegate instance is associated with a given context within | |
54 // which an AutofillManager is used (e.g. a single tab), so when we | |
55 // say "for the delegate" below, we mean "in the execution context the | |
56 // delegate is associated with" (e.g. for the tab the AutofillManager is | |
57 // attached to). | |
58 class AutofillManagerDelegate { | |
59 public: | |
60 virtual ~AutofillManagerDelegate() {} | |
61 | |
62 // Gets the PersonalDataManager instance associated with the delegate. | |
63 virtual PersonalDataManager* GetPersonalDataManager() = 0; | |
64 | |
65 // Gets the preferences associated with the delegate. | |
66 virtual PrefService* GetPrefs() = 0; | |
67 | |
68 // Gets the autocheckout::WhitelistManager instance associated with the | |
69 // delegate. | |
70 virtual autocheckout::WhitelistManager* | |
71 GetAutocheckoutWhitelistManager() const = 0; | |
72 | |
73 // Hides the associated request autocomplete dialog (if it exists). | |
74 virtual void HideRequestAutocompleteDialog() = 0; | |
75 | |
76 // Causes an error explaining that Autocheckout has failed to be displayed to | |
77 // the user. | |
78 virtual void OnAutocheckoutError() = 0; | |
79 | |
80 // Called when an Autocheckout flow has succeeded. Causes a notification | |
81 // explaining that they must confirm their purchase to be displayed to the | |
82 // user. | |
83 virtual void OnAutocheckoutSuccess() = 0; | |
84 | |
85 // Causes the Autofill settings UI to be shown. | |
86 virtual void ShowAutofillSettings() = 0; | |
87 | |
88 // Run |save_card_callback| if the credit card should be imported as personal | |
89 // data. |metric_logger| can be used to log user actions. | |
90 virtual void ConfirmSaveCreditCard( | |
91 const AutofillMetrics& metric_logger, | |
92 const CreditCard& credit_card, | |
93 const base::Closure& save_card_callback) = 0; | |
94 | |
95 // Causes the Autocheckout bubble UI to be displayed. |bounding_box| is the | |
96 // anchor for the bubble. |is_google_user| is whether or not the user is | |
97 // logged into or has been logged into accounts.google.com. |callback| is run | |
98 // if the bubble is accepted. | |
99 virtual void ShowAutocheckoutBubble( | |
100 const gfx::RectF& bounding_box, | |
101 bool is_google_user, | |
102 const base::Callback<void(bool)>& callback) = 0; | |
103 | |
104 // Causes the dialog for request autocomplete feature to be shown. | |
105 virtual void ShowRequestAutocompleteDialog( | |
106 const FormData& form, | |
107 const GURL& source_url, | |
108 DialogType dialog_type, | |
109 const base::Callback<void(const FormStructure*, | |
110 const std::string&)>& callback) = 0; | |
111 | |
112 // Hide the Autocheckout bubble if one is currently showing. | |
113 virtual void HideAutocheckoutBubble() = 0; | |
114 | |
115 // Shows an Autofill popup with the given |values|, |labels|, |icons|, and | |
116 // |identifiers| for the element at |element_bounds|. |delegate| will be | |
117 // notified of popup events. | |
118 virtual void ShowAutofillPopup( | |
119 const gfx::RectF& element_bounds, | |
120 base::i18n::TextDirection text_direction, | |
121 const std::vector<base::string16>& values, | |
122 const std::vector<base::string16>& labels, | |
123 const std::vector<base::string16>& icons, | |
124 const std::vector<int>& identifiers, | |
125 base::WeakPtr<AutofillPopupDelegate> delegate) = 0; | |
126 | |
127 // Hide the Autofill popup if one is currently showing. | |
128 virtual void HideAutofillPopup() = 0; | |
129 | |
130 // Updates the Autocheckout progress bar. |value| must be in [0.0, 1.0]. | |
131 virtual void UpdateProgressBar(double value) = 0; | |
132 }; | |
133 | |
134 } // namespace autofill | |
135 | |
136 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ | |
OLD | NEW |