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_CONTENT_RENDERER_AUTOFILL_AGENT_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ |
6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
16 #include "components/autofill/content/renderer/form_cache.h" | 16 #include "components/autofill/content/renderer/form_cache.h" |
17 #include "components/autofill/content/renderer/page_click_listener.h" | 17 #include "components/autofill/content/renderer/page_click_listener.h" |
18 #include "components/autofill/core/common/forms_seen_state.h" | 18 #include "components/autofill/core/common/forms_seen_state.h" |
19 #include "content/public/renderer/render_view_observer.h" | 19 #include "content/public/renderer/render_view_observer.h" |
20 #include "third_party/WebKit/public/web/WebAutofillClient.h" | 20 #include "third_party/WebKit/public/web/WebAutofillClient.h" |
21 #include "third_party/WebKit/public/web/WebFormControlElement.h" | |
21 #include "third_party/WebKit/public/web/WebFormElement.h" | 22 #include "third_party/WebKit/public/web/WebFormElement.h" |
22 #include "third_party/WebKit/public/web/WebInputElement.h" | 23 #include "third_party/WebKit/public/web/WebInputElement.h" |
24 #include "third_party/WebKit/public/web/WebTextAreaElement.h" | |
23 | 25 |
24 namespace blink { | 26 namespace blink { |
25 class WebNode; | 27 class WebNode; |
26 class WebView; | 28 class WebView; |
27 } | 29 } |
28 | 30 |
29 namespace autofill { | 31 namespace autofill { |
30 | 32 |
31 struct FormData; | 33 struct FormData; |
32 struct FormFieldData; | 34 struct FormFieldData; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 bool is_new_navigation) OVERRIDE; | 70 bool is_new_navigation) OVERRIDE; |
69 virtual void FrameDetached(blink::WebFrame* frame) OVERRIDE; | 71 virtual void FrameDetached(blink::WebFrame* frame) OVERRIDE; |
70 virtual void WillSubmitForm(blink::WebFrame* frame, | 72 virtual void WillSubmitForm(blink::WebFrame* frame, |
71 const blink::WebFormElement& form) OVERRIDE; | 73 const blink::WebFormElement& form) OVERRIDE; |
72 virtual void ZoomLevelChanged() OVERRIDE; | 74 virtual void ZoomLevelChanged() OVERRIDE; |
73 virtual void DidChangeScrollOffset(blink::WebFrame* frame) OVERRIDE; | 75 virtual void DidChangeScrollOffset(blink::WebFrame* frame) OVERRIDE; |
74 virtual void FocusedNodeChanged(const blink::WebNode& node) OVERRIDE; | 76 virtual void FocusedNodeChanged(const blink::WebNode& node) OVERRIDE; |
75 virtual void OrientationChangeEvent(int orientation) OVERRIDE; | 77 virtual void OrientationChangeEvent(int orientation) OVERRIDE; |
76 | 78 |
77 // PageClickListener: | 79 // PageClickListener: |
78 virtual void InputElementClicked(const blink::WebInputElement& element, | 80 virtual void FormControlElementClicked( |
79 bool was_focused, | 81 const blink::WebFormControlElement& element, |
80 bool is_focused) OVERRIDE; | 82 bool was_focused, |
81 virtual void InputElementLostFocus() OVERRIDE; | 83 bool is_focused) OVERRIDE; |
84 virtual void FormControlElementLostFocus() OVERRIDE; | |
82 | 85 |
83 // blink::WebAutofillClient: | 86 // blink::WebAutofillClient: |
84 virtual void textFieldDidEndEditing( | 87 virtual void textFieldDidEndEditing( |
85 const blink::WebInputElement& element) OVERRIDE; | 88 const blink::WebInputElement& element) OVERRIDE; |
89 // TODO: To be removed once next Blink roll is done | |
Ilya Sherman
2014/02/22 06:24:20
nit: TODO's should be formatted as "TODO(ziran.sun
ziran.sun
2014/02/25 16:10:03
textFieldDidChange() change is not in yet. More ch
| |
86 virtual void textFieldDidChange( | 90 virtual void textFieldDidChange( |
87 const blink::WebInputElement& element) OVERRIDE; | 91 const blink::WebInputElement& element); |
92 // TODO: OVERRIDE this function once next Blink roll is done | |
93 virtual void textFieldDidChange( | |
94 const blink::WebFormControlElement& element); | |
88 virtual void textFieldDidReceiveKeyDown( | 95 virtual void textFieldDidReceiveKeyDown( |
89 const blink::WebInputElement& element, | 96 const blink::WebInputElement& element, |
90 const blink::WebKeyboardEvent& event) OVERRIDE; | 97 const blink::WebKeyboardEvent& event) OVERRIDE; |
91 virtual void didRequestAutocomplete( | 98 virtual void didRequestAutocomplete( |
92 blink::WebFrame* frame, | 99 blink::WebFrame* frame, |
93 const blink::WebFormElement& form) OVERRIDE; | 100 const blink::WebFormElement& form) OVERRIDE; |
94 virtual void setIgnoreTextChanges(bool ignore) OVERRIDE; | 101 virtual void setIgnoreTextChanges(bool ignore) OVERRIDE; |
95 virtual void didAssociateFormControls( | 102 virtual void didAssociateFormControls( |
96 const blink::WebVector<blink::WebNode>& nodes) OVERRIDE; | 103 const blink::WebVector<blink::WebNode>& nodes) OVERRIDE; |
97 virtual void openTextDataListChooser(const blink::WebInputElement& element); | 104 virtual void openTextDataListChooser(const blink::WebInputElement& element); |
(...skipping 19 matching lines...) Expand all Loading... | |
117 // Called when an autocomplete request succeeds or fails with the |result|. | 124 // Called when an autocomplete request succeeds or fails with the |result|. |
118 void FinishAutocompleteRequest( | 125 void FinishAutocompleteRequest( |
119 blink::WebFormElement::AutocompleteResult result); | 126 blink::WebFormElement::AutocompleteResult result); |
120 | 127 |
121 // Called when the page is actually shown in the browser, as opposed to simply | 128 // Called when the page is actually shown in the browser, as opposed to simply |
122 // being preloaded. | 129 // being preloaded. |
123 void OnPageShown(); | 130 void OnPageShown(); |
124 | 131 |
125 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug | 132 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug |
126 // http://bugs.webkit.org/show_bug.cgi?id=16976 | 133 // http://bugs.webkit.org/show_bug.cgi?id=16976 |
127 void TextFieldDidChangeImpl(const blink::WebInputElement& element); | 134 void TextFieldDidChangeImpl(const blink::WebFormControlElement& element); |
128 | 135 |
129 // Shows the autofill suggestions for |element|. | 136 // Shows the autofill suggestions for |element|. |
130 // This call is asynchronous and may or may not lead to the showing of a | 137 // This call is asynchronous and may or may not lead to the showing of a |
131 // suggestion popup (no popup is shown if there are no available suggestions). | 138 // suggestion popup (no popup is shown if there are no available suggestions). |
132 // |autofill_on_empty_values| specifies whether suggestions should be shown | 139 // |autofill_on_empty_values| specifies whether suggestions should be shown |
133 // when |element| contains no text. | 140 // when |element| contains no text. |
134 // |requires_caret_at_end| specifies whether suggestions should be shown when | 141 // |requires_caret_at_end| specifies whether suggestions should be shown when |
135 // the caret is not after the last character in |element|. | 142 // the caret is not after the last character in |element|. |
136 // |display_warning_if_disabled| specifies whether a warning should be | 143 // |display_warning_if_disabled| specifies whether a warning should be |
137 // displayed to the user if Autofill has suggestions available, but cannot | 144 // displayed to the user if Autofill has suggestions available, but cannot |
138 // fill them because it is disabled (e.g. when trying to fill a credit card | 145 // fill them because it is disabled (e.g. when trying to fill a credit card |
139 // form on a non-secure website). | 146 // form on a non-secure website). |
140 // |datalist_only| specifies whether all of <datalist> suggestions and no | 147 // |datalist_only| specifies whether all of <datalist> suggestions and no |
141 // autofill suggestions are shown. |autofill_on_empty_values| and | 148 // autofill suggestions are shown. |autofill_on_empty_values| and |
142 // |requires_caret_at_end| are ignored if |datalist_only| is true. | 149 // |requires_caret_at_end| are ignored if |datalist_only| is true. |
143 void ShowSuggestions(const blink::WebInputElement& element, | 150 void ShowSuggestions(const blink::WebFormControlElement& element, |
144 bool autofill_on_empty_values, | 151 bool autofill_on_empty_values, |
145 bool requires_caret_at_end, | 152 bool requires_caret_at_end, |
146 bool display_warning_if_disabled, | 153 bool display_warning_if_disabled, |
147 bool datalist_only); | 154 bool datalist_only); |
148 | 155 |
149 // Queries the browser for Autocomplete and Autofill suggestions for the given | 156 // Queries the browser for Autocomplete and Autofill suggestions for the given |
150 // |element|. | 157 // |element|. |
151 void QueryAutofillSuggestions(const blink::WebInputElement& element, | 158 void QueryAutofillSuggestions(const blink::WebFormControlElement& element, |
152 bool display_warning_if_disabled, | 159 bool display_warning_if_disabled, |
153 bool datalist_only); | 160 bool datalist_only); |
154 | 161 |
155 // Sets the element value to reflect the selected |suggested_value|. | 162 // Sets the element value to reflect the selected |suggested_value|. |
156 void AcceptDataListSuggestion(const base::string16& suggested_value); | 163 void AcceptDataListSuggestion(const base::string16& suggested_value); |
157 | 164 |
158 // Queries the AutofillManager for form data for the form containing |node|. | 165 // Queries the AutofillManager for form data for the form containing |node|. |
159 // |value| is the current text in the field, and |unique_id| is the selected | 166 // |value| is the current text in the field, and |unique_id| is the selected |
160 // profile's unique ID. |action| specifies whether to Fill or Preview the | 167 // profile's unique ID. |action| specifies whether to Fill or Preview the |
161 // values returned from the AutofillManager. | 168 // values returned from the AutofillManager. |
(...skipping 17 matching lines...) Expand all Loading... | |
179 FormCache form_cache_; | 186 FormCache form_cache_; |
180 | 187 |
181 PasswordAutofillAgent* password_autofill_agent_; // Weak reference. | 188 PasswordAutofillAgent* password_autofill_agent_; // Weak reference. |
182 PasswordGenerationAgent* password_generation_agent_; // Weak reference. | 189 PasswordGenerationAgent* password_generation_agent_; // Weak reference. |
183 | 190 |
184 // The ID of the last request sent for form field Autofill. Used to ignore | 191 // The ID of the last request sent for form field Autofill. Used to ignore |
185 // out of date responses. | 192 // out of date responses. |
186 int autofill_query_id_; | 193 int autofill_query_id_; |
187 | 194 |
188 // The element corresponding to the last request sent for form field Autofill. | 195 // The element corresponding to the last request sent for form field Autofill. |
189 blink::WebInputElement element_; | 196 blink::WebFormControlElement element_; |
190 | 197 |
191 // The form element currently requesting an interactive autocomplete. | 198 // The form element currently requesting an interactive autocomplete. |
192 blink::WebFormElement in_flight_request_form_; | 199 blink::WebFormElement in_flight_request_form_; |
193 | 200 |
194 // All the form elements seen in the top frame. | 201 // All the form elements seen in the top frame. |
195 std::vector<blink::WebFormElement> form_elements_; | 202 std::vector<blink::WebFormElement> form_elements_; |
196 | 203 |
197 // The action to take when receiving Autofill data from the AutofillManager. | 204 // The action to take when receiving Autofill data from the AutofillManager. |
198 AutofillAction autofill_action_; | 205 AutofillAction autofill_action_; |
199 | 206 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 FRIEND_TEST_ALL_PREFIXES( | 245 FRIEND_TEST_ALL_PREFIXES( |
239 PasswordAutofillAgentTest, | 246 PasswordAutofillAgentTest, |
240 PasswordAutofillTriggersOnChangeEventsWaitForUsername); | 247 PasswordAutofillTriggersOnChangeEventsWaitForUsername); |
241 | 248 |
242 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); | 249 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); |
243 }; | 250 }; |
244 | 251 |
245 } // namespace autofill | 252 } // namespace autofill |
246 | 253 |
247 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ | 254 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ |
OLD | NEW |