Commit 39c30351 authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Passwords] Run HttpPasswordStoreMigrator against account store.

Before this CL:
HttpPasswordStoreMigrator was conditionally run against only the
profile store.

After this CL:
HttpPasswordStoreMigrator is run against both the profile and account
stores.

Bug: 1107741
Change-Id: Iadb17cc15884085f09dfbef78ed755d9b49869a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315895
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792799}
parent 71975fed
......@@ -127,15 +127,10 @@ void CredentialManagerPendingRequestTask::OnGetPasswordStoreResultsFrom(
scoped_refptr<PasswordStore> store,
std::vector<std::unique_ptr<autofill::PasswordForm>> results) {
// localhost is a secure origin but not https.
if (store.get() == delegate_->client()->GetProfilePasswordStore() &&
results.empty() && origin_.scheme() == url::kHttpsScheme) {
// TODO(crbug.com/1093286): Consider also supporting HTTP->HTTPS migration
// for the account store.
if (results.empty() && origin_.scheme() == url::kHttpsScheme) {
// Try to migrate the HTTP passwords and process them later.
http_migrator_ = std::make_unique<HttpPasswordStoreMigrator>(
origin_, delegate_->client()->GetProfilePasswordStore(),
delegate_->client()->GetNetworkContext(), this);
http_migrators_[store.get()] = std::make_unique<HttpPasswordStoreMigrator>(
origin_, store.get(), delegate_->client()->GetNetworkContext(), this);
return;
}
AggregatePasswordStoreResults(std::move(results));
......
......@@ -102,7 +102,8 @@ class CredentialManagerPendingRequestTask
// then all results are processed.
std::vector<std::unique_ptr<autofill::PasswordForm>> partial_results_;
std::unique_ptr<HttpPasswordStoreMigrator> http_migrator_;
base::flat_map<PasswordStore*, std::unique_ptr<HttpPasswordStoreMigrator>>
http_migrators_;
DISALLOW_COPY_AND_ASSIGN(CredentialManagerPendingRequestTask);
};
......
......@@ -101,9 +101,6 @@ class FormFetcherImpl : public FormFetcher,
// Indicates whether HTTP passwords should be migrated to HTTPS.
const bool should_migrate_http_passwords_;
// Does the actual migration.
std::unique_ptr<HttpPasswordStoreMigrator> http_migrator_;
private:
// PasswordStoreConsumer:
void OnGetPasswordStoreResults(
......@@ -118,6 +115,9 @@ class FormFetcherImpl : public FormFetcher,
void OnGetCompromisedCredentials(
std::vector<CompromisedCredentials> compromised_credentials) override;
// Does the actual migration.
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_;
......
......@@ -113,14 +113,11 @@ void MultiStoreFormFetcher::OnGetPasswordStoreResultsFrom(
DCHECK_EQ(State::WAITING, state_);
DCHECK_GT(wait_counter_, 0);
if (store.get() == client_->GetProfilePasswordStore() &&
should_migrate_http_passwords_ && results.empty() &&
if (should_migrate_http_passwords_ && results.empty() &&
form_digest_.url.SchemeIs(url::kHttpsScheme)) {
// TODO(crbug.com/1107741): Consider also supporting HTTP->HTTPS migration
// for the account store.
http_migrator_ = std::make_unique<HttpPasswordStoreMigrator>(
url::Origin::Create(form_digest_.url),
client_->GetProfilePasswordStore(), client_->GetNetworkContext(), this);
http_migrators_[store.get()] = std::make_unique<HttpPasswordStoreMigrator>(
url::Origin::Create(form_digest_.url), store.get(),
client_->GetNetworkContext(), this);
// The migrator will call us back at ProcessMigratedForms().
return;
}
......
......@@ -56,6 +56,9 @@ class MultiStoreFormFetcher : public FormFetcherImpl {
int wait_counter_ = 0;
std::vector<std::unique_ptr<autofill::PasswordForm>> partial_results_;
base::flat_map<PasswordStore*, std::unique_ptr<HttpPasswordStoreMigrator>>
http_migrators_;
DISALLOW_COPY_AND_ASSIGN(MultiStoreFormFetcher);
};
......
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