| 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 // The user manually edited the password more recently than the username was |
| 98 // changed. |
| 99 bool password_was_edited_last; |
| 100 PasswordInfo(); |
| 98 }; | 101 }; |
| 99 typedef std::map<blink::WebElement, PasswordInfo> LoginToPasswordInfoMap; | 102 typedef std::map<blink::WebElement, PasswordInfo> LoginToPasswordInfoMap; |
| 103 typedef std::map<blink::WebElement, blink::WebElement> PasswordToLoginMap; |
| 100 typedef std::map<blink::WebFrame*, | 104 typedef std::map<blink::WebFrame*, |
| 101 linked_ptr<PasswordForm> > FrameToPasswordFormMap; | 105 linked_ptr<PasswordForm> > FrameToPasswordFormMap; |
| 102 | 106 |
| 103 // This class holds a vector of autofilled password input elements and makes | 107 // This class keeps track of autofilled password input elements and makes sure |
| 104 // sure the autofilled password value is not accessible to JavaScript code | 108 // the autofilled password value is not accessible to JavaScript code until |
| 105 // until the user interacts with the page. | 109 // the user interacts with the page. |
| 106 class PasswordValueGatekeeper { | 110 class PasswordValueGatekeeper { |
| 107 public: | 111 public: |
| 108 PasswordValueGatekeeper(); | 112 PasswordValueGatekeeper(); |
| 109 ~PasswordValueGatekeeper(); | 113 ~PasswordValueGatekeeper(); |
| 110 | 114 |
| 111 // Call this for every autofilled password field, so that the gatekeeper | 115 // Call this for every autofilled password field, so that the gatekeeper |
| 112 // protects the value accordingly. | 116 // protects the value accordingly. |
| 113 void RegisterElement(blink::WebInputElement* element); | 117 void RegisterElement(blink::WebInputElement* element); |
| 114 | 118 |
| 115 // Call this to notify the gatekeeper that the user interacted with the | 119 // 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, | 187 const blink::WebInputElement& password, |
| 184 const PasswordFormFillData& fill_data); | 188 const PasswordFormFillData& fill_data); |
| 185 | 189 |
| 186 // Invoked when the passed frame is closing. Gives us a chance to clear any | 190 // Invoked when the passed frame is closing. Gives us a chance to clear any |
| 187 // reference we may have to elements in that frame. | 191 // reference we may have to elements in that frame. |
| 188 void FrameClosing(const blink::WebFrame* frame); | 192 void FrameClosing(const blink::WebFrame* frame); |
| 189 | 193 |
| 190 // Finds login information for a |node| that was previously filled. | 194 // Finds login information for a |node| that was previously filled. |
| 191 bool FindLoginInfo(const blink::WebNode& node, | 195 bool FindLoginInfo(const blink::WebNode& node, |
| 192 blink::WebInputElement* found_input, | 196 blink::WebInputElement* found_input, |
| 193 PasswordInfo* found_password); | 197 PasswordInfo** found_password); |
| 194 | 198 |
| 195 // Clears the preview for the username and password fields, restoring both to | 199 // Clears the preview for the username and password fields, restoring both to |
| 196 // their previous filled state. | 200 // their previous filled state. |
| 197 void ClearPreview(blink::WebInputElement* username, | 201 void ClearPreview(blink::WebInputElement* username, |
| 198 blink::WebInputElement* password); | 202 blink::WebInputElement* password); |
| 199 | 203 |
| 200 // If |provisionally_saved_forms_| contains a form for |current_frame| or its | 204 // If |provisionally_saved_forms_| contains a form for |current_frame| or its |
| 201 // children, return such frame. | 205 // children, return such frame. |
| 202 blink::WebFrame* CurrentOrChildFrameWithSavedForms( | 206 blink::WebFrame* CurrentOrChildFrameWithSavedForms( |
| 203 const blink::WebFrame* current_frame); | 207 const blink::WebFrame* current_frame); |
| 204 | 208 |
| 205 // Extracts a PasswordForm from |form| and saves it as | 209 // Extracts a PasswordForm from |form| and saves it as |
| 206 // |provisionally_saved_forms_[frame]|, as long as it satisfies |restriction|. | 210 // |provisionally_saved_forms_[frame]|, as long as it satisfies |restriction|. |
| 207 void ProvisionallySavePassword(blink::WebLocalFrame* frame, | 211 void ProvisionallySavePassword(blink::WebLocalFrame* frame, |
| 208 const blink::WebFormElement& form, | 212 const blink::WebFormElement& form, |
| 209 ProvisionallySaveRestriction restriction); | 213 ProvisionallySaveRestriction restriction); |
| 210 | 214 |
| 211 // The logins we have filled so far with their associated info. | 215 // The logins we have filled so far with their associated info. |
| 212 LoginToPasswordInfoMap login_to_password_info_; | 216 LoginToPasswordInfoMap login_to_password_info_; |
| 217 // A (sort-of) reverse map to |login_to_password_info_|. |
| 218 PasswordToLoginMap password_to_username_; |
| 213 | 219 |
| 214 // Used for UMA stats. | 220 // Used for UMA stats. |
| 215 OtherPossibleUsernamesUsage usernames_usage_; | 221 OtherPossibleUsernamesUsage usernames_usage_; |
| 216 | 222 |
| 217 // Pointer to the WebView. Used to access page scale factor. | 223 // Pointer to the WebView. Used to access page scale factor. |
| 218 blink::WebView* web_view_; | 224 blink::WebView* web_view_; |
| 219 | 225 |
| 220 // Set if the user might be submitting a password form on the current page, | 226 // 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). | 227 // but the submit may still fail (i.e. doesn't pass JavaScript validation). |
| 222 FrameToPasswordFormMap provisionally_saved_forms_; | 228 FrameToPasswordFormMap provisionally_saved_forms_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 239 bool did_stop_loading_; | 245 bool did_stop_loading_; |
| 240 | 246 |
| 241 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_; | 247 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_; |
| 242 | 248 |
| 243 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); | 249 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); |
| 244 }; | 250 }; |
| 245 | 251 |
| 246 } // namespace autofill | 252 } // namespace autofill |
| 247 | 253 |
| 248 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ | 254 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ |
| OLD | NEW |