OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_RENDERER_AUTOFILL_AUTOFILL_AGENT_H_ | 5 #ifndef CHROME_RENDERER_AUTOFILL_AUTOFILL_AGENT_H_ |
6 #define CHROME_RENDERER_AUTOFILL_AUTOFILL_AGENT_H_ | 6 #define CHROME_RENDERER_AUTOFILL_AUTOFILL_AGENT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // PageClickListener: | 69 // PageClickListener: |
70 virtual bool InputElementClicked(const WebKit::WebInputElement& element, | 70 virtual bool InputElementClicked(const WebKit::WebInputElement& element, |
71 bool was_focused, | 71 bool was_focused, |
72 bool is_focused) OVERRIDE; | 72 bool is_focused) OVERRIDE; |
73 virtual bool InputElementLostFocus() OVERRIDE; | 73 virtual bool InputElementLostFocus() OVERRIDE; |
74 | 74 |
75 // WebKit::WebAutofillClient: | 75 // WebKit::WebAutofillClient: |
76 virtual void didAcceptAutofillSuggestion(const WebKit::WebNode& node, | 76 virtual void didAcceptAutofillSuggestion(const WebKit::WebNode& node, |
77 const WebKit::WebString& value, | 77 const WebKit::WebString& value, |
78 const WebKit::WebString& label, | 78 const WebKit::WebString& label, |
79 int unique_id, | 79 int item_id, |
80 unsigned index) OVERRIDE; | 80 unsigned index) OVERRIDE; |
81 virtual void didSelectAutofillSuggestion(const WebKit::WebNode& node, | 81 virtual void didSelectAutofillSuggestion(const WebKit::WebNode& node, |
82 const WebKit::WebString& value, | 82 const WebKit::WebString& value, |
83 const WebKit::WebString& label, | 83 const WebKit::WebString& label, |
84 int unique_id) OVERRIDE; | 84 int item_id) OVERRIDE; |
85 virtual void didClearAutofillSelection(const WebKit::WebNode& node) OVERRIDE; | 85 virtual void didClearAutofillSelection(const WebKit::WebNode& node) OVERRIDE; |
86 virtual void removeAutocompleteSuggestion( | 86 virtual void removeAutocompleteSuggestion( |
87 const WebKit::WebString& name, | 87 const WebKit::WebString& name, |
88 const WebKit::WebString& value) OVERRIDE; | 88 const WebKit::WebString& value) OVERRIDE; |
89 virtual void textFieldDidEndEditing( | 89 virtual void textFieldDidEndEditing( |
90 const WebKit::WebInputElement& element) OVERRIDE; | 90 const WebKit::WebInputElement& element) OVERRIDE; |
91 virtual void textFieldDidChange( | 91 virtual void textFieldDidChange( |
92 const WebKit::WebInputElement& element) OVERRIDE; | 92 const WebKit::WebInputElement& element) OVERRIDE; |
93 virtual void textFieldDidReceiveKeyDown( | 93 virtual void textFieldDidReceiveKeyDown( |
94 const WebKit::WebInputElement& element, | 94 const WebKit::WebInputElement& element, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 void ShowSuggestions(const WebKit::WebInputElement& element, | 130 void ShowSuggestions(const WebKit::WebInputElement& element, |
131 bool autofill_on_empty_values, | 131 bool autofill_on_empty_values, |
132 bool requires_caret_at_end, | 132 bool requires_caret_at_end, |
133 bool display_warning_if_disabled); | 133 bool display_warning_if_disabled); |
134 | 134 |
135 // Queries the browser for Autocomplete and Autofill suggestions for the given | 135 // Queries the browser for Autocomplete and Autofill suggestions for the given |
136 // |element|. | 136 // |element|. |
137 void QueryAutofillSuggestions(const WebKit::WebInputElement& element, | 137 void QueryAutofillSuggestions(const WebKit::WebInputElement& element, |
138 bool display_warning_if_disabled); | 138 bool display_warning_if_disabled); |
139 | 139 |
| 140 void CombineDataListEntriesAndShow(const WebKit::WebInputElement& element, |
| 141 const std::vector<string16>& values, |
| 142 const std::vector<string16>& labels, |
| 143 const std::vector<string16>& icons, |
| 144 const std::vector<int>& item_ids, |
| 145 bool has_autofill_item); |
| 146 |
140 // Queries the AutofillManager for form data for the form containing |node|. | 147 // Queries the AutofillManager for form data for the form containing |node|. |
141 // |value| is the current text in the field, and |unique_id| is the selected | 148 // |value| is the current text in the field, and |unique_id| is the selected |
142 // profile's unique ID. |action| specifies whether to Fill or Preview the | 149 // profile's unique ID. |action| specifies whether to Fill or Preview the |
143 // values returned from the AutofillManager. | 150 // values returned from the AutofillManager. |
144 void FillAutofillFormData(const WebKit::WebNode& node, | 151 void FillAutofillFormData(const WebKit::WebNode& node, |
145 int unique_id, | 152 int unique_id, |
146 AutofillAction action); | 153 AutofillAction action); |
147 | 154 |
148 // Fills |form| and |field| with the FormData and FormField corresponding to | 155 // Fills |form| and |field| with the FormData and FormField corresponding to |
149 // |node|. Returns true if the data was found; and false otherwise. | 156 // |node|. Returns true if the data was found; and false otherwise. |
150 bool FindFormAndFieldForNode( | 157 bool FindFormAndFieldForNode( |
151 const WebKit::WebNode& node, | 158 const WebKit::WebNode& node, |
152 webkit::forms::FormData* form, | 159 webkit::forms::FormData* form, |
153 webkit::forms::FormField* field) WARN_UNUSED_RESULT; | 160 webkit::forms::FormField* field) WARN_UNUSED_RESULT; |
154 | 161 |
155 // Set |node| to display the given |value|. | 162 // Set |node| to display the given |value|. |
156 void SetNodeText(const string16& value, WebKit::WebInputElement* node); | 163 void SetNodeText(const string16& value, WebKit::WebInputElement* node); |
157 | 164 |
158 FormCache form_cache_; | 165 FormCache form_cache_; |
159 | 166 |
160 PasswordAutofillManager* password_autofill_manager_; // WEAK reference. | 167 PasswordAutofillManager* password_autofill_manager_; // WEAK reference. |
161 | 168 |
162 // The ID of the last request sent for form field Autofill. Used to ignore | 169 // The ID of the last request sent for form field Autofill. Used to ignore |
163 // out of date responses. | 170 // out of date responses. |
164 int autofill_query_id_; | 171 int autofill_query_id_; |
165 | 172 |
166 // The element corresponding to the last request sent for form field Autofill. | 173 // The element corresponding to the last request sent for form field Autofill. |
167 WebKit::WebInputElement autofill_query_element_; | 174 WebKit::WebInputElement element_; |
168 | 175 |
169 // The action to take when receiving Autofill data from the AutofillManager. | 176 // The action to take when receiving Autofill data from the AutofillManager. |
170 AutofillAction autofill_action_; | 177 AutofillAction autofill_action_; |
171 | 178 |
172 // Should we display a warning if autofill is disabled? | 179 // Should we display a warning if autofill is disabled? |
173 bool display_warning_if_disabled_; | 180 bool display_warning_if_disabled_; |
174 | 181 |
175 // Was the query node autofilled prior to previewing the form? | 182 // Was the query node autofilled prior to previewing the form? |
176 bool was_query_node_autofilled_; | 183 bool was_query_node_autofilled_; |
177 | 184 |
178 // The menu index of the "Clear" menu item. | |
179 int suggestions_clear_index_; | |
180 | |
181 // The menu index of the "Autofill options..." menu item. | |
182 int suggestions_options_index_; | |
183 | |
184 // Have we already shown Autofill suggestions for the field the user is | 185 // Have we already shown Autofill suggestions for the field the user is |
185 // currently editing? Used to keep track of state for metrics logging. | 186 // currently editing? Used to keep track of state for metrics logging. |
186 bool has_shown_autofill_popup_for_current_edit_; | 187 bool has_shown_autofill_popup_for_current_edit_; |
187 | 188 |
188 base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_; | 189 base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_; |
189 | 190 |
190 friend class PasswordAutofillManagerTest; | 191 friend class PasswordAutofillManagerTest; |
191 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, SendForms); | 192 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, SendForms); |
192 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, FillFormElement); | 193 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, FillFormElement); |
193 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest, WaitUsername); | 194 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest, WaitUsername); |
194 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest, SuggestionAccept); | 195 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest, SuggestionAccept); |
195 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest, SuggestionSelect); | 196 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest, SuggestionSelect); |
196 | 197 |
197 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); | 198 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); |
198 }; | 199 }; |
199 | 200 |
200 } // namespace autofill | 201 } // namespace autofill |
201 | 202 |
202 #endif // CHROME_RENDERER_AUTOFILL_AUTOFILL_AGENT_H_ | 203 #endif // CHROME_RENDERER_AUTOFILL_AUTOFILL_AGENT_H_ |
OLD | NEW |