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

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

Powered by Google App Engine
This is Rietveld 408576698