Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(710)

Side by Side Diff: components/autofill/content/renderer/autofill_agent.h

Issue 140093005: Add supports that allow Autofill to be initiated from textarea field (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update codes as per Ilya's 2nd set comments Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
Ilya Sherman 2014/02/26 00:12:07 nit: Doesn't look like this is needed.
ziran.sun 2014/02/26 18:11:50 Done.
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
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) OVERRIDE;
81 virtual void InputElementLostFocus() OVERRIDE; 83 virtual void FormControlElementLostFocus() OVERRIDE;
82 84
83 // blink::WebAutofillClient: 85 // blink::WebAutofillClient:
84 virtual void textFieldDidEndEditing( 86 virtual void textFieldDidEndEditing(
85 const blink::WebInputElement& element) OVERRIDE; 87 const blink::WebInputElement& element) OVERRIDE;
88 // TODO(ziran.sun): To be removed once next Blink roll is done
86 virtual void textFieldDidChange( 89 virtual void textFieldDidChange(
87 const blink::WebInputElement& element) OVERRIDE; 90 const blink::WebInputElement& element);
91 // TODO(ziran.sun): OVERRIDE this function once next Blink roll is done
92 virtual void textFieldDidChange(
93 const blink::WebFormControlElement& element);
88 virtual void textFieldDidReceiveKeyDown( 94 virtual void textFieldDidReceiveKeyDown(
89 const blink::WebInputElement& element, 95 const blink::WebInputElement& element,
90 const blink::WebKeyboardEvent& event) OVERRIDE; 96 const blink::WebKeyboardEvent& event) OVERRIDE;
91 virtual void didRequestAutocomplete( 97 virtual void didRequestAutocomplete(
92 blink::WebFrame* frame, 98 blink::WebFrame* frame,
93 const blink::WebFormElement& form) OVERRIDE; 99 const blink::WebFormElement& form) OVERRIDE;
94 virtual void setIgnoreTextChanges(bool ignore) OVERRIDE; 100 virtual void setIgnoreTextChanges(bool ignore) OVERRIDE;
95 virtual void didAssociateFormControls( 101 virtual void didAssociateFormControls(
96 const blink::WebVector<blink::WebNode>& nodes) OVERRIDE; 102 const blink::WebVector<blink::WebNode>& nodes) OVERRIDE;
97 virtual void openTextDataListChooser(const blink::WebInputElement& element); 103 virtual void openTextDataListChooser(const blink::WebInputElement& element);
(...skipping 19 matching lines...) Expand all
117 // Called when an autocomplete request succeeds or fails with the |result|. 123 // Called when an autocomplete request succeeds or fails with the |result|.
118 void FinishAutocompleteRequest( 124 void FinishAutocompleteRequest(
119 blink::WebFormElement::AutocompleteResult result); 125 blink::WebFormElement::AutocompleteResult result);
120 126
121 // Called when the page is actually shown in the browser, as opposed to simply 127 // Called when the page is actually shown in the browser, as opposed to simply
122 // being preloaded. 128 // being preloaded.
123 void OnPageShown(); 129 void OnPageShown();
124 130
125 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug 131 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug
126 // http://bugs.webkit.org/show_bug.cgi?id=16976 132 // http://bugs.webkit.org/show_bug.cgi?id=16976
127 void TextFieldDidChangeImpl(const blink::WebInputElement& element); 133 void TextFieldDidChangeImpl(const blink::WebFormControlElement& element);
128 134
129 // Shows the autofill suggestions for |element|. 135 // Shows the autofill suggestions for |element|.
130 // This call is asynchronous and may or may not lead to the showing of a 136 // 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). 137 // suggestion popup (no popup is shown if there are no available suggestions).
132 // |autofill_on_empty_values| specifies whether suggestions should be shown 138 // |autofill_on_empty_values| specifies whether suggestions should be shown
133 // when |element| contains no text. 139 // when |element| contains no text.
134 // |requires_caret_at_end| specifies whether suggestions should be shown when 140 // |requires_caret_at_end| specifies whether suggestions should be shown when
135 // the caret is not after the last character in |element|. 141 // the caret is not after the last character in |element|.
136 // |display_warning_if_disabled| specifies whether a warning should be 142 // |display_warning_if_disabled| specifies whether a warning should be
137 // displayed to the user if Autofill has suggestions available, but cannot 143 // 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 144 // fill them because it is disabled (e.g. when trying to fill a credit card
139 // form on a non-secure website). 145 // form on a non-secure website).
140 // |datalist_only| specifies whether all of <datalist> suggestions and no 146 // |datalist_only| specifies whether all of <datalist> suggestions and no
141 // autofill suggestions are shown. |autofill_on_empty_values| and 147 // autofill suggestions are shown. |autofill_on_empty_values| and
142 // |requires_caret_at_end| are ignored if |datalist_only| is true. 148 // |requires_caret_at_end| are ignored if |datalist_only| is true.
143 void ShowSuggestions(const blink::WebInputElement& element, 149 void ShowSuggestions(const blink::WebFormControlElement& element,
144 bool autofill_on_empty_values, 150 bool autofill_on_empty_values,
145 bool requires_caret_at_end, 151 bool requires_caret_at_end,
146 bool display_warning_if_disabled, 152 bool display_warning_if_disabled,
147 bool datalist_only); 153 bool datalist_only);
148 154
149 // Queries the browser for Autocomplete and Autofill suggestions for the given 155 // Queries the browser for Autocomplete and Autofill suggestions for the given
150 // |element|. 156 // |element|.
151 void QueryAutofillSuggestions(const blink::WebInputElement& element, 157 void QueryAutofillSuggestions(const blink::WebFormControlElement& element,
152 bool display_warning_if_disabled, 158 bool display_warning_if_disabled,
153 bool datalist_only); 159 bool datalist_only);
154 160
155 // Sets the element value to reflect the selected |suggested_value|. 161 // Sets the element value to reflect the selected |suggested_value|.
156 void AcceptDataListSuggestion(const base::string16& suggested_value); 162 void AcceptDataListSuggestion(const base::string16& suggested_value);
157 163
158 // Queries the AutofillManager for form data for the form containing |node|. 164 // 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 165 // |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 166 // profile's unique ID. |action| specifies whether to Fill or Preview the
161 // values returned from the AutofillManager. 167 // values returned from the AutofillManager.
(...skipping 17 matching lines...) Expand all
179 FormCache form_cache_; 185 FormCache form_cache_;
180 186
181 PasswordAutofillAgent* password_autofill_agent_; // Weak reference. 187 PasswordAutofillAgent* password_autofill_agent_; // Weak reference.
182 PasswordGenerationAgent* password_generation_agent_; // Weak reference. 188 PasswordGenerationAgent* password_generation_agent_; // Weak reference.
183 189
184 // The ID of the last request sent for form field Autofill. Used to ignore 190 // The ID of the last request sent for form field Autofill. Used to ignore
185 // out of date responses. 191 // out of date responses.
186 int autofill_query_id_; 192 int autofill_query_id_;
187 193
188 // The element corresponding to the last request sent for form field Autofill. 194 // The element corresponding to the last request sent for form field Autofill.
189 blink::WebInputElement element_; 195 blink::WebFormControlElement element_;
190 196
191 // The form element currently requesting an interactive autocomplete. 197 // The form element currently requesting an interactive autocomplete.
192 blink::WebFormElement in_flight_request_form_; 198 blink::WebFormElement in_flight_request_form_;
193 199
194 // All the form elements seen in the top frame. 200 // All the form elements seen in the top frame.
195 std::vector<blink::WebFormElement> form_elements_; 201 std::vector<blink::WebFormElement> form_elements_;
196 202
197 // The action to take when receiving Autofill data from the AutofillManager. 203 // The action to take when receiving Autofill data from the AutofillManager.
198 AutofillAction autofill_action_; 204 AutofillAction autofill_action_;
199 205
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 FRIEND_TEST_ALL_PREFIXES( 244 FRIEND_TEST_ALL_PREFIXES(
239 PasswordAutofillAgentTest, 245 PasswordAutofillAgentTest,
240 PasswordAutofillTriggersOnChangeEventsWaitForUsername); 246 PasswordAutofillTriggersOnChangeEventsWaitForUsername);
241 247
242 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); 248 DISALLOW_COPY_AND_ASSIGN(AutofillAgent);
243 }; 249 };
244 250
245 } // namespace autofill 251 } // namespace autofill
246 252
247 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ 253 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698