| 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 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 virtual void removeAutocompleteSuggestion( | 81 virtual void removeAutocompleteSuggestion( |
| 82 const WebKit::WebString& name, | 82 const WebKit::WebString& name, |
| 83 const WebKit::WebString& value) OVERRIDE; | 83 const WebKit::WebString& value) OVERRIDE; |
| 84 virtual void textFieldDidEndEditing( | 84 virtual void textFieldDidEndEditing( |
| 85 const WebKit::WebInputElement& element) OVERRIDE; | 85 const WebKit::WebInputElement& element) OVERRIDE; |
| 86 virtual void textFieldDidChange( | 86 virtual void textFieldDidChange( |
| 87 const WebKit::WebInputElement& element) OVERRIDE; | 87 const WebKit::WebInputElement& element) OVERRIDE; |
| 88 virtual void textFieldDidReceiveKeyDown( | 88 virtual void textFieldDidReceiveKeyDown( |
| 89 const WebKit::WebInputElement& element, | 89 const WebKit::WebInputElement& element, |
| 90 const WebKit::WebKeyboardEvent& event) OVERRIDE; | 90 const WebKit::WebKeyboardEvent& event) OVERRIDE; |
| 91 virtual void didRequestAutocomplete( |
| 92 WebKit::WebFrame* frame, |
| 93 const WebKit::WebFormElement& form) OVERRIDE; |
| 91 | 94 |
| 92 void OnSuggestionsReturned(int query_id, | 95 void OnSuggestionsReturned(int query_id, |
| 93 const std::vector<string16>& values, | 96 const std::vector<string16>& values, |
| 94 const std::vector<string16>& labels, | 97 const std::vector<string16>& labels, |
| 95 const std::vector<string16>& icons, | 98 const std::vector<string16>& icons, |
| 96 const std::vector<int>& unique_ids); | 99 const std::vector<int>& unique_ids); |
| 97 void OnFormDataFilled(int query_id, const FormData& form); | 100 void OnFormDataFilled(int query_id, const FormData& form); |
| 98 void OnFieldTypePredictionsAvailable( | 101 void OnFieldTypePredictionsAvailable( |
| 99 const std::vector<FormDataPredictions>& forms); | 102 const std::vector<FormDataPredictions>& forms); |
| 100 | 103 |
| 101 // For external Autofill selection. | 104 // For external Autofill selection. |
| 102 void OnSetAutofillActionFill(); | 105 void OnSetAutofillActionFill(); |
| 103 void OnClearForm(); | 106 void OnClearForm(); |
| 104 void OnSetAutofillActionPreview(); | 107 void OnSetAutofillActionPreview(); |
| 105 void OnClearPreviewedForm(); | 108 void OnClearPreviewedForm(); |
| 106 void OnSetNodeText(const string16& value); | 109 void OnSetNodeText(const string16& value); |
| 107 void OnAcceptDataListSuggestion(const string16& value); | 110 void OnAcceptDataListSuggestion(const string16& value); |
| 108 void OnAcceptPasswordAutofillSuggestion(const string16& value); | 111 void OnAcceptPasswordAutofillSuggestion(const string16& value); |
| 109 | 112 |
| 113 // For interactive autocomplete. |
| 114 void OnRequestAutocompleteFinished(int result); |
| 115 |
| 110 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug | 116 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug |
| 111 // http://bugs.webkit.org/show_bug.cgi?id=16976 | 117 // http://bugs.webkit.org/show_bug.cgi?id=16976 |
| 112 void TextFieldDidChangeImpl(const WebKit::WebInputElement& element); | 118 void TextFieldDidChangeImpl(const WebKit::WebInputElement& element); |
| 113 | 119 |
| 114 // Shows the autofill suggestions for |element|. | 120 // Shows the autofill suggestions for |element|. |
| 115 // This call is asynchronous and may or may not lead to the showing of a | 121 // This call is asynchronous and may or may not lead to the showing of a |
| 116 // suggestion popup (no popup is shown if there are no available suggestions). | 122 // suggestion popup (no popup is shown if there are no available suggestions). |
| 117 // |autofill_on_empty_values| specifies whether suggestions should be shown | 123 // |autofill_on_empty_values| specifies whether suggestions should be shown |
| 118 // when |element| contains no text. | 124 // when |element| contains no text. |
| 119 // |requires_caret_at_end| specifies whether suggestions should be shown when | 125 // |requires_caret_at_end| specifies whether suggestions should be shown when |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // Fills |form| and |field| with the FormData and FormField corresponding to | 161 // Fills |form| and |field| with the FormData and FormField corresponding to |
| 156 // |node|. Returns true if the data was found; and false otherwise. | 162 // |node|. Returns true if the data was found; and false otherwise. |
| 157 bool FindFormAndFieldForNode( | 163 bool FindFormAndFieldForNode( |
| 158 const WebKit::WebNode& node, | 164 const WebKit::WebNode& node, |
| 159 FormData* form, | 165 FormData* form, |
| 160 FormFieldData* field) WARN_UNUSED_RESULT; | 166 FormFieldData* field) WARN_UNUSED_RESULT; |
| 161 | 167 |
| 162 // Set |node| to display the given |value|. | 168 // Set |node| to display the given |value|. |
| 163 void SetNodeText(const string16& value, WebKit::WebInputElement* node); | 169 void SetNodeText(const string16& value, WebKit::WebInputElement* node); |
| 164 | 170 |
| 171 // Hides any currently showing Autofill popups. |
| 172 void HidePopups(); |
| 173 |
| 165 FormCache form_cache_; | 174 FormCache form_cache_; |
| 166 | 175 |
| 167 PasswordAutofillManager* password_autofill_manager_; // WEAK reference. | 176 PasswordAutofillManager* password_autofill_manager_; // WEAK reference. |
| 168 | 177 |
| 169 // The ID of the last request sent for form field Autofill. Used to ignore | 178 // The ID of the last request sent for form field Autofill. Used to ignore |
| 170 // out of date responses. | 179 // out of date responses. |
| 171 int autofill_query_id_; | 180 int autofill_query_id_; |
| 172 | 181 |
| 173 // The element corresponding to the last request sent for form field Autofill. | 182 // The element corresponding to the last request sent for form field Autofill. |
| 174 WebKit::WebInputElement element_; | 183 WebKit::WebInputElement element_; |
| 175 | 184 |
| 185 // The element corresponding to the last request sent for an interactive |
| 186 // autocomplete. |
| 187 WebKit::WebFormElement form_; |
| 188 |
| 176 // The action to take when receiving Autofill data from the AutofillManager. | 189 // The action to take when receiving Autofill data from the AutofillManager. |
| 177 AutofillAction autofill_action_; | 190 AutofillAction autofill_action_; |
| 178 | 191 |
| 179 // Should we display a warning if autofill is disabled? | 192 // Should we display a warning if autofill is disabled? |
| 180 bool display_warning_if_disabled_; | 193 bool display_warning_if_disabled_; |
| 181 | 194 |
| 182 // Was the query node autofilled prior to previewing the form? | 195 // Was the query node autofilled prior to previewing the form? |
| 183 bool was_query_node_autofilled_; | 196 bool was_query_node_autofilled_; |
| 184 | 197 |
| 185 // Have we already shown Autofill suggestions for the field the user is | 198 // Have we already shown Autofill suggestions for the field the user is |
| 186 // currently editing? Used to keep track of state for metrics logging. | 199 // currently editing? Used to keep track of state for metrics logging. |
| 187 bool has_shown_autofill_popup_for_current_edit_; | 200 bool has_shown_autofill_popup_for_current_edit_; |
| 188 | 201 |
| 189 // If true we just set the node text so we shouldn't show the popup. | 202 // If true we just set the node text so we shouldn't show the popup. |
| 190 bool did_set_node_text_; | 203 bool did_set_node_text_; |
| 191 | 204 |
| 205 // Whether there is a pending request for an interactive autocomplete. |
| 206 bool has_requested_autocomplete_; |
| 207 |
| 192 base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_; | 208 base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_; |
| 193 | 209 |
| 194 friend class PasswordAutofillManagerTest; | 210 friend class PasswordAutofillManagerTest; |
| 195 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, SendForms); | 211 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, SendForms); |
| 196 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, FillFormElement); | 212 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, FillFormElement); |
| 197 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest, WaitUsername); | 213 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest, WaitUsername); |
| 198 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest, SuggestionAccept); | 214 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest, SuggestionAccept); |
| 199 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest, SuggestionSelect); | 215 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillManagerTest, SuggestionSelect); |
| 200 | 216 |
| 201 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); | 217 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); |
| 202 }; | 218 }; |
| 203 | 219 |
| 204 } // namespace autofill | 220 } // namespace autofill |
| 205 | 221 |
| 206 #endif // CHROME_RENDERER_AUTOFILL_AUTOFILL_AGENT_H_ | 222 #endif // CHROME_RENDERER_AUTOFILL_AUTOFILL_AGENT_H_ |
| OLD | NEW |