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 @@
#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/statistics_table.h"
using autofill::PasswordForm;
namespace password_manager {
FakeFormFetcher::FakeFormFetcher() = default;
......
......@@ -9,14 +9,10 @@
#include "base/macros.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/password_form.h"
#include "components/password_manager/core/browser/statistics_table.h"
namespace autofill {
struct PasswordForm;
}
namespace password_manager {
struct InteractionsStats;
......@@ -46,18 +42,15 @@ class FakeFormFetcher : public FormFetcher {
const std::vector<InteractionsStats>& GetInteractionsStats() const override;
base::span<const CompromisedCredentials> GetCompromisedCredentials()
const override;
std::vector<const autofill::PasswordForm*> GetNonFederatedMatches()
const override;
std::vector<const autofill::PasswordForm*> GetFederatedMatches()
const override;
std::vector<const PasswordForm*> GetNonFederatedMatches() const override;
std::vector<const PasswordForm*> GetFederatedMatches() const override;
bool IsBlacklisted() const override;
bool IsMovingBlocked(const autofill::GaiaIdHash& destination,
const base::string16& username) const override;
const std::vector<const autofill::PasswordForm*>& GetAllRelevantMatches()
const override;
const std::vector<const autofill::PasswordForm*>& GetBestMatches()
const std::vector<const PasswordForm*>& GetAllRelevantMatches()
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.
std::unique_ptr<FormFetcher> Clone() override;
......@@ -66,10 +59,9 @@ class FakeFormFetcher : public FormFetcher {
stats_ = stats;
}
void set_scheme(autofill::PasswordForm::Scheme scheme) { scheme_ = scheme; }
void set_scheme(PasswordForm::Scheme scheme) { scheme_ = scheme; }
void set_federated(
const std::vector<const autofill::PasswordForm*>& federated) {
void set_federated(const std::vector<const PasswordForm*>& federated) {
state_ = State::NOT_WAITING;
federated_ = federated;
}
......@@ -78,8 +70,7 @@ class FakeFormFetcher : public FormFetcher {
compromised_ = compromised;
}
void SetNonFederated(
const std::vector<const autofill::PasswordForm*>& non_federated);
void SetNonFederated(const std::vector<const PasswordForm*>& non_federated);
void SetBlacklisted(bool is_blacklisted);
......@@ -88,15 +79,14 @@ class FakeFormFetcher : public FormFetcher {
private:
base::ObserverList<Consumer> consumers_;
State state_ = State::NOT_WAITING;
autofill::PasswordForm::Scheme scheme_ =
autofill::PasswordForm::Scheme::kHtml;
PasswordForm::Scheme scheme_ = PasswordForm::Scheme::kHtml;
std::vector<InteractionsStats> stats_;
std::vector<const autofill::PasswordForm*> non_federated_;
std::vector<const autofill::PasswordForm*> federated_;
std::vector<const autofill::PasswordForm*> non_federated_same_scheme_;
std::vector<const autofill::PasswordForm*> best_matches_;
std::vector<const PasswordForm*> non_federated_;
std::vector<const PasswordForm*> federated_;
std::vector<const PasswordForm*> non_federated_same_scheme_;
std::vector<const PasswordForm*> best_matches_;
std::vector<CompromisedCredentials> compromised_;
const autofill::PasswordForm* preferred_match_ = nullptr;
const PasswordForm* preferred_match_ = nullptr;
bool is_blacklisted_ = false;
DISALLOW_COPY_AND_ASSIGN(FakeFormFetcher);
......
......@@ -41,7 +41,7 @@ autofill::ServerFieldType FieldInfoManagerImpl::GetFieldType(
}
void FieldInfoManagerImpl::OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> results) {
std::vector<std::unique_ptr<PasswordForm>> results) {
NOTREACHED();
}
......
......@@ -10,6 +10,7 @@
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/common/signatures.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"
namespace password_manager {
......@@ -50,7 +51,7 @@ class FieldInfoManagerImpl : public FieldInfoManager,
private:
// PasswordStoreConsumer:
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;
std::map<std::pair<autofill::FormSignature, autofill::FieldSignature>,
......
......@@ -13,10 +13,7 @@
#include "base/observer_list_types.h"
#include "base/strings/string16.h"
#include "components/autofill/core/common/gaia_id_hash.h"
namespace autofill {
struct PasswordForm;
}
#include "components/password_manager/core/browser/password_form_forward.h"
namespace password_manager {
......@@ -74,13 +71,11 @@ class FormFetcher {
// Non-federated matches obtained from the backend. Valid only if GetState()
// returns NOT_WAITING.
virtual std::vector<const autofill::PasswordForm*> GetNonFederatedMatches()
const = 0;
virtual std::vector<const PasswordForm*> GetNonFederatedMatches() const = 0;
// Federated matches obtained from the backend. Valid only if GetState()
// returns NOT_WAITING.
virtual std::vector<const autofill::PasswordForm*> GetFederatedMatches()
const = 0;
virtual std::vector<const PasswordForm*> GetFederatedMatches() const = 0;
// Whether there are blacklisted matches in the backend. Valid only if
// GetState() returns NOT_WAITING.
......@@ -95,15 +90,14 @@ class FormFetcher {
// Non-federated matches obtained from the backend that have the same scheme
// of this form.
virtual const std::vector<const autofill::PasswordForm*>&
GetAllRelevantMatches() const = 0;
virtual const std::vector<const PasswordForm*>& GetAllRelevantMatches()
const = 0;
// Nonblacklisted matches obtained from the backend.
virtual const std::vector<const autofill::PasswordForm*>& GetBestMatches()
const = 0;
virtual const std::vector<const PasswordForm*>& GetBestMatches() const = 0;
// 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
// need for calling Fetch().
......
......@@ -10,10 +10,10 @@
#include <utility>
#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/credentials_filter.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_util.h"
#include "components/password_manager/core/browser/password_store.h"
......@@ -21,8 +21,6 @@
#include "components/password_manager/core/browser/statistics_table.h"
#include "components/password_manager/core/common/password_manager_features.h"
using autofill::PasswordForm;
using Logger = autofill::SavePasswordProgressLogger;
namespace password_manager {
......@@ -73,9 +71,9 @@ FormFetcherImpl::FormFetcherImpl(PasswordStore::FormDigest form_digest,
bool should_migrate_http_passwords)
: form_digest_(std::move(form_digest)),
client_(client),
should_migrate_http_passwords_(
should_migrate_http_passwords &&
form_digest_.scheme == autofill::PasswordForm::Scheme::kHtml) {}
should_migrate_http_passwords_(should_migrate_http_passwords &&
form_digest_.scheme ==
PasswordForm::Scheme::kHtml) {}
FormFetcherImpl::~FormFetcherImpl() = default;
......
......@@ -53,29 +53,25 @@ class FormFetcherImpl : public FormFetcher,
const std::vector<InteractionsStats>& GetInteractionsStats() const override;
base::span<const CompromisedCredentials> GetCompromisedCredentials()
const override;
std::vector<const autofill::PasswordForm*> GetNonFederatedMatches()
const override;
std::vector<const autofill::PasswordForm*> GetFederatedMatches()
const override;
std::vector<const PasswordForm*> GetNonFederatedMatches() const override;
std::vector<const PasswordForm*> GetFederatedMatches() const override;
bool IsBlacklisted() const override;
bool IsMovingBlocked(const autofill::GaiaIdHash& destination,
const base::string16& username) const override;
const std::vector<const autofill::PasswordForm*>& GetAllRelevantMatches()
const override;
const std::vector<const autofill::PasswordForm*>& GetBestMatches()
const std::vector<const PasswordForm*>& GetAllRelevantMatches()
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;
protected:
// Processes password form results and forwards them to the |consumers_|.
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_|.
virtual void SplitResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> results);
virtual void SplitResults(std::vector<std::unique_ptr<PasswordForm>> results);
// PasswordStore results will be fetched for this description.
const PasswordStore::FormDigest form_digest_;
......@@ -91,12 +87,12 @@ class FormFetcherImpl : public FormFetcher,
bool need_to_refetch_ = false;
// 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
// filled not saved by PasswordFormManager, so they are kept separately from
// 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.
std::vector<CompromisedCredentials> compromised_credentials_;
......@@ -108,12 +104,12 @@ class FormFetcherImpl : public FormFetcher,
private:
// PasswordStoreConsumer:
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;
// HttpPasswordStoreMigrator::Consumer:
void ProcessMigratedForms(
std::vector<std::unique_ptr<autofill::PasswordForm>> forms) override;
std::vector<std::unique_ptr<PasswordForm>> forms) override;
// CompromisedCredentialsConsumer:
void OnGetCompromisedCredentials(
......@@ -123,17 +119,17 @@ class FormFetcherImpl : public FormFetcher,
std::unique_ptr<HttpPasswordStoreMigrator> http_migrator_;
// 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
// 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
// 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
// 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
// store.
......
......@@ -17,9 +17,9 @@
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.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/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_store.h"
#include "components/password_manager/core/browser/statistics_table.h"
......@@ -33,7 +33,6 @@
#include "url/origin.h"
#include "url/url_constants.h"
using autofill::PasswordForm;
using base::ASCIIToUTF16;
using base::StringPiece;
using testing::_;
......
......@@ -12,7 +12,7 @@
#include "base/macros.h"
#include "base/optional.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"
namespace password_manager {
......@@ -27,7 +27,7 @@ class FormSaver {
// Blacklist the origin described by |digest|. Returns the PasswordForm pushed
// to the store.
virtual autofill::PasswordForm PermanentlyBlacklist(
virtual PasswordForm PermanentlyBlacklist(
PasswordStore::FormDigest digest) = 0;
// Unblacklist the origin described by |digest| by deleting all corresponding
......@@ -41,16 +41,16 @@ class FormSaver {
// - empty-username credentials with the same password are removed.
// - if |old_password| is provided, the old credentials with the same username
// and the old password are updated to the new password.
virtual void Save(autofill::PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches,
virtual void Save(PasswordForm pending,
const std::vector<const PasswordForm*>& matches,
const base::string16& old_password) = 0;
// Updates the saved credential in the password store sharing the same key as
// the |pending| form.
// The algorithm for handling |matches| and |old_password| is the same as
// above.
virtual void Update(autofill::PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches,
virtual void Update(PasswordForm pending,
const std::vector<const PasswordForm*>& matches,
const base::string16& old_password) = 0;
// If any of the unique key fields (signon_realm, origin, username_element,
......@@ -59,14 +59,13 @@ class FormSaver {
// 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
// above.
virtual void UpdateReplace(
autofill::PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches,
const base::string16& old_password,
const autofill::PasswordForm& old_unique_key) = 0;
virtual void UpdateReplace(PasswordForm pending,
const std::vector<const PasswordForm*>& matches,
const base::string16& old_password,
const PasswordForm& old_unique_key) = 0;
// 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|.
virtual std::unique_ptr<FormSaver> Clone() = 0;
......
......@@ -19,7 +19,6 @@
using autofill::FormData;
using autofill::FormFieldData;
using autofill::PasswordForm;
namespace password_manager {
......@@ -106,10 +105,9 @@ void FormSaverImpl::Save(PasswordForm pending,
PostProcessMatches(pending, matches, old_password, store_);
}
void FormSaverImpl::Update(
autofill::PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches,
const base::string16& old_password) {
void FormSaverImpl::Update(PasswordForm pending,
const std::vector<const PasswordForm*>& matches,
const base::string16& old_password) {
SanitizeFormData(&pending.form_data);
store_->UpdateLogin(pending);
// Update existing matches in the password store.
......@@ -117,10 +115,10 @@ void FormSaverImpl::Update(
}
void FormSaverImpl::UpdateReplace(
autofill::PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches,
PasswordForm pending,
const std::vector<const PasswordForm*>& matches,
const base::string16& old_password,
const autofill::PasswordForm& old_unique_key) {
const PasswordForm& old_unique_key) {
SanitizeFormData(&pending.form_data);
store_->UpdateLoginWithPrimaryKey(pending, old_unique_key);
// Update existing matches in the password store.
......
......@@ -24,20 +24,19 @@ class FormSaverImpl : public FormSaver {
~FormSaverImpl() override;
// FormSaver:
autofill::PasswordForm PermanentlyBlacklist(
PasswordStore::FormDigest digest) override;
PasswordForm PermanentlyBlacklist(PasswordStore::FormDigest digest) override;
void Unblacklist(const PasswordStore::FormDigest& digest) override;
void Save(autofill::PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches,
void Save(PasswordForm pending,
const std::vector<const PasswordForm*>& matches,
const base::string16& old_password) override;
void Update(autofill::PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches,
void Update(PasswordForm pending,
const std::vector<const PasswordForm*>& matches,
const base::string16& old_password) override;
void UpdateReplace(autofill::PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches,
void UpdateReplace(PasswordForm pending,
const std::vector<const PasswordForm*>& matches,
const base::string16& old_password,
const autofill::PasswordForm& old_unique_key) override;
void Remove(const autofill::PasswordForm& form) override;
const PasswordForm& old_unique_key) override;
void Remove(const PasswordForm& form) override;
std::unique_ptr<FormSaver> Clone() override;
private:
......
......@@ -14,15 +14,14 @@
#include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversions.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/password_form.h"
#include "components/password_manager/core/browser/password_manager_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
using autofill::FormFieldData;
using autofill::PasswordForm;
using base::ASCIIToUTF16;
using base::StringPiece;
using testing::_;
......@@ -89,14 +88,14 @@ class FormSaverImplSaveTest
public ::testing::WithParamInterface<SaveOperation> {
protected:
// Either saves, updates or replaces |pending| according to the test param.
void SaveCredential(autofill::PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches,
void SaveCredential(PasswordForm pending,
const std::vector<const PasswordForm*>& matches,
const base::string16& old_password);
};
void FormSaverImplSaveTest::SaveCredential(
autofill::PasswordForm pending,
const std::vector<const autofill::PasswordForm*>& matches,
PasswordForm pending,
const std::vector<const PasswordForm*>& matches,
const base::string16& old_password) {
switch (GetParam()) {
case SaveOperation::kSave:
......
......@@ -5,8 +5,8 @@
#ifndef 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/password_form_forward.h"
namespace password_manager {
......@@ -26,7 +26,7 @@ class HttpAuthManager {
// Set the observer which is notified in case a form can be auto-filled.
virtual void SetObserverAndDeliverCredentials(
HttpAuthObserver* observer,
const autofill::PasswordForm& observed_form) = 0;
const PasswordForm& observed_form) = 0;
// Detach |observer| as the observer if it is the current observer.
// Called by the observer when destructed to unregister itself.
......@@ -34,8 +34,7 @@ class HttpAuthManager {
// Handles submitted http-auth credentials event.
// Called by the LoginHandler instance.
virtual void OnPasswordFormSubmitted(
const autofill::PasswordForm& password_form) = 0;
virtual void OnPasswordFormSubmitted(const PasswordForm& password_form) = 0;
// Called by the LoginHandler instance when the password form is dismissed.
virtual void OnPasswordFormDismissed() = 0;
......
......@@ -6,16 +6,14 @@
#include <utility>
#include "components/autofill/core/common/password_form.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_for_ui.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_save_manager_impl.h"
using autofill::PasswordForm;
namespace password_manager {
namespace {
......
......@@ -10,10 +10,10 @@
#include <string>
#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/http_auth_manager.h"
#include "components/password_manager/core/browser/http_auth_observer.h"
#include "components/password_manager/core/browser/password_form_forward.h"
namespace password_manager {
......@@ -28,24 +28,23 @@ class HttpAuthManagerImpl : public HttpAuthManager {
HttpAuthManagerImpl(PasswordManagerClient* client,
HttpAuthObserver* observer,
const autofill::PasswordForm& observed_form);
const PasswordForm& observed_form);
~HttpAuthManagerImpl() override;
// HttpAuthManager:
void SetObserverAndDeliverCredentials(
HttpAuthObserver* observer,
const autofill::PasswordForm& observed_form) override;
const PasswordForm& observed_form) override;
void DetachObserver(HttpAuthObserver* observer) override;
void OnPasswordFormSubmitted(
const autofill::PasswordForm& password_form) override;
void OnPasswordFormSubmitted(const PasswordForm& password_form) override;
void OnPasswordFormDismissed() override;
// Called by a PasswordManagerClient when it decides that a HTTP auth dialog
// 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
// 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;
// Handles successful navigation to the main frame.
......@@ -57,7 +56,7 @@ class HttpAuthManagerImpl : public HttpAuthManager {
// Passes |form| to PasswordFormManager that manages it for using it after
// detecting submission success for saving.
void ProvisionallySaveForm(const autofill::PasswordForm& password_form);
void ProvisionallySaveForm(const PasswordForm& password_form);
// Initiates the saving of the password.
void OnLoginSuccesfull();
......
......@@ -31,8 +31,6 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using autofill::PasswordForm;
using base::ASCIIToUTF16;
using base::TestMockTimeTaskRunner;
using testing::_;
......@@ -53,8 +51,7 @@ class MockPasswordManagerClient : public StubPasswordManagerClient {
MOCK_CONST_METHOD1(IsSavingAndFillingEnabled, bool(const GURL&));
MOCK_CONST_METHOD1(IsFillingEnabled, bool(const GURL&));
MOCK_METHOD2(AutofillHttpAuth,
void(const autofill::PasswordForm&,
const PasswordFormManagerForUI*));
void(const PasswordForm&, const PasswordFormManagerForUI*));
MOCK_CONST_METHOD0(GetProfilePasswordStore, PasswordStore*());
MOCK_CONST_METHOD0(GetAccountPasswordStore, PasswordStore*());
MOCK_METHOD0(PromptUserToSaveOrUpdatePasswordPtr, void());
......
......@@ -9,7 +9,6 @@
#include "base/macros.h"
#include "base/strings/string16.h"
#include "components/autofill/core/common/password_form.h"
namespace password_manager {
......
......@@ -39,7 +39,7 @@ void HttpCredentialCleaner::StartCleaning(Observer* observer) {
}
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
// federated credentials.
for (auto& form : RemoveNonHTTPOrHTTPSForms(std::move(results))) {
......@@ -64,7 +64,7 @@ void HttpCredentialCleaner::OnGetPasswordStoreResults(
}
void HttpCredentialCleaner::OnHSTSQueryResult(
std::unique_ptr<autofill::PasswordForm> form,
std::unique_ptr<PasswordForm> form,
FormKey key,
HSTSResult hsts_result) {
++processed_results_;
......
......@@ -14,9 +14,9 @@
#include "base/containers/flat_set.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/hsts_query.h"
#include "components/password_manager/core/browser/password_form.h"
#include "components/password_manager/core/browser/password_store_consumer.h"
namespace network {
......@@ -77,19 +77,18 @@ class HttpCredentialCleaner : public PasswordStoreConsumer,
// signon-realm excluding the protocol, the second argument is
// the PasswordForm::scheme (i.e. HTML, BASIC, etc.) and the third argument is
// the username of the form.
using FormKey =
std::tuple<std::string, autofill::PasswordForm::Scheme, base::string16>;
using FormKey = std::tuple<std::string, PasswordForm::Scheme, base::string16>;
// PasswordStoreConsumer:
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
// host has HSTS enabled. |key| is |form|'s encoding which is used for
// matching |form| with an HTTPS credential with the same FormKey.
// Inside the function the metric counters are updated and, if needed, the
// |form| is removed or migrated to HTTPS.
void OnHSTSQueryResult(std::unique_ptr<autofill::PasswordForm> form,
void OnHSTSQueryResult(std::unique_ptr<PasswordForm> form,
FormKey key,
HSTSResult hsts_result);
......
......@@ -35,7 +35,7 @@ enum class HttpCredentialType { kConflicting, kEquivalent, kNoMatching };
struct TestCase {
bool is_hsts_enabled;
autofill::PasswordForm::Scheme http_form_scheme;
PasswordForm::Scheme http_form_scheme;
bool same_signon_realm;
bool same_scheme;
bool same_username;
......@@ -54,48 +54,48 @@ struct TestCase {
constexpr static TestCase kCases[] = {
{true, autofill::PasswordForm::Scheme::kHtml, false, true, true, true,
{true, PasswordForm::Scheme::kHtml, false, true, true, true,
HttpCredentialType::kNoMatching},
{true, autofill::PasswordForm::Scheme::kHtml, true, false, true, true,
{true, PasswordForm::Scheme::kHtml, true, false, true, true,
HttpCredentialType::kNoMatching},
{true, autofill::PasswordForm::Scheme::kHtml, true, true, false, true,
{true, PasswordForm::Scheme::kHtml, true, true, false, true,
HttpCredentialType::kNoMatching},
{true, autofill::PasswordForm::Scheme::kHtml, true, true, true, false,
{true, PasswordForm::Scheme::kHtml, true, true, true, false,
HttpCredentialType::kConflicting},
{true, autofill::PasswordForm::Scheme::kHtml, true, true, true, true,
{true, PasswordForm::Scheme::kHtml, true, true, true, true,
HttpCredentialType::kEquivalent},
{false, autofill::PasswordForm::Scheme::kHtml, false, true, true, true,
{false, PasswordForm::Scheme::kHtml, false, true, true, true,
HttpCredentialType::kNoMatching},
{false, autofill::PasswordForm::Scheme::kHtml, true, false, true, true,
{false, PasswordForm::Scheme::kHtml, true, false, true, true,
HttpCredentialType::kNoMatching},
{false, autofill::PasswordForm::Scheme::kHtml, true, true, false, true,
{false, PasswordForm::Scheme::kHtml, true, true, false, true,
HttpCredentialType::kNoMatching},
{false, autofill::PasswordForm::Scheme::kHtml, true, true, true, false,
{false, PasswordForm::Scheme::kHtml, true, true, true, false,
HttpCredentialType::kConflicting},
{false, autofill::PasswordForm::Scheme::kHtml, true, true, true, true,
{false, PasswordForm::Scheme::kHtml, true, true, true, true,
HttpCredentialType::kEquivalent},
{true, autofill::PasswordForm::Scheme::kBasic, false, true, true, true,
{true, PasswordForm::Scheme::kBasic, false, true, true, true,
HttpCredentialType::kNoMatching},
{true, autofill::PasswordForm::Scheme::kBasic, true, false, true, true,
{true, PasswordForm::Scheme::kBasic, true, false, true, true,
HttpCredentialType::kNoMatching},
{true, autofill::PasswordForm::Scheme::kBasic, true, true, false, true,
{true, PasswordForm::Scheme::kBasic, true, true, false, true,
HttpCredentialType::kNoMatching},
{true, autofill::PasswordForm::Scheme::kBasic, true, true, true, false,
{true, PasswordForm::Scheme::kBasic, true, true, true, false,
HttpCredentialType::kConflicting},
{true, autofill::PasswordForm::Scheme::kBasic, true, true, true, true,
{true, PasswordForm::Scheme::kBasic, true, true, true, true,
HttpCredentialType::kEquivalent},
{false, autofill::PasswordForm::Scheme::kBasic, false, true, true, true,
{false, PasswordForm::Scheme::kBasic, false, true, true, true,
HttpCredentialType::kNoMatching},
{false, autofill::PasswordForm::Scheme::kBasic, true, false, true, true,
{false, PasswordForm::Scheme::kBasic, true, false, true, true,
HttpCredentialType::kNoMatching},
{false, autofill::PasswordForm::Scheme::kBasic, true, true, false, true,
{false, PasswordForm::Scheme::kBasic, true, true, false, true,
HttpCredentialType::kNoMatching},
{false, autofill::PasswordForm::Scheme::kBasic, true, true, true, false,
{false, PasswordForm::Scheme::kBasic, true, true, true, false,
HttpCredentialType::kConflicting},
{false, autofill::PasswordForm::Scheme::kBasic, true, true, true, true,
{false, PasswordForm::Scheme::kBasic, true, true, true, true,
HttpCredentialType::kEquivalent}};
} // namespace
......@@ -151,7 +151,7 @@ TEST_P(HttpCredentialCleanerTest, ReportHttpMigrationMetrics) {
<< ", same_username=" << test.same_username
<< ", same_password=" << test.same_password);
autofill::PasswordForm http_form;
PasswordForm http_form;
http_form.url = GURL("http://example.org/");
http_form.signon_realm = "http://example.org/";
http_form.scheme = test.http_form_scheme;
......@@ -159,17 +159,16 @@ TEST_P(HttpCredentialCleanerTest, ReportHttpMigrationMetrics) {
http_form.password_value = password[1];
store_->AddLogin(http_form);
autofill::PasswordForm https_form;
PasswordForm https_form;
https_form.url = GURL("https://example.org/");
https_form.signon_realm = signon_realm[test.same_signon_realm];
https_form.username_value = username[test.same_username];
https_form.password_value = password[test.same_password];
https_form.scheme = test.http_form_scheme;
if (!test.same_scheme) {
https_form.scheme =
(http_form.scheme == autofill::PasswordForm::Scheme::kBasic
? autofill::PasswordForm::Scheme::kHtml
: autofill::PasswordForm::Scheme::kBasic);
https_form.scheme = (http_form.scheme == PasswordForm::Scheme::kBasic
? PasswordForm::Scheme::kHtml
: PasswordForm::Scheme::kBasic);
}
store_->AddLogin(https_form);
......
......@@ -48,7 +48,7 @@ HttpPasswordStoreMigrator::HttpPasswordStoreMigrator(
GURL::Replacements rep;
rep.SetSchemeStr(url::kHttpScheme);
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_domain_ = url::Origin::Create(http_origin);
store_->GetLogins(form, this);
......@@ -60,11 +60,11 @@ HttpPasswordStoreMigrator::HttpPasswordStoreMigrator(
HttpPasswordStoreMigrator::~HttpPasswordStoreMigrator() = default;
autofill::PasswordForm HttpPasswordStoreMigrator::MigrateHttpFormToHttps(
const autofill::PasswordForm& http_form) {
PasswordForm HttpPasswordStoreMigrator::MigrateHttpFormToHttps(
const PasswordForm& http_form) {
DCHECK(http_form.url.SchemeIs(url::kHttpScheme));
autofill::PasswordForm https_form = http_form;
PasswordForm https_form = http_form;
GURL::Replacements rep;
rep.SetSchemeStr(url::kHttpsScheme);
https_form.url = http_form.url.ReplaceComponents(rep);
......@@ -83,13 +83,13 @@ autofill::PasswordForm HttpPasswordStoreMigrator::MigrateHttpFormToHttps(
https_form.action = https_form.url;
https_form.form_data = autofill::FormData();
https_form.generation_upload_status =
autofill::PasswordForm::GenerationUploadStatus::kNoSignalSent;
PasswordForm::GenerationUploadStatus::kNoSignalSent;
https_form.skip_zero_click = false;
return https_form;
}
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_);
results_ = std::move(results);
got_password_store_results_ = true;
......@@ -113,15 +113,14 @@ void HttpPasswordStoreMigrator::OnHSTSQueryResult(HSTSResult is_hsts) {
void HttpPasswordStoreMigrator::ProcessPasswordStoreResults() {
// Android and PSL matches are ignored.
base::EraseIf(
results_, [](const std::unique_ptr<autofill::PasswordForm>& form) {
return form->is_affiliation_based_match || form->is_public_suffix_match;
});
base::EraseIf(results_, [](const std::unique_ptr<PasswordForm>& form) {
return form->is_affiliation_based_match || form->is_public_suffix_match;
});
// Add the new credentials to the password store. The HTTP forms are
// removed iff |mode_| == MigrationMode::MOVE.
for (const auto& form : results_) {
autofill::PasswordForm new_form =
PasswordForm new_form =
HttpPasswordStoreMigrator::MigrateHttpFormToHttps(*form);
store_->AddLogin(new_form);
......
......@@ -11,13 +11,10 @@
#include "base/macros.h"
#include "base/sequence_checker.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 "url/origin.h"
namespace autofill {
struct PasswordForm;
}
namespace password_manager {
// These values are persisted to logs. Entries should not be renumbered and
......@@ -51,7 +48,7 @@ class HttpPasswordStoreMigrator : public PasswordStoreConsumer {
// Notify the embedder that |forms| were migrated to HTTPS. |forms| contain
// the updated HTTPS scheme.
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.
......@@ -62,12 +59,11 @@ class HttpPasswordStoreMigrator : public PasswordStoreConsumer {
~HttpPasswordStoreMigrator() override;
// Creates HTTPS version of |http_form|.
static autofill::PasswordForm MigrateHttpFormToHttps(
const autofill::PasswordForm& http_form);
static PasswordForm MigrateHttpFormToHttps(const PasswordForm& http_form);
// PasswordStoreConsumer:
void OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> results) override;
std::vector<std::unique_ptr<PasswordForm>> results) override;
// Callback for PostHSTSQueryForHostAndNetworkContext.
void OnHSTSQueryResult(HSTSResult is_hsts);
......@@ -85,7 +81,7 @@ class HttpPasswordStoreMigrator : public PasswordStoreConsumer {
bool got_hsts_query_result_ = false;
bool got_password_store_results_ = false;
HttpPasswordMigrationMode mode_ = HttpPasswordMigrationMode::kMove;
std::vector<std::unique_ptr<autofill::PasswordForm>> results_;
std::vector<std::unique_ptr<PasswordForm>> results_;
url::Origin http_origin_domain_;
SEQUENCE_CHECKER(sequence_checker_);
......
......@@ -16,7 +16,6 @@
namespace password_manager {
namespace {
using autofill::PasswordForm;
using testing::_;
using testing::ElementsAre;
using testing::Invoke;
......@@ -78,16 +77,14 @@ PasswordForm CreateLocalFederatedCredential() {
class MockConsumer : public HttpPasswordStoreMigrator::Consumer {
public:
MOCK_METHOD1(ProcessForms,
void(const std::vector<autofill::PasswordForm*>& forms));
MOCK_METHOD1(ProcessForms, void(const std::vector<PasswordForm*>& forms));
void ProcessMigratedForms(
std::vector<std::unique_ptr<autofill::PasswordForm>> forms) override {
std::vector<autofill::PasswordForm*> raw_forms(forms.size());
std::transform(forms.begin(), forms.end(), raw_forms.begin(),
[](const std::unique_ptr<autofill::PasswordForm>& form) {
return form.get();
});
std::vector<std::unique_ptr<PasswordForm>> forms) override {
std::vector<PasswordForm*> raw_forms(forms.size());
std::transform(
forms.begin(), forms.end(), raw_forms.begin(),
[](const std::unique_ptr<PasswordForm>& form) { return form.get(); });
ProcessForms(raw_forms);
}
};
......@@ -153,9 +150,9 @@ void HttpPasswordStoreMigratorTest::TestEmptyStore(bool is_hsts) {
.Times(is_hsts);
WaitForPasswordStore();
EXPECT_CALL(consumer(), ProcessForms(std::vector<autofill::PasswordForm*>()));
EXPECT_CALL(consumer(), ProcessForms(std::vector<PasswordForm*>()));
migrator.OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>>());
std::vector<std::unique_ptr<PasswordForm>>());
}
void HttpPasswordStoreMigratorTest::TestFullStore(bool is_hsts) {
......@@ -195,7 +192,7 @@ void HttpPasswordStoreMigratorTest::TestFullStore(bool is_hsts) {
EXPECT_CALL(consumer(),
ProcessForms(ElementsAre(Pointee(expected_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>(form));
results.push_back(std::make_unique<PasswordForm>(android_form));
......@@ -226,7 +223,7 @@ void HttpPasswordStoreMigratorTest::TestMigratorDeletionByConsumer(
}));
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
// 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