Chromium Code Reviews| 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 29 matching lines...) Expand all Loading... | |
| 40 bool TextDidChangeInTextField(const blink::WebInputElement& element); | 40 bool TextDidChangeInTextField(const blink::WebInputElement& element); |
| 41 | 41 |
| 42 // Function that should be called whenever the value of |element| changes due | 42 // Function that should be called whenever the value of |element| changes due |
| 43 // to user input. This is separate from TextDidChangeInTextField() as that | 43 // to user input. This is separate from TextDidChangeInTextField() as that |
| 44 // function may trigger UI and should only be called when other UI won't be | 44 // function may trigger UI and should only be called when other UI won't be |
| 45 // shown. | 45 // shown. |
| 46 void UpdateStateForTextChange(const blink::WebInputElement& element); | 46 void UpdateStateForTextChange(const blink::WebInputElement& element); |
| 47 | 47 |
| 48 // Fills the username and password fields of this form with the given values. | 48 // Fills the username and password fields of this form with the given values. |
| 49 // Returns true if the fields were filled, false otherwise. | 49 // Returns true if the fields were filled, false otherwise. |
| 50 bool FillSuggestion(const blink::WebNode& node, | 50 bool FillSuggestion(const blink::WebFormControlElement& node, |
| 51 const blink::WebString& username, | 51 const blink::WebString& username, |
| 52 const blink::WebString& password); | 52 const blink::WebString& password); |
| 53 | 53 |
| 54 // Previews the username and password fields of this form with the given | 54 // Previews the username and password fields of this form with the given |
| 55 // values. Returns true if the fields were previewed, false otherwise. | 55 // values. Returns true if the fields were previewed, false otherwise. |
| 56 bool PreviewSuggestion(const blink::WebNode& node, | 56 bool PreviewSuggestion(const blink::WebFormControlElement& node, |
| 57 const blink::WebString& username, | 57 const blink::WebString& username, |
| 58 const blink::WebString& password); | 58 const blink::WebString& password); |
| 59 | 59 |
| 60 // Clears the preview for the username and password fields, restoring both to | 60 // Clears the preview for the username and password fields, restoring both to |
| 61 // their previous filled state. Return false if no login information was | 61 // their previous filled state. Return false if no login information was |
| 62 // found for the form. | 62 // found for the form. |
| 63 bool DidClearAutofillSelection(const blink::WebNode& node); | 63 bool DidClearAutofillSelection( |
| 64 const blink::WebFormControlElement& control_element); | |
| 64 | 65 |
| 65 // Shows an Autofill popup with username suggestions for |element|. If | 66 // Shows an Autofill popup with username suggestions for |element|. If |
| 66 // |show_all| is |true|, will show all possible suggestions for that element, | 67 // |show_all| is |true|, will show all possible suggestions for that element, |
| 67 // otherwise shows suggestions based on current value of |element|. | 68 // otherwise shows suggestions based on current value of |element|. |
| 68 // If |generation_popup_showing| is true, this function will return false | 69 // If |generation_popup_showing| is true, this function will return false |
| 69 // as both UIs should not be shown at the same time. This function should | 70 // as both UIs should not be shown at the same time. This function should |
| 70 // still be called in this situation so that UMA stats can be logged. | 71 // still be called in this situation so that UMA stats can be logged. |
| 71 // Returns true if any suggestions were shown, false otherwise. | 72 // Returns true if any suggestions were shown, false otherwise. |
| 72 bool ShowSuggestions(const blink::WebInputElement& element, | 73 bool ShowSuggestions(const blink::WebInputElement& element, |
| 73 bool show_all, | 74 bool show_all, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 94 enum ProvisionallySaveRestriction { | 95 enum ProvisionallySaveRestriction { |
| 95 RESTRICTION_NONE, | 96 RESTRICTION_NONE, |
| 96 RESTRICTION_NON_EMPTY_PASSWORD | 97 RESTRICTION_NON_EMPTY_PASSWORD |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 struct PasswordInfo { | 100 struct PasswordInfo { |
| 100 blink::WebInputElement password_field; | 101 blink::WebInputElement password_field; |
| 101 PasswordFormFillData fill_data; | 102 PasswordFormFillData fill_data; |
| 102 // The user manually edited the password more recently than the username was | 103 // The user manually edited the password more recently than the username was |
| 103 // changed. | 104 // changed. |
| 104 bool password_was_edited_last; | 105 bool password_was_edited_last = false; |
| 105 // The user edited the username field after page loading. | 106 // The user edited the username field after page loading. |
| 106 bool username_was_edited; | 107 bool username_was_edited = false; |
| 108 // The user accepted a suggestion from a dropdown on a password field. | |
| 109 bool password_field_suggestion_was_accepted = false; | |
| 110 | |
| 111 int key; | |
|
vabr (Chromium)
2016/04/01 14:07:37
nit: Please explain what kind of key is this.
dvadym
2016/04/07 17:30:20
Done.
| |
| 107 PasswordInfo(); | 112 PasswordInfo(); |
| 108 }; | 113 }; |
| 109 typedef std::map<blink::WebInputElement, PasswordInfo> | 114 typedef std::map<blink::WebInputElement, PasswordInfo> |
| 110 WebInputToPasswordInfoMap; | 115 WebInputToPasswordInfoMap; |
| 111 typedef std::map<blink::WebElement, int> WebElementToPasswordInfoKeyMap; | 116 typedef std::map<blink::WebElement, int> WebElementToPasswordInfoKeyMap; |
| 112 typedef std::map<blink::WebInputElement, blink::WebInputElement> | 117 typedef std::map<blink::WebInputElement, blink::WebInputElement> |
| 113 PasswordToLoginMap; | 118 PasswordToLoginMap; |
| 114 | 119 |
| 115 // This class keeps track of autofilled password input elements and makes sure | 120 // This class keeps track of autofilled password input elements and makes sure |
| 116 // the autofilled password value is not accessible to JavaScript code until | 121 // the autofilled password value is not accessible to JavaScript code until |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 // Scans the given frame for password forms and sends them up to the browser. | 168 // Scans the given frame for password forms and sends them up to the browser. |
| 164 // If |only_visible| is true, only forms visible in the layout are sent. | 169 // If |only_visible| is true, only forms visible in the layout are sent. |
| 165 void SendPasswordForms(bool only_visible); | 170 void SendPasswordForms(bool only_visible); |
| 166 | 171 |
| 167 // Instructs the browser to show a pop-up suggesting which credentials could | 172 // Instructs the browser to show a pop-up suggesting which credentials could |
| 168 // be filled. |show_in_password_field| should indicate whether the pop-up is | 173 // be filled. |show_in_password_field| should indicate whether the pop-up is |
| 169 // to be shown on the password field instead of on the username field. If the | 174 // to be shown on the password field instead of on the username field. If the |
| 170 // username exists, it should be passed as |user_input|. If there is no | 175 // username exists, it should be passed as |user_input|. If there is no |
| 171 // username, pass the password field in |user_input|. In the latter case, no | 176 // username, pass the password field in |user_input|. In the latter case, no |
| 172 // username value will be shown in the pop-up. | 177 // username value will be shown in the pop-up. |
| 173 bool ShowSuggestionPopup(const PasswordFormFillData& fill_data, | 178 bool ShowSuggestionPopup(const PasswordInfo& password_info, |
| 174 const blink::WebInputElement& user_input, | 179 const blink::WebInputElement& user_input, |
| 175 bool show_all, | 180 bool show_all, |
| 176 bool show_on_password_field); | 181 bool show_on_password_field); |
| 177 | 182 |
| 178 // Finds the PasswordInfo that corresponds to the passed in element. The | 183 // Finds the PasswordInfo that corresponds to the passed in element. The |
| 179 // passed in element can be either a username element or a password element. | 184 // passed in element can be either a username element or a password element. |
| 180 // If a PasswordInfo was found, returns |true| and also assigns the | 185 // If a PasswordInfo was found, returns |true| and also assigns the |
| 181 // corresponding username WebInputElement and PasswordInfo into | 186 // corresponding username WebInputElement and PasswordInfo into |
|
vabr (Chromium)
2016/04/01 14:07:37
nit: Please update the comment to speak about |pas
dvadym
2016/04/07 17:30:20
I've updated. No it's not always equal to *passwor
| |
| 182 // username_element and pasword_info, respectively. Note, that | 187 // username_element and pasword_info, respectively. Note, that |
| 183 // |username_element->isNull()| can be true for forms without a username | 188 // |username_element->isNull()| can be true for forms without a username |
| 184 // field. | 189 // field. |
| 185 bool FindPasswordInfoForElement( | 190 bool FindPasswordInfoForElement(const blink::WebInputElement& element, |
| 186 const blink::WebInputElement& element, | 191 blink::WebInputElement* username_element, |
| 187 const blink::WebInputElement** username_element, | 192 blink::WebInputElement* password_element, |
| 188 PasswordInfo** password_info); | 193 PasswordInfo** password_info); |
| 189 | 194 |
| 190 // Invoked when the frame is closing. | 195 // Invoked when the frame is closing. |
| 191 void FrameClosing(); | 196 void FrameClosing(); |
| 192 | 197 |
| 193 // Finds login information for a |node| that was previously filled. | |
| 194 bool FindLoginInfo(const blink::WebNode& node, | |
| 195 blink::WebInputElement* found_input, | |
| 196 PasswordInfo** found_password); | |
| 197 | |
| 198 // Clears the preview for the username and password fields, restoring both to | 198 // Clears the preview for the username and password fields, restoring both to |
| 199 // their previous filled state. | 199 // their previous filled state. |
| 200 void ClearPreview(blink::WebInputElement* username, | 200 void ClearPreview(blink::WebInputElement* username, |
| 201 blink::WebInputElement* password); | 201 blink::WebInputElement* password); |
| 202 | 202 |
| 203 // Saves |password_form| in |provisionally_saved_form_|, as long as it | 203 // Saves |password_form| in |provisionally_saved_form_|, as long as it |
| 204 // satisfies |restriction|. | 204 // satisfies |restriction|. |
| 205 void ProvisionallySavePassword(scoped_ptr<PasswordForm> password_form, | 205 void ProvisionallySavePassword(scoped_ptr<PasswordForm> password_form, |
| 206 ProvisionallySaveRestriction restriction); | 206 ProvisionallySaveRestriction restriction); |
| 207 | 207 |
| 208 // Returns true if |provisionally_saved_form_| has enough information that | 208 // Returns true if |provisionally_saved_form_| has enough information that |
| 209 // it is likely filled out. | 209 // it is likely filled out. |
| 210 bool ProvisionallySavedPasswordIsValid(); | 210 bool ProvisionallySavedPasswordIsValid(); |
| 211 | 211 |
| 212 // Helper function called when in-page navigation completed | 212 // Helper function called when in-page navigation completed |
| 213 void OnSamePageNavigationCompleted(); | 213 void OnSamePageNavigationCompleted(); |
| 214 | 214 |
| 215 // The logins we have filled so far with their associated info. | 215 // The logins we have filled so far with their associated info. |
| 216 WebInputToPasswordInfoMap web_input_to_password_info_; | 216 WebInputToPasswordInfoMap web_input_to_password_info_; |
| 217 // And the keys under which PasswordAutofillManager can find the same info. | |
| 218 WebElementToPasswordInfoKeyMap web_element_to_password_info_key_; | |
| 219 // A (sort-of) reverse map to |login_to_password_info_|. | 217 // A (sort-of) reverse map to |login_to_password_info_|. |
| 220 PasswordToLoginMap password_to_username_; | 218 PasswordToLoginMap password_to_username_; |
| 221 | 219 |
| 222 // Set if the user might be submitting a password form on the current page, | 220 // Set if the user might be submitting a password form on the current page, |
| 223 // but the submit may still fail (i.e. doesn't pass JavaScript validation). | 221 // but the submit may still fail (i.e. doesn't pass JavaScript validation). |
| 224 scoped_ptr<PasswordForm> provisionally_saved_form_; | 222 scoped_ptr<PasswordForm> provisionally_saved_form_; |
| 225 | 223 |
| 226 // Contains the most recent text that user typed or PasswordManager autofilled | 224 // Contains the most recent text that user typed or PasswordManager autofilled |
| 227 // in input elements. Used for storing username/password before JavaScript | 225 // in input elements. Used for storing username/password before JavaScript |
| 228 // changes them. | 226 // changes them. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 246 FormsPredictionsMap form_predictions_; | 244 FormsPredictionsMap form_predictions_; |
| 247 | 245 |
| 248 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_; | 246 base::WeakPtrFactory<PasswordAutofillAgent> weak_ptr_factory_; |
| 249 | 247 |
| 250 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); | 248 DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); |
| 251 }; | 249 }; |
| 252 | 250 |
| 253 } // namespace autofill | 251 } // namespace autofill |
| 254 | 252 |
| 255 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ | 253 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_AUTOFILL_AGENT_H_ |
| OLD | NEW |