Index: components/password_manager/core/browser/password_form_manager.h |
diff --git a/components/password_manager/core/browser/password_form_manager.h b/components/password_manager/core/browser/password_form_manager.h |
index f271f31707f7bc9bf333c847832ad819d079cef1..06cf261fd485d5b4dce635988a2b31d9baad33ba 100644 |
--- a/components/password_manager/core/browser/password_form_manager.h |
+++ b/components/password_manager/core/browser/password_form_manager.h |
@@ -14,6 +14,7 @@ |
#include "base/macros.h" |
#include "base/memory/scoped_vector.h" |
#include "base/memory/weak_ptr.h" |
+#include "base/optional.h" |
#include "build/build_config.h" |
#include "components/autofill/core/browser/field_types.h" |
#include "components/autofill/core/browser/form_structure.h" |
@@ -24,6 +25,7 @@ |
namespace password_manager { |
+class FormSaver; |
class PasswordManager; |
class PasswordManagerClient; |
@@ -39,7 +41,8 @@ class PasswordFormManager : public PasswordStoreConsumer { |
PasswordManagerClient* client, |
const base::WeakPtr<PasswordManagerDriver>& driver, |
const autofill::PasswordForm& observed_form, |
- bool ssl_valid); |
+ bool ssl_valid, |
+ std::unique_ptr<FormSaver> form_saver); |
~PasswordFormManager() override; |
// Flags describing the result of comparing two forms as performed by |
@@ -263,19 +266,12 @@ class PasswordFormManager : public PasswordStoreConsumer { |
// Called when the user didn't interact with Update UI. |
void OnNoInteractionOnUpdate(); |
- // Called when the user accepts a generated password or change it. |
- void PresaveGeneratedPassword(const autofill::PasswordForm& form); |
- |
- // Called when the user removes the generated password. |
- void RemovePresavedPassword(); |
- |
- // Called after successful login on the form with a generated password. |
- void ReplacePresavedPasswordWithPendingCredentials(PasswordStore* store); |
- |
// Saves the outcome of HTML parsing based form classifier to upload proto. |
void SaveGenerationFieldDetectedByClassifier( |
const base::string16& generation_field); |
+ FormSaver* form_saver() { return form_saver_.get(); } |
+ |
private: |
// ManagerAction - What does the manager do with this form? Either it |
// fills it, or it doesn't. If it doesn't fill it, that's either |
@@ -366,12 +362,10 @@ class PasswordFormManager : public PasswordStoreConsumer { |
// For the blacklisted |form| returns true iff it blacklists |observed_form_|. |
bool IsBlacklistMatch(const autofill::PasswordForm& form) const; |
- // Helper for Save in the case that best_matches.size() > 0, meaning |
- // we have at least one match for this form/username/password. This |
- // Updates the form managed by this object, as well as any matching forms |
- // that now need to have preferred bit changed, since updated_credentials |
- // is now implicitly 'preferred'. |
- void UpdateLogin(); |
+ // Helper for Save in the case there is at least one match for the pending |
+ // credentials. This sends needed signals to the autofill server, and also |
+ // triggers some UMA reporting. |
+ void ProcessUpdate(); |
// Check to see if |pending| corresponds to an account creation form. If we |
// think that it does, we label it as such and upload this state to the |
@@ -402,10 +396,6 @@ class PasswordFormManager : public PasswordStoreConsumer { |
// UMA. |
int GetActionsTaken() const; |
- // Remove possible_usernames that may contains sensitive information and |
- // duplicates. |
- void SanitizePossibleUsernames(autofill::PasswordForm* form); |
- |
// Try to label password fields and upload |form_data|. This differs from |
// AutofillManager::OnFormSubmitted() in a few ways. |
// - This function will only label the first <input type="password"> field |
@@ -450,12 +440,6 @@ class PasswordFormManager : public PasswordStoreConsumer { |
// represents credentials that were not previosly saved. |
void CreatePendingCredentialsForNewCredentials(); |
- // If |pending_credentials_.username_value| is not empty, iterates over all |
- // forms from |best_matches_| and deletes from the password store all which |
- // are not PSL-matched, have an empty username, and a password equal to |
- // |pending_credentials_.password_value|. |
- void DeleteEmptyUsernameCredentials(); |
- |
// If |best_matches| contains only one entry then return this entry. Otherwise |
// for empty |password| return nullptr and for non-empty |password| returns |
// the unique entry in |best_matches_| with the same password, if it exists, |
@@ -475,6 +459,19 @@ class PasswordFormManager : public PasswordStoreConsumer { |
autofill::PasswordForm* FindBestSavedMatch( |
const autofill::PasswordForm* form) const; |
+ // Send appropriate votes based on what is currently being saved. |
+ void SendVotesOnSave(); |
+ |
+ // Edits some fields in |pending_credentials_| before it can be used to |
+ // update the password store. It also goes through |not_best_matches|, |
+ // updates the password of those which share the old password and username |
+ // with |pending_credentials_| to the new password of |pending_credentials_|, |
+ // and adds pointers to all such modified credentials to |
+ // |credentials_to_update|. If needed, this also returns a PasswordForm to |
+ // be used as the old primary key during the store update. |
+ base::Optional<autofill::PasswordForm> UpdatePendingAndGetOldKey( |
+ std::vector<const autofill::PasswordForm*>* credentials_to_update); |
+ |
// Set of nonblacklisted PasswordForms from the DB that best match the form |
// being managed by this. Use a map instead of vector, because we most |
// frequently require lookups by username value in IsNewLogin. |
@@ -624,6 +621,10 @@ class PasswordFormManager : public PasswordStoreConsumer { |
// without the password store returning results in the meantime. |
bool need_to_refetch_; |
+ // FormSaver instance used by |this| to all tasks related to storing |
+ // credentials. |
+ std::unique_ptr<FormSaver> form_saver_; |
+ |
DISALLOW_COPY_AND_ASSIGN(PasswordFormManager); |
}; |