OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "components/autofill/content/browser/autocheckout_steps.h" | |
15 #include "components/autofill/core/browser/autocheckout_bubble_state.h" | |
16 | 14 |
17 namespace content { | 15 namespace content { |
18 struct PasswordForm; | 16 struct PasswordForm; |
19 } | 17 } |
20 | 18 |
21 namespace gfx { | 19 namespace gfx { |
22 class Rect; | 20 class Rect; |
23 class RectF; | 21 class RectF; |
24 } | 22 } |
25 | 23 |
26 class GURL; | 24 class GURL; |
27 class InfoBarService; | 25 class InfoBarService; |
28 class PrefService; | 26 class PrefService; |
29 | 27 |
30 namespace autofill { | 28 namespace autofill { |
31 | 29 |
32 class AutofillMetrics; | 30 class AutofillMetrics; |
33 class AutofillPopupDelegate; | 31 class AutofillPopupDelegate; |
34 class CreditCard; | 32 class CreditCard; |
35 class FormStructure; | 33 class FormStructure; |
36 class PasswordGenerator; | 34 class PasswordGenerator; |
37 class PersonalDataManager; | 35 class PersonalDataManager; |
38 struct FormData; | 36 struct FormData; |
39 | 37 |
40 namespace autocheckout { | 38 // TODO(ramankk): Simplify dialog type when removing autocheckout. |
Dan Beam
2013/08/20 21:44:08
where is this still used?
Raman Kakilate
2013/08/22 21:29:04
Should probably be deleted in separate CL.
~/chro
| |
41 class WhitelistManager; | |
42 } | |
43 | |
44 enum DialogType { | 39 enum DialogType { |
45 // Autofill dialog for the Autocheckout feature. | 40 // Autofill dialog for the Autocheckout feature. |
46 DIALOG_TYPE_AUTOCHECKOUT, | 41 DIALOG_TYPE_AUTOCHECKOUT, |
47 // Autofill dialog for the requestAutocomplete feature. | 42 // Autofill dialog for the requestAutocomplete feature. |
48 DIALOG_TYPE_REQUEST_AUTOCOMPLETE, | 43 DIALOG_TYPE_REQUEST_AUTOCOMPLETE, |
49 }; | 44 }; |
50 | 45 |
51 // A delegate interface that needs to be supplied to AutofillManager | 46 // A delegate interface that needs to be supplied to AutofillManager |
52 // by the embedder. | 47 // by the embedder. |
53 // | 48 // |
54 // Each delegate instance is associated with a given context within | 49 // Each delegate instance is associated with a given context within |
55 // which an AutofillManager is used (e.g. a single tab), so when we | 50 // which an AutofillManager is used (e.g. a single tab), so when we |
56 // say "for the delegate" below, we mean "in the execution context the | 51 // say "for the delegate" below, we mean "in the execution context the |
57 // delegate is associated with" (e.g. for the tab the AutofillManager is | 52 // delegate is associated with" (e.g. for the tab the AutofillManager is |
58 // attached to). | 53 // attached to). |
59 class AutofillManagerDelegate { | 54 class AutofillManagerDelegate { |
60 public: | 55 public: |
61 virtual ~AutofillManagerDelegate() {} | 56 virtual ~AutofillManagerDelegate() {} |
62 | 57 |
63 // Gets the PersonalDataManager instance associated with the delegate. | 58 // Gets the PersonalDataManager instance associated with the delegate. |
64 virtual PersonalDataManager* GetPersonalDataManager() = 0; | 59 virtual PersonalDataManager* GetPersonalDataManager() = 0; |
65 | 60 |
66 // Gets the preferences associated with the delegate. | 61 // Gets the preferences associated with the delegate. |
67 virtual PrefService* GetPrefs() = 0; | 62 virtual PrefService* GetPrefs() = 0; |
68 | 63 |
69 // Gets the autocheckout::WhitelistManager instance associated with the | |
70 // delegate. | |
71 virtual autocheckout::WhitelistManager* | |
72 GetAutocheckoutWhitelistManager() const = 0; | |
73 | |
74 // Hides the associated request autocomplete dialog (if it exists). | 64 // Hides the associated request autocomplete dialog (if it exists). |
75 virtual void HideRequestAutocompleteDialog() = 0; | 65 virtual void HideRequestAutocompleteDialog() = 0; |
76 | 66 |
77 // Causes an error explaining that Autocheckout has failed to be displayed to | |
78 // the user. | |
79 virtual void OnAutocheckoutError() = 0; | |
80 | |
81 // Called when an Autocheckout flow has succeeded. Causes a notification | |
82 // explaining that they must confirm their purchase to be displayed to the | |
83 // user. | |
84 virtual void OnAutocheckoutSuccess() = 0; | |
85 | |
86 // Causes the Autofill settings UI to be shown. | 67 // Causes the Autofill settings UI to be shown. |
87 virtual void ShowAutofillSettings() = 0; | 68 virtual void ShowAutofillSettings() = 0; |
88 | 69 |
89 // Run |save_card_callback| if the credit card should be imported as personal | 70 // Run |save_card_callback| if the credit card should be imported as personal |
90 // data. |metric_logger| can be used to log user actions. | 71 // data. |metric_logger| can be used to log user actions. |
91 virtual void ConfirmSaveCreditCard( | 72 virtual void ConfirmSaveCreditCard( |
92 const AutofillMetrics& metric_logger, | 73 const AutofillMetrics& metric_logger, |
93 const CreditCard& credit_card, | 74 const CreditCard& credit_card, |
94 const base::Closure& save_card_callback) = 0; | 75 const base::Closure& save_card_callback) = 0; |
95 | 76 |
96 // Causes the Autocheckout bubble UI to be displayed. |bounding_box| is the | |
97 // anchor for the bubble. |is_google_user| is whether or not the user is | |
98 // logged into or has been logged into accounts.google.com. |callback| is run | |
99 // if the bubble is accepted. The returned boolean informs the caller whether | |
100 // or not the bubble is successfully shown. | |
101 virtual bool ShowAutocheckoutBubble( | |
102 const gfx::RectF& bounding_box, | |
103 bool is_google_user, | |
104 const base::Callback<void(AutocheckoutBubbleState)>& callback) = 0; | |
105 | |
106 // Causes the dialog for request autocomplete feature to be shown. | 77 // Causes the dialog for request autocomplete feature to be shown. |
107 virtual void ShowRequestAutocompleteDialog( | 78 virtual void ShowRequestAutocompleteDialog( |
108 const FormData& form, | 79 const FormData& form, |
109 const GURL& source_url, | 80 const GURL& source_url, |
110 DialogType dialog_type, | 81 DialogType dialog_type, |
111 const base::Callback<void(const FormStructure*, | 82 const base::Callback<void(const FormStructure*, |
112 const std::string&)>& callback) = 0; | 83 const std::string&)>& callback) = 0; |
113 | 84 |
114 // Hide the Autocheckout bubble if one is currently showing. | |
115 virtual void HideAutocheckoutBubble() = 0; | |
116 | |
117 // Shows an Autofill popup with the given |values|, |labels|, |icons|, and | 85 // Shows an Autofill popup with the given |values|, |labels|, |icons|, and |
118 // |identifiers| for the element at |element_bounds|. |delegate| will be | 86 // |identifiers| for the element at |element_bounds|. |delegate| will be |
119 // notified of popup events. | 87 // notified of popup events. |
120 virtual void ShowAutofillPopup( | 88 virtual void ShowAutofillPopup( |
121 const gfx::RectF& element_bounds, | 89 const gfx::RectF& element_bounds, |
122 base::i18n::TextDirection text_direction, | 90 base::i18n::TextDirection text_direction, |
123 const std::vector<base::string16>& values, | 91 const std::vector<base::string16>& values, |
124 const std::vector<base::string16>& labels, | 92 const std::vector<base::string16>& labels, |
125 const std::vector<base::string16>& icons, | 93 const std::vector<base::string16>& icons, |
126 const std::vector<int>& identifiers, | 94 const std::vector<int>& identifiers, |
127 base::WeakPtr<AutofillPopupDelegate> delegate) = 0; | 95 base::WeakPtr<AutofillPopupDelegate> delegate) = 0; |
128 | 96 |
129 // Update the data list values shown by the Autofill popup, if visible. | 97 // Update the data list values shown by the Autofill popup, if visible. |
130 virtual void UpdateAutofillPopupDataListValues( | 98 virtual void UpdateAutofillPopupDataListValues( |
131 const std::vector<base::string16>& values, | 99 const std::vector<base::string16>& values, |
132 const std::vector<base::string16>& labels) = 0; | 100 const std::vector<base::string16>& labels) = 0; |
133 | 101 |
134 // Hide the Autofill popup if one is currently showing. | 102 // Hide the Autofill popup if one is currently showing. |
135 virtual void HideAutofillPopup() = 0; | 103 virtual void HideAutofillPopup() = 0; |
136 | 104 |
137 // Whether the Autocomplete feature of Autofill should be enabled. | 105 // Whether the Autocomplete feature of Autofill should be enabled. |
138 virtual bool IsAutocompleteEnabled() = 0; | 106 virtual bool IsAutocompleteEnabled() = 0; |
139 | |
140 // Update progress of the Autocheckout flow as displayed to the user. | |
141 virtual void AddAutocheckoutStep(AutocheckoutStepType step_type) = 0; | |
142 virtual void UpdateAutocheckoutStep( | |
143 AutocheckoutStepType step_type, | |
144 AutocheckoutStepStatus step_status) = 0; | |
145 }; | 107 }; |
146 | 108 |
147 } // namespace autofill | 109 } // namespace autofill |
148 | 110 |
149 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ | 111 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_DELEGATE_H_ |
OLD | NEW |