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

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

Issue 208453002: Add "previewing on hover" support for password field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update code as per further review comments. Created 6 years, 7 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_PASSWORD_AUTOFILL_AGENT_H_ 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_
6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 22 matching lines...) Expand all
33 // WebViewClient editor related calls forwarded by the RenderView. 33 // WebViewClient editor related calls forwarded by the RenderView.
34 // If they return true, it indicates the event was consumed and should not 34 // If they return true, it indicates the event was consumed and should not
35 // be used for any other autofill activity. 35 // be used for any other autofill activity.
36 bool TextFieldDidEndEditing(const blink::WebInputElement& element); 36 bool TextFieldDidEndEditing(const blink::WebInputElement& element);
37 bool TextDidChangeInTextField(const blink::WebInputElement& element); 37 bool TextDidChangeInTextField(const blink::WebInputElement& element);
38 bool TextFieldHandlingKeyDown(const blink::WebInputElement& element, 38 bool TextFieldHandlingKeyDown(const blink::WebInputElement& element,
39 const blink::WebKeyboardEvent& event); 39 const blink::WebKeyboardEvent& event);
40 40
41 // Fills the username and password fields of this form with the given values. 41 // Fills the username and password fields of this form with the given values.
42 // Returns true if the fields were filled, false otherwise. 42 // Returns true if the fields were filled, false otherwise.
43 bool AcceptSuggestion(const blink::WebNode& node, 43 bool FillSuggestion(const blink::WebNode& node,
44 const blink::WebString& username, 44 const blink::WebString& username,
45 const blink::WebString& password); 45 const blink::WebString& password);
46 46
47 // A no-op. Password forms are not previewed, so they do not need to be 47 // Previews the username and password fields of this form with the given
48 // cleared when the selection changes. However, this method returns 48 // values. Returns true if the fields were previewed, false otherwise.
49 // true when |node| is fillable by password Autofill. 49 bool PreviewSuggestion(const blink::WebNode& node,
50 const blink::WebString& username,
51 const blink::WebString& password);
52
53 // Clears the preview for the username and password fields, restoring both to
54 // their previous filled state. Return false if no login information was
55 // found for the form.
50 bool DidClearAutofillSelection(const blink::WebNode& node); 56 bool DidClearAutofillSelection(const blink::WebNode& node);
51 // Shows an Autofill popup with username suggestions for |element|. 57 // Shows an Autofill popup with username suggestions for |element|.
52 // Returns true if any suggestions were shown, false otherwise. 58 // Returns true if any suggestions were shown, false otherwise.
53 bool ShowSuggestions(const blink::WebInputElement& element); 59 bool ShowSuggestions(const blink::WebInputElement& element);
54 60
55 // Called when new form controls are inserted. 61 // Called when new form controls are inserted.
56 void OnDynamicFormsSeen(blink::WebFrame* frame); 62 void OnDynamicFormsSeen(blink::WebFrame* frame);
57 63
58 // Called when the user first interacts with the page after a load. This is a 64 // Called when the user first interacts with the page after a load. This is a
59 // signal to make autofilled values of password input elements accessible to 65 // signal to make autofilled values of password input elements accessible to
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 152
147 // Attempts to fill |username_element| and |password_element| with the 153 // Attempts to fill |username_element| and |password_element| with the
148 // |fill_data|. Will use the data corresponding to the preferred username, 154 // |fill_data|. Will use the data corresponding to the preferred username,
149 // unless the |username_element| already has a value set. In that case, 155 // unless the |username_element| already has a value set. In that case,
150 // attempts to fill the password matching the already filled username, if 156 // attempts to fill the password matching the already filled username, if
151 // such a password exists. 157 // such a password exists.
152 void FillFormOnPasswordRecieved(const PasswordFormFillData& fill_data, 158 void FillFormOnPasswordRecieved(const PasswordFormFillData& fill_data,
153 blink::WebInputElement username_element, 159 blink::WebInputElement username_element,
154 blink::WebInputElement password_element); 160 blink::WebInputElement password_element);
155 161
156 bool FillUserNameAndPassword( 162 bool FillUserNameAndPassword(blink::WebInputElement* username_element,
157 blink::WebInputElement* username_element, 163 blink::WebInputElement* password_element,
158 blink::WebInputElement* password_element, 164 const PasswordFormFillData& fill_data,
159 const PasswordFormFillData& fill_data, 165 bool exact_username_match,
160 bool exact_username_match, 166 bool set_selection);
161 bool set_selection);
162 167
163 // Fills |login_input| and |password| with the most relevant suggestion from 168 // Fills |login_input| and |password| with the most relevant suggestion from
164 // |fill_data| and shows a popup with other suggestions. 169 // |fill_data| and shows a popup with other suggestions.
165 void PerformInlineAutocomplete( 170 void PerformInlineAutocomplete(
166 const blink::WebInputElement& username, 171 const blink::WebInputElement& username,
167 const blink::WebInputElement& password, 172 const blink::WebInputElement& password,
168 const PasswordFormFillData& fill_data); 173 const PasswordFormFillData& fill_data);
169 174
170 // Invoked when the passed frame is closing. Gives us a chance to clear any 175 // Invoked when the passed frame is closing. Gives us a chance to clear any
171 // reference we may have to elements in that frame. 176 // reference we may have to elements in that frame.
172 void FrameClosing(const blink::WebFrame* frame); 177 void FrameClosing(const blink::WebFrame* frame);
173 178
174 // Finds login information for a |node| that was previously filled. 179 // Finds login information for a |node| that was previously filled.
175 bool FindLoginInfo(const blink::WebNode& node, 180 bool FindLoginInfo(const blink::WebNode& node,
176 blink::WebInputElement* found_input, 181 blink::WebInputElement* found_input,
177 PasswordInfo* found_password); 182 PasswordInfo* found_password);
178 183
184 // Clears the preview for the username and password fields, restoring both to
185 // their previous filled state.
186 void ClearPreview(blink::WebInputElement* username,
187 blink::WebInputElement* password);
188
179 // If |provisionally_saved_forms_| contains a form for |current_frame| or its 189 // If |provisionally_saved_forms_| contains a form for |current_frame| or its
180 // children, return such frame. 190 // children, return such frame.
181 blink::WebFrame* CurrentOrChildFrameWithSavedForms( 191 blink::WebFrame* CurrentOrChildFrameWithSavedForms(
182 const blink::WebFrame* current_frame); 192 const blink::WebFrame* current_frame);
183 193
184 // The logins we have filled so far with their associated info. 194 // The logins we have filled so far with their associated info.
185 LoginToPasswordInfoMap login_to_password_info_; 195 LoginToPasswordInfoMap login_to_password_info_;
186 196
187 // Used for UMA stats. 197 // Used for UMA stats.
188 OtherPossibleUsernamesUsage usernames_usage_; 198 OtherPossibleUsernamesUsage usernames_usage_;
189 199
190 // Pointer to the WebView. Used to access page scale factor. 200 // Pointer to the WebView. Used to access page scale factor.
191 blink::WebView* web_view_; 201 blink::WebView* web_view_;
192 202
193 // Set if the user might be submitting a password form on the current page, 203 // Set if the user might be submitting a password form on the current page,
194 // but the submit may still fail (i.e. doesn't pass JavaScript validation). 204 // but the submit may still fail (i.e. doesn't pass JavaScript validation).
195 FrameToPasswordFormMap provisionally_saved_forms_; 205 FrameToPasswordFormMap provisionally_saved_forms_;
196 206
197 PasswordValueGatekeeper gatekeeper_; 207 PasswordValueGatekeeper gatekeeper_;
198 208
199 // True indicates that user debug information should be logged. 209 // True indicates that user debug information should be logged.
200 bool logging_state_active_; 210 bool logging_state_active_;
201 211
212 // True indicates that the username field was autofilled, false otherwise.
213 bool was_username_autofilled_;
214 // True indicates that the password field was autofilled, false otherwise.
215 bool was_password_autofilled_;
216
217 // Records original starting point of username element's selection range
218 // before preview.
219 int username_selection_start_;
220
202 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_; 221 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_;
203 222
204 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); 223 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent);
205 }; 224 };
206 225
207 } // namespace autofill 226 } // namespace autofill
208 227
209 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ 228 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698