Commit b9747055 authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Commit Bot

[Passwords] password_manager::PasswordForm in [fake...http]

This change replaces usages of autofill::PasswordForm with
password_manager::PasswordForm in the file range [fake...http] in the
//components/password_manager/core/browser directory.

Bug: 1067347
Change-Id: If62b9017a4bf2deb82eab75b7968c6c395f6b732
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2426709Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810258}
parent 3d157bac
...@@ -6,12 +6,10 @@ ...@@ -6,12 +6,10 @@
#include <memory> #include <memory>
#include "components/autofill/core/common/password_form.h" #include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/password_manager_util.h" #include "components/password_manager/core/browser/password_manager_util.h"
#include "components/password_manager/core/browser/statistics_table.h" #include "components/password_manager/core/browser/statistics_table.h"
using autofill::PasswordForm;
namespace password_manager { namespace password_manager {
FakeFormFetcher::FakeFormFetcher() = default; FakeFormFetcher::FakeFormFetcher() = default;
......
...@@ -9,14 +9,10 @@ ...@@ -9,14 +9,10 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/form_fetcher.h" #include "components/password_manager/core/browser/form_fetcher.h"
#include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/statistics_table.h" #include "components/password_manager/core/browser/statistics_table.h"
namespace autofill {
struct PasswordForm;
}
namespace password_manager { namespace password_manager {
struct InteractionsStats; struct InteractionsStats;
...@@ -46,18 +42,15 @@ class FakeFormFetcher : public FormFetcher { ...@@ -46,18 +42,15 @@ class FakeFormFetcher : public FormFetcher {
const std::vector<InteractionsStats>& GetInteractionsStats() const override; const std::vector<InteractionsStats>& GetInteractionsStats() const override;
base::span<const CompromisedCredentials> GetCompromisedCredentials() base::span<const CompromisedCredentials> GetCompromisedCredentials()
const override; const override;
std::vector<const autofill::PasswordForm*> GetNonFederatedMatches() std::vector<const PasswordForm*> GetNonFederatedMatches() const override;
const override; std::vector<const PasswordForm*> GetFederatedMatches() const override;
std::vector<const autofill::PasswordForm*> GetFederatedMatches()
const override;
bool IsBlacklisted() const override; bool IsBlacklisted() const override;
bool IsMovingBlocked(const autofill::GaiaIdHash& destination, bool IsMovingBlocked(const autofill::GaiaIdHash& destination,
const base::string16& username) const override; const base::string16& username) const override;
const std::vector<const autofill::PasswordForm*>& GetAllRelevantMatches() const std::vector<const PasswordForm*>& GetAllRelevantMatches()
const override;
const std::vector<const autofill::PasswordForm*>& GetBestMatches()
const override; const override;
const autofill::PasswordForm* GetPreferredMatch() const override; const std::vector<const PasswordForm*>& GetBestMatches() const override;
const PasswordForm* GetPreferredMatch() const override;
// Returns a new FakeFormFetcher. // Returns a new FakeFormFetcher.
std::unique_ptr<FormFetcher> Clone() override; std::unique_ptr<FormFetcher> Clone() override;
...@@ -66,10 +59,9 @@ class FakeFormFetcher : public FormFetcher { ...@@ -66,10 +59,9 @@ class FakeFormFetcher : public FormFetcher {
stats_ = stats; stats_ = stats;
} }
void set_scheme(autofill::PasswordForm::Scheme scheme) { scheme_ = scheme; } void set_scheme(PasswordForm::Scheme scheme) { scheme_ = scheme; }
void set_federated( void set_federated(const std::vector<const PasswordForm*>& federated) {
const std::vector<const autofill::PasswordForm*>& federated) {
state_ = State::NOT_WAITING; state_ = State::NOT_WAITING;
federated_ = federated; federated_ = federated;
} }
...@@ -78,8 +70,7 @@ class FakeFormFetcher : public FormFetcher { ...@@ -78,8 +70,7 @@ class FakeFormFetcher : public FormFetcher {
compromised_ = compromised; compromised_ = compromised;
} }
void SetNonFederated( void SetNonFederated(const std::vector<const PasswordForm*>& non_federated);
const std::vector<const autofill::PasswordForm*>& non_federated);
void SetBlacklisted(bool is_blacklisted); void SetBlacklisted(bool is_blacklisted);
...@@ -88,15 +79,14 @@ class FakeFormFetcher : public FormFetcher { ...@@ -88,15 +79,14 @@ class FakeFormFetcher : public FormFetcher {
private: private:
base::ObserverList<Consumer> consumers_; base::ObserverList<Consumer> consumers_;
State state_ = State::NOT_WAITING; State state_ = State::NOT_WAITING;
autofill::PasswordForm::Scheme scheme_ = PasswordForm::Scheme scheme_ = PasswordForm::Scheme::kHtml;
autofill::PasswordForm::Scheme::kHtml;
std::vector<InteractionsStats> stats_; std::vector<InteractionsStats> stats_;
std::vector<const autofill::PasswordForm*> non_federated_; std::vector<const PasswordForm*> non_federated_;
std::vector<const autofill::PasswordForm*> federated_; std::vector<const PasswordForm*> federated_;
std::vector<const autofill::PasswordForm*> non_federated_same_scheme_; std::vector<const PasswordForm*> non_federated_same_scheme_;
std::vector<const autofill::PasswordForm*> best_matches_; std::vector<const PasswordForm*> best_matches_;
std::vector<CompromisedCredentials> compromised_; std::vector<CompromisedCredentials> compromised_;
const autofill::PasswordForm* preferred_match_ = nullptr; const PasswordForm* preferred_match_ = nullptr;
bool is_blacklisted_ = false; bool is_blacklisted_ = false;
DISALLOW_COPY_AND_ASSIGN(FakeFormFetcher); DISALLOW_COPY_AND_ASSIGN(FakeFormFetcher);
......
...@@ -41,7 +41,7 @@ autofill::ServerFieldType FieldInfoManagerImpl::GetFieldType( ...@@ -41,7 +41,7 @@ autofill::ServerFieldType FieldInfoManagerImpl::GetFieldType(
} }
void FieldInfoManagerImpl::OnGetPasswordStoreResults( void FieldInfoManagerImpl::OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> results) { std::vector<std::unique_ptr<PasswordForm>> results) {
NOTREACHED(); NOTREACHED();
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "components/autofill/core/browser/field_types.h" #include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/common/signatures.h" #include "components/autofill/core/common/signatures.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
#include "components/password_manager/core/browser/password_form_forward.h"
#include "components/password_manager/core/browser/password_store_consumer.h" #include "components/password_manager/core/browser/password_store_consumer.h"
namespace password_manager { namespace password_manager {
...@@ -50,7 +51,7 @@ class FieldInfoManagerImpl : public FieldInfoManager, ...@@ -50,7 +51,7 @@ class FieldInfoManagerImpl : public FieldInfoManager,
private: private:
// PasswordStoreConsumer: // PasswordStoreConsumer:
void OnGetPasswordStoreResults( void OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> results) override; std::vector<std::unique_ptr<PasswordForm>> results) override;
void OnGetAllFieldInfo(std::vector<FieldInfo>) override; void OnGetAllFieldInfo(std::vector<FieldInfo>) override;
std::map<std::pair<autofill::FormSignature, autofill::FieldSignature>, std::map<std::pair<autofill::FormSignature, autofill::FieldSignature>,
......
...@@ -13,10 +13,7 @@ ...@@ -13,10 +13,7 @@
#include "base/observer_list_types.h" #include "base/observer_list_types.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "components/autofill/core/common/gaia_id_hash.h" #include "components/autofill/core/common/gaia_id_hash.h"
#include "components/password_manager/core/browser/password_form_forward.h"
namespace autofill {
struct PasswordForm;
}
namespace password_manager { namespace password_manager {
...@@ -74,13 +71,11 @@ class FormFetcher { ...@@ -74,13 +71,11 @@ class FormFetcher {
// Non-federated matches obtained from the backend. Valid only if GetState() // Non-federated matches obtained from the backend. Valid only if GetState()
// returns NOT_WAITING. // returns NOT_WAITING.
virtual std::vector<const autofill::PasswordForm*> GetNonFederatedMatches() virtual std::vector<const PasswordForm*> GetNonFederatedMatches() const = 0;
const = 0;
// Federated matches obtained from the backend. Valid only if GetState() // Federated matches obtained from the backend. Valid only if GetState()
// returns NOT_WAITING. // returns NOT_WAITING.
virtual std::vector<const autofill::PasswordForm*> GetFederatedMatches() virtual std::vector<const PasswordForm*> GetFederatedMatches() const = 0;
const = 0;
// Whether there are blacklisted matches in the backend. Valid only if // Whether there are blacklisted matches in the backend. Valid only if
// GetState() returns NOT_WAITING. // GetState() returns NOT_WAITING.
...@@ -95,15 +90,14 @@ class FormFetcher { ...@@ -95,15 +90,14 @@ class FormFetcher {
// Non-federated matches obtained from the backend that have the same scheme // Non-federated matches obtained from the backend that have the same scheme
// of this form. // of this form.
virtual const std::vector<const autofill::PasswordForm*>& virtual const std::vector<const PasswordForm*>& GetAllRelevantMatches()
GetAllRelevantMatches() const = 0; const = 0;
// Nonblacklisted matches obtained from the backend. // Nonblacklisted matches obtained from the backend.
virtual const std::vector<const autofill::PasswordForm*>& GetBestMatches() virtual const std::vector<const PasswordForm*>& GetBestMatches() const = 0;
const = 0;
// Pointer to a preferred entry in the vector returned by GetBestMatches(). // Pointer to a preferred entry in the vector returned by GetBestMatches().
virtual const autofill::PasswordForm* GetPreferredMatch() const = 0; virtual const PasswordForm* GetPreferredMatch() const = 0;
// Creates a copy of |*this| with contains the same credentials without the // Creates a copy of |*this| with contains the same credentials without the
// need for calling Fetch(). // need for calling Fetch().
......
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
#include <utility> #include <utility>
#include "build/build_config.h" #include "build/build_config.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/browser_save_password_progress_logger.h" #include "components/password_manager/core/browser/browser_save_password_progress_logger.h"
#include "components/password_manager/core/browser/credentials_filter.h" #include "components/password_manager/core/browser/credentials_filter.h"
#include "components/password_manager/core/browser/multi_store_form_fetcher.h" #include "components/password_manager/core/browser/multi_store_form_fetcher.h"
#include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/password_manager_client.h" #include "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_manager_util.h" #include "components/password_manager/core/browser/password_manager_util.h"
#include "components/password_manager/core/browser/password_store.h" #include "components/password_manager/core/browser/password_store.h"
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#include "components/password_manager/core/browser/statistics_table.h" #include "components/password_manager/core/browser/statistics_table.h"
#include "components/password_manager/core/common/password_manager_features.h" #include "components/password_manager/core/common/password_manager_features.h"
using autofill::PasswordForm;
using Logger = autofill::SavePasswordProgressLogger; using Logger = autofill::SavePasswordProgressLogger;
namespace password_manager { namespace password_manager {
...@@ -73,9 +71,9 @@ FormFetcherImpl::FormFetcherImpl(PasswordStore::FormDigest form_digest, ...@@ -73,9 +71,9 @@ FormFetcherImpl::FormFetcherImpl(PasswordStore::FormDigest form_digest,
bool should_migrate_http_passwords) bool should_migrate_http_passwords)
: form_digest_(std::move(form_digest)), : form_digest_(std::move(form_digest)),
client_(client), client_(client),
should_migrate_http_passwords_( should_migrate_http_passwords_(should_migrate_http_passwords &&
should_migrate_http_passwords && form_digest_.scheme ==
form_digest_.scheme == autofill::PasswordForm::Scheme::kHtml) {} PasswordForm::Scheme::kHtml) {}
FormFetcherImpl::~FormFetcherImpl() = default; FormFetcherImpl::~FormFetcherImpl() = default;
......
...@@ -53,29 +53,25 @@ class FormFetcherImpl : public FormFetcher, ...@@ -53,29 +53,25 @@ class FormFetcherImpl : public FormFetcher,
const std::vector<InteractionsStats>& GetInteractionsStats() const override; const std::vector<InteractionsStats>& GetInteractionsStats() const override;
base::span<const CompromisedCredentials> GetCompromisedCredentials() base::span<const CompromisedCredentials> GetCompromisedCredentials()
const override; const override;
std::vector<const autofill::PasswordForm*> GetNonFederatedMatches() std::vector<const PasswordForm*> GetNonFederatedMatches() const override;
const override; std::vector<const PasswordForm*> GetFederatedMatches() const override;
std::vector<const autofill::PasswordForm*> GetFederatedMatches()
const override;
bool IsBlacklisted() const override; bool IsBlacklisted() const override;
bool IsMovingBlocked(const autofill::GaiaIdHash& destination, bool IsMovingBlocked(const autofill::GaiaIdHash& destination,
const base::string16& username) const override; const base::string16& username) const override;
const std::vector<const autofill::PasswordForm*>& GetAllRelevantMatches() const std::vector<const PasswordForm*>& GetAllRelevantMatches()
const override;
const std::vector<const autofill::PasswordForm*>& GetBestMatches()
const override; const override;
const autofill::PasswordForm* GetPreferredMatch() const override; const std::vector<const PasswordForm*>& GetBestMatches() const override;
const PasswordForm* GetPreferredMatch() const override;
std::unique_ptr<FormFetcher> Clone() override; std::unique_ptr<FormFetcher> Clone() override;
protected: protected:
// Processes password form results and forwards them to the |consumers_|. // Processes password form results and forwards them to the |consumers_|.
void ProcessPasswordStoreResults( void ProcessPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> results); std::vector<std::unique_ptr<PasswordForm>> results);
// Splits |results| into |federated_|, |non_federated_| and |is_blacklisted_|. // Splits |results| into |federated_|, |non_federated_| and |is_blacklisted_|.
virtual void SplitResults( virtual void SplitResults(std::vector<std::unique_ptr<PasswordForm>> results);
std::vector<std::unique_ptr<autofill::PasswordForm>> results);
// PasswordStore results will be fetched for this description. // PasswordStore results will be fetched for this description.
const PasswordStore::FormDigest form_digest_; const PasswordStore::FormDigest form_digest_;
...@@ -91,12 +87,12 @@ class FormFetcherImpl : public FormFetcher, ...@@ -91,12 +87,12 @@ class FormFetcherImpl : public FormFetcher,
bool need_to_refetch_ = false; bool need_to_refetch_ = false;
// Results obtained from PasswordStore: // Results obtained from PasswordStore:
std::vector<std::unique_ptr<autofill::PasswordForm>> non_federated_; std::vector<std::unique_ptr<PasswordForm>> non_federated_;
// Federated credentials relevant to the observed form. They are neither // Federated credentials relevant to the observed form. They are neither
// filled not saved by PasswordFormManager, so they are kept separately from // filled not saved by PasswordFormManager, so they are kept separately from
// non-federated matches. // non-federated matches.
std::vector<std::unique_ptr<autofill::PasswordForm>> federated_; std::vector<std::unique_ptr<PasswordForm>> federated_;
// List of compromised credentials for the current domain. // List of compromised credentials for the current domain.
std::vector<CompromisedCredentials> compromised_credentials_; std::vector<CompromisedCredentials> compromised_credentials_;
...@@ -108,12 +104,12 @@ class FormFetcherImpl : public FormFetcher, ...@@ -108,12 +104,12 @@ class FormFetcherImpl : public FormFetcher,
private: private:
// PasswordStoreConsumer: // PasswordStoreConsumer:
void OnGetPasswordStoreResults( void OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> results) override; std::vector<std::unique_ptr<PasswordForm>> results) override;
void OnGetSiteStatistics(std::vector<InteractionsStats> stats) override; void OnGetSiteStatistics(std::vector<InteractionsStats> stats) override;
// HttpPasswordStoreMigrator::Consumer: // HttpPasswordStoreMigrator::Consumer:
void ProcessMigratedForms( void ProcessMigratedForms(
std::vector<std::unique_ptr<autofill::PasswordForm>> forms) override; std::vector<std::unique_ptr<PasswordForm>> forms) override;
// CompromisedCredentialsConsumer: // CompromisedCredentialsConsumer:
void OnGetCompromisedCredentials( void OnGetCompromisedCredentials(
...@@ -123,17 +119,17 @@ class FormFetcherImpl : public FormFetcher, ...@@ -123,17 +119,17 @@ class FormFetcherImpl : public FormFetcher,
std::unique_ptr<HttpPasswordStoreMigrator> http_migrator_; std::unique_ptr<HttpPasswordStoreMigrator> http_migrator_;
// Non-federated credentials of the same scheme as the observed form. // Non-federated credentials of the same scheme as the observed form.
std::vector<const autofill::PasswordForm*> non_federated_same_scheme_; std::vector<const PasswordForm*> non_federated_same_scheme_;
// Set of nonblacklisted PasswordForms from the password store that best match // Set of nonblacklisted PasswordForms from the password store that best match
// the form being managed by |this|. // the form being managed by |this|.
std::vector<const autofill::PasswordForm*> best_matches_; std::vector<const PasswordForm*> best_matches_;
// Convenience pointer to entry in |best_matches_| that is marked as // Convenience pointer to entry in |best_matches_| that is marked as
// preferred. This is only allowed to be null if there are no best matches at // preferred. This is only allowed to be null if there are no best matches at
// all, since there will always be one preferred login when there are multiple // all, since there will always be one preferred login when there are multiple
// matches (when first saved, a login is marked preferred). // matches (when first saved, a login is marked preferred).
const autofill::PasswordForm* preferred_match_ = nullptr; const PasswordForm* preferred_match_ = nullptr;
// Whether there were any blacklisted credentials obtained from the password // Whether there were any blacklisted credentials obtained from the password
// store. // store.
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/mock_password_store.h" #include "components/password_manager/core/browser/mock_password_store.h"
#include "components/password_manager/core/browser/multi_store_form_fetcher.h" #include "components/password_manager/core/browser/multi_store_form_fetcher.h"
#include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/password_manager_test_utils.h" #include "components/password_manager/core/browser/password_manager_test_utils.h"
#include "components/password_manager/core/browser/password_store.h" #include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/core/browser/statistics_table.h" #include "components/password_manager/core/browser/statistics_table.h"
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "url/origin.h" #include "url/origin.h"
#include "url/url_constants.h" #include "url/url_constants.h"
using autofill::PasswordForm;
using base::ASCIIToUTF16; using base::ASCIIToUTF16;
using base::StringPiece; using base::StringPiece;
using testing::_; using testing::_;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "components/autofill/core/common/password_form.h" #include "components/password_manager/core/browser/password_form_forward.h"
#include "components/password_manager/core/browser/password_store.h" #include "components/password_manager/core/browser/password_store.h"
namespace password_manager { namespace password_manager {
...@@ -27,7 +27,7 @@ class FormSaver { ...@@ -27,7 +27,7 @@ class FormSaver {
// Blacklist the origin described by |digest|. Returns the PasswordForm pushed // Blacklist the origin described by |digest|. Returns the PasswordForm pushed
// to the store. // to the store.
virtual autofill::PasswordForm PermanentlyBlacklist( virtual PasswordForm PermanentlyBlacklist(
PasswordStore::FormDigest digest) = 0; PasswordStore::FormDigest digest) = 0;
// Unblacklist the origin described by |digest| by deleting all corresponding // Unblacklist the origin described by |digest| by deleting all corresponding
...@@ -41,16 +41,16 @@ class FormSaver { ...@@ -41,16 +41,16 @@ class FormSaver {
// - empty-username credentials with the same password are removed. // - empty-username credentials with the same password are removed.
// - if |old_password| is provided, the old credentials with the same username // - if |old_password| is provided, the old credentials with the same username
// and the old password are updated to the new password. // and the old password are updated to the new password.
virtual void Save(autofill::PasswordForm pending, virtual void Save(PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches, const std::vector<const PasswordForm*>& matches,
const base::string16& old_password) = 0; const base::string16& old_password) = 0;
// Updates the saved credential in the password store sharing the same key as // Updates the saved credential in the password store sharing the same key as
// the |pending| form. // the |pending| form.
// The algorithm for handling |matches| and |old_password| is the same as // The algorithm for handling |matches| and |old_password| is the same as
// above. // above.
virtual void Update(autofill::PasswordForm pending, virtual void Update(PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches, const std::vector<const PasswordForm*>& matches,
const base::string16& old_password) = 0; const base::string16& old_password) = 0;
// If any of the unique key fields (signon_realm, origin, username_element, // If any of the unique key fields (signon_realm, origin, username_element,
...@@ -59,14 +59,13 @@ class FormSaver { ...@@ -59,14 +59,13 @@ class FormSaver {
// old values for the unique key fields (the rest of the fields are ignored). // old values for the unique key fields (the rest of the fields are ignored).
// The algorithm for handling |matches| and |old_password| is the same as // The algorithm for handling |matches| and |old_password| is the same as
// above. // above.
virtual void UpdateReplace( virtual void UpdateReplace(PasswordForm pending,
autofill::PasswordForm pending, const std::vector<const PasswordForm*>& matches,
const std::vector<const autofill::PasswordForm*>& matches,
const base::string16& old_password, const base::string16& old_password,
const autofill::PasswordForm& old_unique_key) = 0; const PasswordForm& old_unique_key) = 0;
// Removes |form| from the password store. // Removes |form| from the password store.
virtual void Remove(const autofill::PasswordForm& form) = 0; virtual void Remove(const PasswordForm& form) = 0;
// Creates a new FormSaver with the same state as |*this|. // Creates a new FormSaver with the same state as |*this|.
virtual std::unique_ptr<FormSaver> Clone() = 0; virtual std::unique_ptr<FormSaver> Clone() = 0;
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
using autofill::FormData; using autofill::FormData;
using autofill::FormFieldData; using autofill::FormFieldData;
using autofill::PasswordForm;
namespace password_manager { namespace password_manager {
...@@ -106,9 +105,8 @@ void FormSaverImpl::Save(PasswordForm pending, ...@@ -106,9 +105,8 @@ void FormSaverImpl::Save(PasswordForm pending,
PostProcessMatches(pending, matches, old_password, store_); PostProcessMatches(pending, matches, old_password, store_);
} }
void FormSaverImpl::Update( void FormSaverImpl::Update(PasswordForm pending,
autofill::PasswordForm pending, const std::vector<const PasswordForm*>& matches,
const std::vector<const autofill::PasswordForm*>& matches,
const base::string16& old_password) { const base::string16& old_password) {
SanitizeFormData(&pending.form_data); SanitizeFormData(&pending.form_data);
store_->UpdateLogin(pending); store_->UpdateLogin(pending);
...@@ -117,10 +115,10 @@ void FormSaverImpl::Update( ...@@ -117,10 +115,10 @@ void FormSaverImpl::Update(
} }
void FormSaverImpl::UpdateReplace( void FormSaverImpl::UpdateReplace(
autofill::PasswordForm pending, PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches, const std::vector<const PasswordForm*>& matches,
const base::string16& old_password, const base::string16& old_password,
const autofill::PasswordForm& old_unique_key) { const PasswordForm& old_unique_key) {
SanitizeFormData(&pending.form_data); SanitizeFormData(&pending.form_data);
store_->UpdateLoginWithPrimaryKey(pending, old_unique_key); store_->UpdateLoginWithPrimaryKey(pending, old_unique_key);
// Update existing matches in the password store. // Update existing matches in the password store.
......
...@@ -24,20 +24,19 @@ class FormSaverImpl : public FormSaver { ...@@ -24,20 +24,19 @@ class FormSaverImpl : public FormSaver {
~FormSaverImpl() override; ~FormSaverImpl() override;
// FormSaver: // FormSaver:
autofill::PasswordForm PermanentlyBlacklist( PasswordForm PermanentlyBlacklist(PasswordStore::FormDigest digest) override;
PasswordStore::FormDigest digest) override;
void Unblacklist(const PasswordStore::FormDigest& digest) override; void Unblacklist(const PasswordStore::FormDigest& digest) override;
void Save(autofill::PasswordForm pending, void Save(PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches, const std::vector<const PasswordForm*>& matches,
const base::string16& old_password) override; const base::string16& old_password) override;
void Update(autofill::PasswordForm pending, void Update(PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches, const std::vector<const PasswordForm*>& matches,
const base::string16& old_password) override; const base::string16& old_password) override;
void UpdateReplace(autofill::PasswordForm pending, void UpdateReplace(PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches, const std::vector<const PasswordForm*>& matches,
const base::string16& old_password, const base::string16& old_password,
const autofill::PasswordForm& old_unique_key) override; const PasswordForm& old_unique_key) override;
void Remove(const autofill::PasswordForm& form) override; void Remove(const PasswordForm& form) override;
std::unique_ptr<FormSaver> Clone() override; std::unique_ptr<FormSaver> Clone() override;
private: private:
......
...@@ -14,15 +14,14 @@ ...@@ -14,15 +14,14 @@
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/mock_password_store.h" #include "components/password_manager/core/browser/mock_password_store.h"
#include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/password_manager_util.h" #include "components/password_manager/core/browser/password_manager_util.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h" #include "url/gurl.h"
using autofill::FormFieldData; using autofill::FormFieldData;
using autofill::PasswordForm;
using base::ASCIIToUTF16; using base::ASCIIToUTF16;
using base::StringPiece; using base::StringPiece;
using testing::_; using testing::_;
...@@ -89,14 +88,14 @@ class FormSaverImplSaveTest ...@@ -89,14 +88,14 @@ class FormSaverImplSaveTest
public ::testing::WithParamInterface<SaveOperation> { public ::testing::WithParamInterface<SaveOperation> {
protected: protected:
// Either saves, updates or replaces |pending| according to the test param. // Either saves, updates or replaces |pending| according to the test param.
void SaveCredential(autofill::PasswordForm pending, void SaveCredential(PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches, const std::vector<const PasswordForm*>& matches,
const base::string16& old_password); const base::string16& old_password);
}; };
void FormSaverImplSaveTest::SaveCredential( void FormSaverImplSaveTest::SaveCredential(
autofill::PasswordForm pending, PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches, const std::vector<const PasswordForm*>& matches,
const base::string16& old_password) { const base::string16& old_password) {
switch (GetParam()) { switch (GetParam()) {
case SaveOperation::kSave: case SaveOperation::kSave:
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_HTTP_AUTH_MANAGER_H_ #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_HTTP_AUTH_MANAGER_H_
#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_HTTP_AUTH_MANAGER_H_ #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_HTTP_AUTH_MANAGER_H_
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/browser_save_password_progress_logger.h" #include "components/password_manager/core/browser/browser_save_password_progress_logger.h"
#include "components/password_manager/core/browser/password_form_forward.h"
namespace password_manager { namespace password_manager {
...@@ -26,7 +26,7 @@ class HttpAuthManager { ...@@ -26,7 +26,7 @@ class HttpAuthManager {
// Set the observer which is notified in case a form can be auto-filled. // Set the observer which is notified in case a form can be auto-filled.
virtual void SetObserverAndDeliverCredentials( virtual void SetObserverAndDeliverCredentials(
HttpAuthObserver* observer, HttpAuthObserver* observer,
const autofill::PasswordForm& observed_form) = 0; const PasswordForm& observed_form) = 0;
// Detach |observer| as the observer if it is the current observer. // Detach |observer| as the observer if it is the current observer.
// Called by the observer when destructed to unregister itself. // Called by the observer when destructed to unregister itself.
...@@ -34,8 +34,7 @@ class HttpAuthManager { ...@@ -34,8 +34,7 @@ class HttpAuthManager {
// Handles submitted http-auth credentials event. // Handles submitted http-auth credentials event.
// Called by the LoginHandler instance. // Called by the LoginHandler instance.
virtual void OnPasswordFormSubmitted( virtual void OnPasswordFormSubmitted(const PasswordForm& password_form) = 0;
const autofill::PasswordForm& password_form) = 0;
// Called by the LoginHandler instance when the password form is dismissed. // Called by the LoginHandler instance when the password form is dismissed.
virtual void OnPasswordFormDismissed() = 0; virtual void OnPasswordFormDismissed() = 0;
......
...@@ -6,16 +6,14 @@ ...@@ -6,16 +6,14 @@
#include <utility> #include <utility>
#include "components/autofill/core/common/password_form.h"
#include "components/autofill/core/common/save_password_progress_logger.h" #include "components/autofill/core/common/save_password_progress_logger.h"
#include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/password_form_manager.h" #include "components/password_manager/core/browser/password_form_manager.h"
#include "components/password_manager/core/browser/password_form_manager_for_ui.h" #include "components/password_manager/core/browser/password_form_manager_for_ui.h"
#include "components/password_manager/core/browser/password_manager_client.h" #include "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_manager_util.h" #include "components/password_manager/core/browser/password_manager_util.h"
#include "components/password_manager/core/browser/password_save_manager_impl.h" #include "components/password_manager/core/browser/password_save_manager_impl.h"
using autofill::PasswordForm;
namespace password_manager { namespace password_manager {
namespace { namespace {
......
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/browser_save_password_progress_logger.h" #include "components/password_manager/core/browser/browser_save_password_progress_logger.h"
#include "components/password_manager/core/browser/http_auth_manager.h" #include "components/password_manager/core/browser/http_auth_manager.h"
#include "components/password_manager/core/browser/http_auth_observer.h" #include "components/password_manager/core/browser/http_auth_observer.h"
#include "components/password_manager/core/browser/password_form_forward.h"
namespace password_manager { namespace password_manager {
...@@ -28,24 +28,23 @@ class HttpAuthManagerImpl : public HttpAuthManager { ...@@ -28,24 +28,23 @@ class HttpAuthManagerImpl : public HttpAuthManager {
HttpAuthManagerImpl(PasswordManagerClient* client, HttpAuthManagerImpl(PasswordManagerClient* client,
HttpAuthObserver* observer, HttpAuthObserver* observer,
const autofill::PasswordForm& observed_form); const PasswordForm& observed_form);
~HttpAuthManagerImpl() override; ~HttpAuthManagerImpl() override;
// HttpAuthManager: // HttpAuthManager:
void SetObserverAndDeliverCredentials( void SetObserverAndDeliverCredentials(
HttpAuthObserver* observer, HttpAuthObserver* observer,
const autofill::PasswordForm& observed_form) override; const PasswordForm& observed_form) override;
void DetachObserver(HttpAuthObserver* observer) override; void DetachObserver(HttpAuthObserver* observer) override;
void OnPasswordFormSubmitted( void OnPasswordFormSubmitted(const PasswordForm& password_form) override;
const autofill::PasswordForm& password_form) override;
void OnPasswordFormDismissed() override; void OnPasswordFormDismissed() override;
// Called by a PasswordManagerClient when it decides that a HTTP auth dialog // Called by a PasswordManagerClient when it decides that a HTTP auth dialog
// can be auto-filled. It notifies the observer about new credentials given // can be auto-filled. It notifies the observer about new credentials given
// that the form manged by |form_manager| equals the one observed by the // that the form manged by |form_manager| equals the one observed by the
// observer that is managed by |form_manager|. // observer that is managed by |form_manager|.
void Autofill(const autofill::PasswordForm& preferred_match, void Autofill(const PasswordForm& preferred_match,
const PasswordFormManagerForUI* form_manager) const; const PasswordFormManagerForUI* form_manager) const;
// Handles successful navigation to the main frame. // Handles successful navigation to the main frame.
...@@ -57,7 +56,7 @@ class HttpAuthManagerImpl : public HttpAuthManager { ...@@ -57,7 +56,7 @@ class HttpAuthManagerImpl : public HttpAuthManager {
// Passes |form| to PasswordFormManager that manages it for using it after // Passes |form| to PasswordFormManager that manages it for using it after
// detecting submission success for saving. // detecting submission success for saving.
void ProvisionallySaveForm(const autofill::PasswordForm& password_form); void ProvisionallySaveForm(const PasswordForm& password_form);
// Initiates the saving of the password. // Initiates the saving of the password.
void OnLoginSuccesfull(); void OnLoginSuccesfull();
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using autofill::PasswordForm;
using base::ASCIIToUTF16; using base::ASCIIToUTF16;
using base::TestMockTimeTaskRunner; using base::TestMockTimeTaskRunner;
using testing::_; using testing::_;
...@@ -53,8 +51,7 @@ class MockPasswordManagerClient : public StubPasswordManagerClient { ...@@ -53,8 +51,7 @@ class MockPasswordManagerClient : public StubPasswordManagerClient {
MOCK_CONST_METHOD1(IsSavingAndFillingEnabled, bool(const GURL&)); MOCK_CONST_METHOD1(IsSavingAndFillingEnabled, bool(const GURL&));
MOCK_CONST_METHOD1(IsFillingEnabled, bool(const GURL&)); MOCK_CONST_METHOD1(IsFillingEnabled, bool(const GURL&));
MOCK_METHOD2(AutofillHttpAuth, MOCK_METHOD2(AutofillHttpAuth,
void(const autofill::PasswordForm&, void(const PasswordForm&, const PasswordFormManagerForUI*));
const PasswordFormManagerForUI*));
MOCK_CONST_METHOD0(GetProfilePasswordStore, PasswordStore*()); MOCK_CONST_METHOD0(GetProfilePasswordStore, PasswordStore*());
MOCK_CONST_METHOD0(GetAccountPasswordStore, PasswordStore*()); MOCK_CONST_METHOD0(GetAccountPasswordStore, PasswordStore*());
MOCK_METHOD0(PromptUserToSaveOrUpdatePasswordPtr, void()); MOCK_METHOD0(PromptUserToSaveOrUpdatePasswordPtr, void());
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "components/autofill/core/common/password_form.h"
namespace password_manager { namespace password_manager {
......
...@@ -39,7 +39,7 @@ void HttpCredentialCleaner::StartCleaning(Observer* observer) { ...@@ -39,7 +39,7 @@ void HttpCredentialCleaner::StartCleaning(Observer* observer) {
} }
void HttpCredentialCleaner::OnGetPasswordStoreResults( void HttpCredentialCleaner::OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> results) { std::vector<std::unique_ptr<PasswordForm>> results) {
// Non HTTP or HTTPS credentials are ignored, in particular Android or // Non HTTP or HTTPS credentials are ignored, in particular Android or
// federated credentials. // federated credentials.
for (auto& form : RemoveNonHTTPOrHTTPSForms(std::move(results))) { for (auto& form : RemoveNonHTTPOrHTTPSForms(std::move(results))) {
...@@ -64,7 +64,7 @@ void HttpCredentialCleaner::OnGetPasswordStoreResults( ...@@ -64,7 +64,7 @@ void HttpCredentialCleaner::OnGetPasswordStoreResults(
} }
void HttpCredentialCleaner::OnHSTSQueryResult( void HttpCredentialCleaner::OnHSTSQueryResult(
std::unique_ptr<autofill::PasswordForm> form, std::unique_ptr<PasswordForm> form,
FormKey key, FormKey key,
HSTSResult hsts_result) { HSTSResult hsts_result) {
++processed_results_; ++processed_results_;
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
#include "base/containers/flat_set.h" #include "base/containers/flat_set.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/credentials_cleaner.h" #include "components/password_manager/core/browser/credentials_cleaner.h"
#include "components/password_manager/core/browser/hsts_query.h" #include "components/password_manager/core/browser/hsts_query.h"
#include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/password_store_consumer.h" #include "components/password_manager/core/browser/password_store_consumer.h"
namespace network { namespace network {
...@@ -77,19 +77,18 @@ class HttpCredentialCleaner : public PasswordStoreConsumer, ...@@ -77,19 +77,18 @@ class HttpCredentialCleaner : public PasswordStoreConsumer,
// signon-realm excluding the protocol, the second argument is // signon-realm excluding the protocol, the second argument is
// the PasswordForm::scheme (i.e. HTML, BASIC, etc.) and the third argument is // the PasswordForm::scheme (i.e. HTML, BASIC, etc.) and the third argument is
// the username of the form. // the username of the form.
using FormKey = using FormKey = std::tuple<std::string, PasswordForm::Scheme, base::string16>;
std::tuple<std::string, autofill::PasswordForm::Scheme, base::string16>;
// PasswordStoreConsumer: // PasswordStoreConsumer:
void OnGetPasswordStoreResults( void OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> results) override; std::vector<std::unique_ptr<PasswordForm>> results) override;
// This function will inform us using |hsts_result| parameter if the |form|'s // This function will inform us using |hsts_result| parameter if the |form|'s
// host has HSTS enabled. |key| is |form|'s encoding which is used for // host has HSTS enabled. |key| is |form|'s encoding which is used for
// matching |form| with an HTTPS credential with the same FormKey. // matching |form| with an HTTPS credential with the same FormKey.
// Inside the function the metric counters are updated and, if needed, the // Inside the function the metric counters are updated and, if needed, the
// |form| is removed or migrated to HTTPS. // |form| is removed or migrated to HTTPS.
void OnHSTSQueryResult(std::unique_ptr<autofill::PasswordForm> form, void OnHSTSQueryResult(std::unique_ptr<PasswordForm> form,
FormKey key, FormKey key,
HSTSResult hsts_result); HSTSResult hsts_result);
......
...@@ -35,7 +35,7 @@ enum class HttpCredentialType { kConflicting, kEquivalent, kNoMatching }; ...@@ -35,7 +35,7 @@ enum class HttpCredentialType { kConflicting, kEquivalent, kNoMatching };
struct TestCase { struct TestCase {
bool is_hsts_enabled; bool is_hsts_enabled;
autofill::PasswordForm::Scheme http_form_scheme; PasswordForm::Scheme http_form_scheme;
bool same_signon_realm; bool same_signon_realm;
bool same_scheme; bool same_scheme;
bool same_username; bool same_username;
...@@ -54,48 +54,48 @@ struct TestCase { ...@@ -54,48 +54,48 @@ struct TestCase {
constexpr static TestCase kCases[] = { constexpr static TestCase kCases[] = {
{true, autofill::PasswordForm::Scheme::kHtml, false, true, true, true, {true, PasswordForm::Scheme::kHtml, false, true, true, true,
HttpCredentialType::kNoMatching}, HttpCredentialType::kNoMatching},
{true, autofill::PasswordForm::Scheme::kHtml, true, false, true, true, {true, PasswordForm::Scheme::kHtml, true, false, true, true,
HttpCredentialType::kNoMatching}, HttpCredentialType::kNoMatching},
{true, autofill::PasswordForm::Scheme::kHtml, true, true, false, true, {true, PasswordForm::Scheme::kHtml, true, true, false, true,
HttpCredentialType::kNoMatching}, HttpCredentialType::kNoMatching},
{true, autofill::PasswordForm::Scheme::kHtml, true, true, true, false, {true, PasswordForm::Scheme::kHtml, true, true, true, false,
HttpCredentialType::kConflicting}, HttpCredentialType::kConflicting},
{true, autofill::PasswordForm::Scheme::kHtml, true, true, true, true, {true, PasswordForm::Scheme::kHtml, true, true, true, true,
HttpCredentialType::kEquivalent}, HttpCredentialType::kEquivalent},
{false, autofill::PasswordForm::Scheme::kHtml, false, true, true, true, {false, PasswordForm::Scheme::kHtml, false, true, true, true,
HttpCredentialType::kNoMatching}, HttpCredentialType::kNoMatching},
{false, autofill::PasswordForm::Scheme::kHtml, true, false, true, true, {false, PasswordForm::Scheme::kHtml, true, false, true, true,
HttpCredentialType::kNoMatching}, HttpCredentialType::kNoMatching},
{false, autofill::PasswordForm::Scheme::kHtml, true, true, false, true, {false, PasswordForm::Scheme::kHtml, true, true, false, true,
HttpCredentialType::kNoMatching}, HttpCredentialType::kNoMatching},
{false, autofill::PasswordForm::Scheme::kHtml, true, true, true, false, {false, PasswordForm::Scheme::kHtml, true, true, true, false,
HttpCredentialType::kConflicting}, HttpCredentialType::kConflicting},
{false, autofill::PasswordForm::Scheme::kHtml, true, true, true, true, {false, PasswordForm::Scheme::kHtml, true, true, true, true,
HttpCredentialType::kEquivalent}, HttpCredentialType::kEquivalent},
{true, autofill::PasswordForm::Scheme::kBasic, false, true, true, true, {true, PasswordForm::Scheme::kBasic, false, true, true, true,
HttpCredentialType::kNoMatching}, HttpCredentialType::kNoMatching},
{true, autofill::PasswordForm::Scheme::kBasic, true, false, true, true, {true, PasswordForm::Scheme::kBasic, true, false, true, true,
HttpCredentialType::kNoMatching}, HttpCredentialType::kNoMatching},
{true, autofill::PasswordForm::Scheme::kBasic, true, true, false, true, {true, PasswordForm::Scheme::kBasic, true, true, false, true,
HttpCredentialType::kNoMatching}, HttpCredentialType::kNoMatching},
{true, autofill::PasswordForm::Scheme::kBasic, true, true, true, false, {true, PasswordForm::Scheme::kBasic, true, true, true, false,
HttpCredentialType::kConflicting}, HttpCredentialType::kConflicting},
{true, autofill::PasswordForm::Scheme::kBasic, true, true, true, true, {true, PasswordForm::Scheme::kBasic, true, true, true, true,
HttpCredentialType::kEquivalent}, HttpCredentialType::kEquivalent},
{false, autofill::PasswordForm::Scheme::kBasic, false, true, true, true, {false, PasswordForm::Scheme::kBasic, false, true, true, true,
HttpCredentialType::kNoMatching}, HttpCredentialType::kNoMatching},
{false, autofill::PasswordForm::Scheme::kBasic, true, false, true, true, {false, PasswordForm::Scheme::kBasic, true, false, true, true,
HttpCredentialType::kNoMatching}, HttpCredentialType::kNoMatching},
{false, autofill::PasswordForm::Scheme::kBasic, true, true, false, true, {false, PasswordForm::Scheme::kBasic, true, true, false, true,
HttpCredentialType::kNoMatching}, HttpCredentialType::kNoMatching},
{false, autofill::PasswordForm::Scheme::kBasic, true, true, true, false, {false, PasswordForm::Scheme::kBasic, true, true, true, false,
HttpCredentialType::kConflicting}, HttpCredentialType::kConflicting},
{false, autofill::PasswordForm::Scheme::kBasic, true, true, true, true, {false, PasswordForm::Scheme::kBasic, true, true, true, true,
HttpCredentialType::kEquivalent}}; HttpCredentialType::kEquivalent}};
} // namespace } // namespace
...@@ -151,7 +151,7 @@ TEST_P(HttpCredentialCleanerTest, ReportHttpMigrationMetrics) { ...@@ -151,7 +151,7 @@ TEST_P(HttpCredentialCleanerTest, ReportHttpMigrationMetrics) {
<< ", same_username=" << test.same_username << ", same_username=" << test.same_username
<< ", same_password=" << test.same_password); << ", same_password=" << test.same_password);
autofill::PasswordForm http_form; PasswordForm http_form;
http_form.url = GURL("http://example.org/"); http_form.url = GURL("http://example.org/");
http_form.signon_realm = "http://example.org/"; http_form.signon_realm = "http://example.org/";
http_form.scheme = test.http_form_scheme; http_form.scheme = test.http_form_scheme;
...@@ -159,17 +159,16 @@ TEST_P(HttpCredentialCleanerTest, ReportHttpMigrationMetrics) { ...@@ -159,17 +159,16 @@ TEST_P(HttpCredentialCleanerTest, ReportHttpMigrationMetrics) {
http_form.password_value = password[1]; http_form.password_value = password[1];
store_->AddLogin(http_form); store_->AddLogin(http_form);
autofill::PasswordForm https_form; PasswordForm https_form;
https_form.url = GURL("https://example.org/"); https_form.url = GURL("https://example.org/");
https_form.signon_realm = signon_realm[test.same_signon_realm]; https_form.signon_realm = signon_realm[test.same_signon_realm];
https_form.username_value = username[test.same_username]; https_form.username_value = username[test.same_username];
https_form.password_value = password[test.same_password]; https_form.password_value = password[test.same_password];
https_form.scheme = test.http_form_scheme; https_form.scheme = test.http_form_scheme;
if (!test.same_scheme) { if (!test.same_scheme) {
https_form.scheme = https_form.scheme = (http_form.scheme == PasswordForm::Scheme::kBasic
(http_form.scheme == autofill::PasswordForm::Scheme::kBasic ? PasswordForm::Scheme::kHtml
? autofill::PasswordForm::Scheme::kHtml : PasswordForm::Scheme::kBasic);
: autofill::PasswordForm::Scheme::kBasic);
} }
store_->AddLogin(https_form); store_->AddLogin(https_form);
......
...@@ -48,7 +48,7 @@ HttpPasswordStoreMigrator::HttpPasswordStoreMigrator( ...@@ -48,7 +48,7 @@ HttpPasswordStoreMigrator::HttpPasswordStoreMigrator(
GURL::Replacements rep; GURL::Replacements rep;
rep.SetSchemeStr(url::kHttpScheme); rep.SetSchemeStr(url::kHttpScheme);
GURL http_origin = https_origin.GetURL().ReplaceComponents(rep); GURL http_origin = https_origin.GetURL().ReplaceComponents(rep);
PasswordStore::FormDigest form(autofill::PasswordForm::Scheme::kHtml, PasswordStore::FormDigest form(PasswordForm::Scheme::kHtml,
http_origin.GetOrigin().spec(), http_origin); http_origin.GetOrigin().spec(), http_origin);
http_origin_domain_ = url::Origin::Create(http_origin); http_origin_domain_ = url::Origin::Create(http_origin);
store_->GetLogins(form, this); store_->GetLogins(form, this);
...@@ -60,11 +60,11 @@ HttpPasswordStoreMigrator::HttpPasswordStoreMigrator( ...@@ -60,11 +60,11 @@ HttpPasswordStoreMigrator::HttpPasswordStoreMigrator(
HttpPasswordStoreMigrator::~HttpPasswordStoreMigrator() = default; HttpPasswordStoreMigrator::~HttpPasswordStoreMigrator() = default;
autofill::PasswordForm HttpPasswordStoreMigrator::MigrateHttpFormToHttps( PasswordForm HttpPasswordStoreMigrator::MigrateHttpFormToHttps(
const autofill::PasswordForm& http_form) { const PasswordForm& http_form) {
DCHECK(http_form.url.SchemeIs(url::kHttpScheme)); DCHECK(http_form.url.SchemeIs(url::kHttpScheme));
autofill::PasswordForm https_form = http_form; PasswordForm https_form = http_form;
GURL::Replacements rep; GURL::Replacements rep;
rep.SetSchemeStr(url::kHttpsScheme); rep.SetSchemeStr(url::kHttpsScheme);
https_form.url = http_form.url.ReplaceComponents(rep); https_form.url = http_form.url.ReplaceComponents(rep);
...@@ -83,13 +83,13 @@ autofill::PasswordForm HttpPasswordStoreMigrator::MigrateHttpFormToHttps( ...@@ -83,13 +83,13 @@ autofill::PasswordForm HttpPasswordStoreMigrator::MigrateHttpFormToHttps(
https_form.action = https_form.url; https_form.action = https_form.url;
https_form.form_data = autofill::FormData(); https_form.form_data = autofill::FormData();
https_form.generation_upload_status = https_form.generation_upload_status =
autofill::PasswordForm::GenerationUploadStatus::kNoSignalSent; PasswordForm::GenerationUploadStatus::kNoSignalSent;
https_form.skip_zero_click = false; https_form.skip_zero_click = false;
return https_form; return https_form;
} }
void HttpPasswordStoreMigrator::OnGetPasswordStoreResults( void HttpPasswordStoreMigrator::OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> results) { std::vector<std::unique_ptr<PasswordForm>> results) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
results_ = std::move(results); results_ = std::move(results);
got_password_store_results_ = true; got_password_store_results_ = true;
...@@ -113,15 +113,14 @@ void HttpPasswordStoreMigrator::OnHSTSQueryResult(HSTSResult is_hsts) { ...@@ -113,15 +113,14 @@ void HttpPasswordStoreMigrator::OnHSTSQueryResult(HSTSResult is_hsts) {
void HttpPasswordStoreMigrator::ProcessPasswordStoreResults() { void HttpPasswordStoreMigrator::ProcessPasswordStoreResults() {
// Android and PSL matches are ignored. // Android and PSL matches are ignored.
base::EraseIf( base::EraseIf(results_, [](const std::unique_ptr<PasswordForm>& form) {
results_, [](const std::unique_ptr<autofill::PasswordForm>& form) {
return form->is_affiliation_based_match || form->is_public_suffix_match; return form->is_affiliation_based_match || form->is_public_suffix_match;
}); });
// Add the new credentials to the password store. The HTTP forms are // Add the new credentials to the password store. The HTTP forms are
// removed iff |mode_| == MigrationMode::MOVE. // removed iff |mode_| == MigrationMode::MOVE.
for (const auto& form : results_) { for (const auto& form : results_) {
autofill::PasswordForm new_form = PasswordForm new_form =
HttpPasswordStoreMigrator::MigrateHttpFormToHttps(*form); HttpPasswordStoreMigrator::MigrateHttpFormToHttps(*form);
store_->AddLogin(new_form); store_->AddLogin(new_form);
......
...@@ -11,13 +11,10 @@ ...@@ -11,13 +11,10 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "components/password_manager/core/browser/hsts_query.h" #include "components/password_manager/core/browser/hsts_query.h"
#include "components/password_manager/core/browser/password_form_forward.h"
#include "components/password_manager/core/browser/password_store_consumer.h" #include "components/password_manager/core/browser/password_store_consumer.h"
#include "url/origin.h" #include "url/origin.h"
namespace autofill {
struct PasswordForm;
}
namespace password_manager { namespace password_manager {
// These values are persisted to logs. Entries should not be renumbered and // These values are persisted to logs. Entries should not be renumbered and
...@@ -51,7 +48,7 @@ class HttpPasswordStoreMigrator : public PasswordStoreConsumer { ...@@ -51,7 +48,7 @@ class HttpPasswordStoreMigrator : public PasswordStoreConsumer {
// Notify the embedder that |forms| were migrated to HTTPS. |forms| contain // Notify the embedder that |forms| were migrated to HTTPS. |forms| contain
// the updated HTTPS scheme. // the updated HTTPS scheme.
virtual void ProcessMigratedForms( virtual void ProcessMigratedForms(
std::vector<std::unique_ptr<autofill::PasswordForm>> forms) = 0; std::vector<std::unique_ptr<PasswordForm>> forms) = 0;
}; };
// |https_origin| should specify a valid HTTPS URL. // |https_origin| should specify a valid HTTPS URL.
...@@ -62,12 +59,11 @@ class HttpPasswordStoreMigrator : public PasswordStoreConsumer { ...@@ -62,12 +59,11 @@ class HttpPasswordStoreMigrator : public PasswordStoreConsumer {
~HttpPasswordStoreMigrator() override; ~HttpPasswordStoreMigrator() override;
// Creates HTTPS version of |http_form|. // Creates HTTPS version of |http_form|.
static autofill::PasswordForm MigrateHttpFormToHttps( static PasswordForm MigrateHttpFormToHttps(const PasswordForm& http_form);
const autofill::PasswordForm& http_form);
// PasswordStoreConsumer: // PasswordStoreConsumer:
void OnGetPasswordStoreResults( void OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> results) override; std::vector<std::unique_ptr<PasswordForm>> results) override;
// Callback for PostHSTSQueryForHostAndNetworkContext. // Callback for PostHSTSQueryForHostAndNetworkContext.
void OnHSTSQueryResult(HSTSResult is_hsts); void OnHSTSQueryResult(HSTSResult is_hsts);
...@@ -85,7 +81,7 @@ class HttpPasswordStoreMigrator : public PasswordStoreConsumer { ...@@ -85,7 +81,7 @@ class HttpPasswordStoreMigrator : public PasswordStoreConsumer {
bool got_hsts_query_result_ = false; bool got_hsts_query_result_ = false;
bool got_password_store_results_ = false; bool got_password_store_results_ = false;
HttpPasswordMigrationMode mode_ = HttpPasswordMigrationMode::kMove; HttpPasswordMigrationMode mode_ = HttpPasswordMigrationMode::kMove;
std::vector<std::unique_ptr<autofill::PasswordForm>> results_; std::vector<std::unique_ptr<PasswordForm>> results_;
url::Origin http_origin_domain_; url::Origin http_origin_domain_;
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
namespace password_manager { namespace password_manager {
namespace { namespace {
using autofill::PasswordForm;
using testing::_; using testing::_;
using testing::ElementsAre; using testing::ElementsAre;
using testing::Invoke; using testing::Invoke;
...@@ -78,16 +77,14 @@ PasswordForm CreateLocalFederatedCredential() { ...@@ -78,16 +77,14 @@ PasswordForm CreateLocalFederatedCredential() {
class MockConsumer : public HttpPasswordStoreMigrator::Consumer { class MockConsumer : public HttpPasswordStoreMigrator::Consumer {
public: public:
MOCK_METHOD1(ProcessForms, MOCK_METHOD1(ProcessForms, void(const std::vector<PasswordForm*>& forms));
void(const std::vector<autofill::PasswordForm*>& forms));
void ProcessMigratedForms( void ProcessMigratedForms(
std::vector<std::unique_ptr<autofill::PasswordForm>> forms) override { std::vector<std::unique_ptr<PasswordForm>> forms) override {
std::vector<autofill::PasswordForm*> raw_forms(forms.size()); std::vector<PasswordForm*> raw_forms(forms.size());
std::transform(forms.begin(), forms.end(), raw_forms.begin(), std::transform(
[](const std::unique_ptr<autofill::PasswordForm>& form) { forms.begin(), forms.end(), raw_forms.begin(),
return form.get(); [](const std::unique_ptr<PasswordForm>& form) { return form.get(); });
});
ProcessForms(raw_forms); ProcessForms(raw_forms);
} }
}; };
...@@ -153,9 +150,9 @@ void HttpPasswordStoreMigratorTest::TestEmptyStore(bool is_hsts) { ...@@ -153,9 +150,9 @@ void HttpPasswordStoreMigratorTest::TestEmptyStore(bool is_hsts) {
.Times(is_hsts); .Times(is_hsts);
WaitForPasswordStore(); WaitForPasswordStore();
EXPECT_CALL(consumer(), ProcessForms(std::vector<autofill::PasswordForm*>())); EXPECT_CALL(consumer(), ProcessForms(std::vector<PasswordForm*>()));
migrator.OnGetPasswordStoreResults( migrator.OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>>()); std::vector<std::unique_ptr<PasswordForm>>());
} }
void HttpPasswordStoreMigratorTest::TestFullStore(bool is_hsts) { void HttpPasswordStoreMigratorTest::TestFullStore(bool is_hsts) {
...@@ -195,7 +192,7 @@ void HttpPasswordStoreMigratorTest::TestFullStore(bool is_hsts) { ...@@ -195,7 +192,7 @@ void HttpPasswordStoreMigratorTest::TestFullStore(bool is_hsts) {
EXPECT_CALL(consumer(), EXPECT_CALL(consumer(),
ProcessForms(ElementsAre(Pointee(expected_form), ProcessForms(ElementsAre(Pointee(expected_form),
Pointee(expected_federated_form)))); Pointee(expected_federated_form))));
std::vector<std::unique_ptr<autofill::PasswordForm>> results; std::vector<std::unique_ptr<PasswordForm>> results;
results.push_back(std::make_unique<PasswordForm>(psl_form)); results.push_back(std::make_unique<PasswordForm>(psl_form));
results.push_back(std::make_unique<PasswordForm>(form)); results.push_back(std::make_unique<PasswordForm>(form));
results.push_back(std::make_unique<PasswordForm>(android_form)); results.push_back(std::make_unique<PasswordForm>(android_form));
...@@ -226,7 +223,7 @@ void HttpPasswordStoreMigratorTest::TestMigratorDeletionByConsumer( ...@@ -226,7 +223,7 @@ void HttpPasswordStoreMigratorTest::TestMigratorDeletionByConsumer(
})); }));
migrator->OnGetPasswordStoreResults( migrator->OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>>()); std::vector<std::unique_ptr<PasswordForm>>());
// We expect a potential call to |RemoveSiteStatsImpl| which is a async task // We expect a potential call to |RemoveSiteStatsImpl| which is a async task
// posted from |PasswordStore::RemoveSiteStats|. Hence the following lines are // posted from |PasswordStore::RemoveSiteStats|. Hence the following lines are
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment