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_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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 // Ways to restrict which passwords are saved in ProvisionallySavePassword. | 87 // Ways to restrict which passwords are saved in ProvisionallySavePassword. |
88 enum ProvisionallySaveRestriction { | 88 enum ProvisionallySaveRestriction { |
89 RESTRICTION_NONE, | 89 RESTRICTION_NONE, |
90 RESTRICTION_NON_EMPTY_PASSWORD | 90 RESTRICTION_NON_EMPTY_PASSWORD |
91 }; | 91 }; |
92 | 92 |
93 struct PasswordInfo { | 93 struct PasswordInfo { |
94 blink::WebInputElement password_field; | 94 blink::WebInputElement password_field; |
95 PasswordFormFillData fill_data; | 95 PasswordFormFillData fill_data; |
96 bool backspace_pressed_last; | 96 bool backspace_pressed_last; |
97 PasswordInfo() : backspace_pressed_last(false) {} | 97 // "Wait for username change" before overwriting the password value -- if |
98 // set to true, this flag means that after selecting a username for password | |
99 // autofill, the user overwrote the autofileld password. The agent should | |
100 // not restore it back to the autofilled password, so it holds on with | |
101 // changing the password value until the flag is reset. The flag is reset | |
102 // when the user chooses another username for autofill. | |
103 bool wait_for_username_change; | |
engedy
2014/08/06 10:18:17
To be consistent with |backspace_pressed_last|, I
vabr (Chromium)
2014/08/25 14:53:29
Done.
| |
104 PasswordInfo(); | |
98 }; | 105 }; |
99 typedef std::map<blink::WebElement, PasswordInfo> LoginToPasswordInfoMap; | 106 typedef std::map<blink::WebElement, PasswordInfo> LoginToPasswordInfoMap; |
107 typedef std::map<blink::WebElement, blink::WebElement> PasswordToLoginMap; | |
100 typedef std::map<blink::WebFrame*, | 108 typedef std::map<blink::WebFrame*, |
101 linked_ptr<PasswordForm> > FrameToPasswordFormMap; | 109 linked_ptr<PasswordForm> > FrameToPasswordFormMap; |
102 | 110 |
103 // This class holds a vector of autofilled password input elements and makes | 111 // This class keeps track of autofilled password input elements and makes sure |
104 // sure the autofilled password value is not accessible to JavaScript code | 112 // the autofilled password value is not accessible to JavaScript code until |
105 // until the user interacts with the page. | 113 // the user interacts with the page. |
106 class PasswordValueGatekeeper { | 114 class PasswordValueGatekeeper { |
107 public: | 115 public: |
108 PasswordValueGatekeeper(); | 116 PasswordValueGatekeeper(); |
109 ~PasswordValueGatekeeper(); | 117 ~PasswordValueGatekeeper(); |
110 | 118 |
111 // Call this for every autofilled password field, so that the gatekeeper | 119 // Call this for every autofilled password field, so that the gatekeeper |
112 // protects the value accordingly. | 120 // protects the value accordingly. |
113 void RegisterElement(blink::WebInputElement* element); | 121 void RegisterElement(blink::WebInputElement* element); |
114 | 122 |
115 // Call this to notify the gatekeeper that the user interacted with the | 123 // Call this to notify the gatekeeper that the user interacted with the |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 const blink::WebInputElement& password, | 191 const blink::WebInputElement& password, |
184 const PasswordFormFillData& fill_data); | 192 const PasswordFormFillData& fill_data); |
185 | 193 |
186 // Invoked when the passed frame is closing. Gives us a chance to clear any | 194 // Invoked when the passed frame is closing. Gives us a chance to clear any |
187 // reference we may have to elements in that frame. | 195 // reference we may have to elements in that frame. |
188 void FrameClosing(const blink::WebFrame* frame); | 196 void FrameClosing(const blink::WebFrame* frame); |
189 | 197 |
190 // Finds login information for a |node| that was previously filled. | 198 // Finds login information for a |node| that was previously filled. |
191 bool FindLoginInfo(const blink::WebNode& node, | 199 bool FindLoginInfo(const blink::WebNode& node, |
192 blink::WebInputElement* found_input, | 200 blink::WebInputElement* found_input, |
193 PasswordInfo* found_password); | 201 PasswordInfo** found_password); |
194 | 202 |
195 // Clears the preview for the username and password fields, restoring both to | 203 // Clears the preview for the username and password fields, restoring both to |
196 // their previous filled state. | 204 // their previous filled state. |
197 void ClearPreview(blink::WebInputElement* username, | 205 void ClearPreview(blink::WebInputElement* username, |
198 blink::WebInputElement* password); | 206 blink::WebInputElement* password); |
199 | 207 |
200 // If |provisionally_saved_forms_| contains a form for |current_frame| or its | 208 // If |provisionally_saved_forms_| contains a form for |current_frame| or its |
201 // children, return such frame. | 209 // children, return such frame. |
202 blink::WebFrame* CurrentOrChildFrameWithSavedForms( | 210 blink::WebFrame* CurrentOrChildFrameWithSavedForms( |
203 const blink::WebFrame* current_frame); | 211 const blink::WebFrame* current_frame); |
204 | 212 |
205 // Extracts a PasswordForm from |form| and saves it as | 213 // Extracts a PasswordForm from |form| and saves it as |
206 // |provisionally_saved_forms_[frame]|, as long as it satisfies |restriction|. | 214 // |provisionally_saved_forms_[frame]|, as long as it satisfies |restriction|. |
207 void ProvisionallySavePassword(blink::WebLocalFrame* frame, | 215 void ProvisionallySavePassword(blink::WebLocalFrame* frame, |
208 const blink::WebFormElement& form, | 216 const blink::WebFormElement& form, |
209 ProvisionallySaveRestriction restriction); | 217 ProvisionallySaveRestriction restriction); |
210 | 218 |
211 // The logins we have filled so far with their associated info. | 219 // The logins we have filled so far with their associated info. |
212 LoginToPasswordInfoMap login_to_password_info_; | 220 LoginToPasswordInfoMap login_to_password_info_; |
221 // Maps password elements to the corresponding username elements, good for | |
engedy
2014/08/06 10:18:17
nit: I would personally also consider shortening o
vabr (Chromium)
2014/08/25 14:53:29
Done.
| |
222 // looking up PasswordInfo associated with a password element in | |
223 // |login_to_password_info_|. | |
224 PasswordToLoginMap password_to_username_; | |
213 | 225 |
214 // Used for UMA stats. | 226 // Used for UMA stats. |
215 OtherPossibleUsernamesUsage usernames_usage_; | 227 OtherPossibleUsernamesUsage usernames_usage_; |
216 | 228 |
217 // Pointer to the WebView. Used to access page scale factor. | 229 // Pointer to the WebView. Used to access page scale factor. |
218 blink::WebView* web_view_; | 230 blink::WebView* web_view_; |
219 | 231 |
220 // Set if the user might be submitting a password form on the current page, | 232 // Set if the user might be submitting a password form on the current page, |
221 // but the submit may still fail (i.e. doesn't pass JavaScript validation). | 233 // but the submit may still fail (i.e. doesn't pass JavaScript validation). |
222 FrameToPasswordFormMap provisionally_saved_forms_; | 234 FrameToPasswordFormMap provisionally_saved_forms_; |
(...skipping 16 matching lines...) Expand all Loading... | |
239 bool did_stop_loading_; | 251 bool did_stop_loading_; |
240 | 252 |
241 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_; | 253 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_; |
242 | 254 |
243 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); | 255 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); |
244 }; | 256 }; |
245 | 257 |
246 } // namespace autofill | 258 } // namespace autofill |
247 | 259 |
248 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ | 260 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ |
OLD | NEW |