diff options
Diffstat (limited to 'chromium/components/autofill/content/renderer/password_autofill_agent.h')
-rw-r--r-- | chromium/components/autofill/content/renderer/password_autofill_agent.h | 94 |
1 files changed, 62 insertions, 32 deletions
diff --git a/chromium/components/autofill/content/renderer/password_autofill_agent.h b/chromium/components/autofill/content/renderer/password_autofill_agent.h index 228907d12ce..a284a03bb42 100644 --- a/chromium/components/autofill/content/renderer/password_autofill_agent.h +++ b/chromium/components/autofill/content/renderer/password_autofill_agent.h @@ -81,17 +81,19 @@ class PasswordAutofillAgent : public content::RenderFrameObserver, void SetPasswordGenerationAgent(PasswordGenerationAgent* generation_agent); - const mojom::PasswordManagerDriverPtr& GetPasswordManagerDriver(); + const mojom::PasswordManagerDriverAssociatedPtr& GetPasswordManagerDriver(); // mojom::PasswordAutofillAgent: void FillPasswordForm(int key, const PasswordFormFillData& form_data) override; + void FillIntoFocusedField(bool is_password, + const base::string16& credential, + FillIntoFocusedFieldCallback callback) override; void SetLoggingState(bool active) override; void AutofillUsernameAndPasswordDataReceived( const FormsPredictionsMap& predictions) override; void FindFocusedPasswordForm( FindFocusedPasswordFormCallback callback) override; - void BlacklistedFormFound() override; // FormTracker::Observer void OnProvisionallySaveForm(const blink::WebFormElement& form, @@ -101,7 +103,7 @@ class PasswordAutofillAgent : public content::RenderFrameObserver, void OnFormSubmitted(const blink::WebFormElement& form) override; void OnInferredFormSubmission(SubmissionSource source) override; - // WebFrameClient editor related calls forwarded by AutofillAgent. + // WebLocalFrameClient editor related calls forwarded by AutofillAgent. // If they return true, it indicates the event was consumed and should not // be used for any other autofill activity. bool TextDidChangeInTextField(const blink::WebInputElement& element); @@ -149,11 +151,6 @@ class PasswordAutofillAgent : public content::RenderFrameObserver, // on a non-secure page. void ShowNotSecureWarning(const blink::WebInputElement& element); - // Shows an Autofill-style popup with an option to go to settings and check - // all saved passwords. Returns true if the suggestion was shown, false - // otherwise. - bool ShowManualFallbackSuggestion(const blink::WebInputElement& element); - // Called when new form controls are inserted. void OnDynamicFormsSeen(); @@ -208,11 +205,10 @@ class PasswordAutofillAgent : public content::RenderFrameObserver, // The key under which PasswordAutofillManager can find info for filling. int key = -1; }; - typedef std::map<blink::WebInputElement, PasswordInfo> - WebInputToPasswordInfoMap; - typedef std::map<blink::WebElement, int> WebElementToPasswordInfoKeyMap; - typedef std::map<blink::WebInputElement, blink::WebInputElement> - PasswordToLoginMap; + using WebInputToPasswordInfoMap = + std::map<blink::WebInputElement, PasswordInfo>; + using PasswordToLoginMap = + std::map<blink::WebInputElement, blink::WebInputElement>; // This class keeps track of autofilled password input elements and makes sure // the autofilled password value is not accessible to JavaScript code until @@ -251,6 +247,7 @@ class PasswordAutofillAgent : public content::RenderFrameObserver, void WillCommitProvisionalLoad() override; void DidCommitProvisionalLoad(bool is_new_navigation, bool is_same_document_navigation) override; + void FocusedNodeChanged(const blink::WebNode& node) override; void OnDestruct() override; // Scans the given frame for password forms and sends them up to the browser. @@ -288,6 +285,16 @@ class PasswordAutofillAgent : public content::RenderFrameObserver, void ClearPreview(blink::WebInputElement* username, blink::WebInputElement* password); + // Checks that a given input field is valid before filling the given |input| + // with the given |credential| and marking the field as auto-filled. + void FillField(blink::WebInputElement* input, + const base::string16& credential); + + // Uses |FillField| to fill the given |credential| into the |password_input|. + // Saves the password for its associated form. + void FillPasswordFieldAndSave(blink::WebInputElement* password_input, + const base::string16& credential); + // Saves |form| and |input| in |provisionally_saved_form_|, as long as it // satisfies |restriction|. |form| and |input| are the elements user has just // been interacting with before the form save. |form| or |input| can be null @@ -299,19 +306,18 @@ class PasswordAutofillAgent : public content::RenderFrameObserver, // This function attempts to fill |username_element| and |password_element| // with values from |fill_data|. The |username_element| and |password_element| - // will only have the suggestedValue set, and will be registered for copying - // that to the real value through |registration_callback|. If a match is - // found, return true and |field_value_and_properties_map| will be modified - // with the autofilled credentials and |FieldPropertiesFlags::AUTOFILLED| - // flag. + // will only have the suggestedValue set. If a match is found, return true and + // |field_value_and_properties_map| will be modified with the autofilled + // credentials and |FieldPropertiesFlags::AUTOFILLED| flag. + // If |username_may_use_prefilled_placeholder| then this function may + // overwrite the value of username field. bool FillUserNameAndPassword( blink::WebInputElement* username_element, blink::WebInputElement* password_element, const PasswordFormFillData& fill_data, bool exact_username_match, - bool set_selection, + bool username_may_use_prefilled_placeholder, FieldValueAndPropertiesMaskMap* field_value_and_properties_map, - base::Callback<void(blink::WebInputElement*)> registration_callback, RendererSavePasswordProgressLogger* logger); // Logs whether a username value that was prefilled by the website was @@ -324,15 +330,12 @@ class PasswordAutofillAgent : public content::RenderFrameObserver, // unless the |username_element| already has a value set. In that case, // attempts to fill the password matching the already filled username, if // such a password exists. The |password_element| will have the - // |suggestedValue| set, and |suggestedValue| will be registered for copying - // to the real value through |registration_callback|. Returns true if the - // password is filled. + // |suggestedValue| set. Returns true if the password is filled. bool FillFormOnPasswordReceived( const PasswordFormFillData& fill_data, blink::WebInputElement username_element, blink::WebInputElement password_element, FieldValueAndPropertiesMaskMap* field_value_and_properties_map, - base::Callback<void(blink::WebInputElement*)> registration_callback, RendererSavePasswordProgressLogger* logger); // Helper function called when form submission is successful. @@ -344,6 +347,30 @@ class PasswordAutofillAgent : public content::RenderFrameObserver, void HidePopup(); + // TODO(https://crbug.com/831123): Rename to FillPasswordForm when browser + // form parsing is launched. + void FillUsingRendererIDs(int key, const PasswordFormFillData& form_data); + + // Returns pair(username_element, password_element) based on renderer ids from + // |username_field| and |password_field| from |form_data|. + std::pair<blink::WebInputElement, blink::WebInputElement> + FindUsernamePasswordElements(const PasswordFormFillData& form_data); + + // Populates |web_input_to_password_info_| and |password_to_username_| in + // order to provide fill on account select on |username_element| and + // |password_element| with credentials from |form_data|. + void StoreDataForFillOnAccountSelect(int key, + const PasswordFormFillData& form_data, + blink::WebInputElement username_element, + blink::WebInputElement password_element); + + // In case when |web_input_to_password_info_| is empty (i.e. no fill on + // account select data yet) this function populates + // |web_input_to_password_info_| in order to provide fill on account select on + // any password field (aka filling fallback) with credentials from + // |form_data|. + void MaybeStoreFallbackData(int key, const PasswordFormFillData& form_data); + // The logins we have filled so far with their associated info. WebInputToPasswordInfoMap web_input_to_password_info_; // A (sort-of) reverse map to |web_input_to_password_info_|. @@ -365,13 +392,19 @@ class PasswordAutofillAgent : public content::RenderFrameObserver, PasswordValueGatekeeper gatekeeper_; + // The currently focused input field. Not null if its a valid input that can + // be filled with a suggestions. + blink::WebInputElement focused_input_element_; + // True indicates that user debug information should be logged. bool logging_state_active_; - // True indicates that the username field was autofilled, false otherwise. - bool was_username_autofilled_; - // True indicates that the password field was autofilled, false otherwise. - bool was_password_autofilled_; + // Indicates whether the field is filled, previewed, or not filled by + // autofill. + blink::WebAutofillState username_autofill_state_; + // Indicates whether the field is filled, previewed, or not filled by + // autofill. + blink::WebAutofillState password_autofill_state_; // True indicates that a request for credentials has been sent to the store. bool sent_request_to_store_; @@ -398,14 +431,11 @@ class PasswordAutofillAgent : public content::RenderFrameObserver, PagePasswordsAnalyser page_passwords_analyser_; #endif - mojom::PasswordManagerDriverPtr password_manager_driver_; + mojom::PasswordManagerDriverAssociatedPtr password_manager_driver_; mojo::Binding<mojom::PasswordAutofillAgent> binding_; - bool blacklisted_form_found_ = false; - bool prefilled_username_metrics_logged_ = false; - DISALLOW_COPY_AND_ASSIGN(PasswordAutofillAgent); }; |