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( ...@@ -127,15 +127,10 @@ void CredentialManagerPendingRequestTask::OnGetPasswordStoreResultsFrom(
scoped_refptr<PasswordStore> store, scoped_refptr<PasswordStore> store,
std::vector<std::unique_ptr<autofill::PasswordForm>> results) { std::vector<std::unique_ptr<autofill::PasswordForm>> results) {
// localhost is a secure origin but not https. // localhost is a secure origin but not https.
if (store.get() == delegate_->client()->GetProfilePasswordStore() && if (results.empty() && origin_.scheme() == url::kHttpsScheme) {
results.empty() && origin_.scheme() == url::kHttpsScheme) {
// TODO(crbug.com/1093286): Consider also supporting HTTP->HTTPS migration
// for the account store.
// Try to migrate the HTTP passwords and process them later. // Try to migrate the HTTP passwords and process them later.
http_migrator_ = std::make_unique<HttpPasswordStoreMigrator>( http_migrators_[store.get()] = std::make_unique<HttpPasswordStoreMigrator>(
origin_, delegate_->client()->GetProfilePasswordStore(), origin_, store.get(), delegate_->client()->GetNetworkContext(), this);
delegate_->client()->GetNetworkContext(), this);
return; return;
} }
AggregatePasswordStoreResults(std::move(results)); AggregatePasswordStoreResults(std::move(results));
......
...@@ -102,7 +102,8 @@ class CredentialManagerPendingRequestTask ...@@ -102,7 +102,8 @@ class CredentialManagerPendingRequestTask
// then all results are processed. // then all results are processed.
std::vector<std::unique_ptr<autofill::PasswordForm>> partial_results_; 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); DISALLOW_COPY_AND_ASSIGN(CredentialManagerPendingRequestTask);
}; };
......
...@@ -101,9 +101,6 @@ class FormFetcherImpl : public FormFetcher, ...@@ -101,9 +101,6 @@ class FormFetcherImpl : public FormFetcher,
// Indicates whether HTTP passwords should be migrated to HTTPS. // Indicates whether HTTP passwords should be migrated to HTTPS.
const bool should_migrate_http_passwords_; const bool should_migrate_http_passwords_;
// Does the actual migration.
std::unique_ptr<HttpPasswordStoreMigrator> http_migrator_;
private: private:
// PasswordStoreConsumer: // PasswordStoreConsumer:
void OnGetPasswordStoreResults( void OnGetPasswordStoreResults(
...@@ -118,6 +115,9 @@ class FormFetcherImpl : public FormFetcher, ...@@ -118,6 +115,9 @@ class FormFetcherImpl : public FormFetcher,
void OnGetCompromisedCredentials( void OnGetCompromisedCredentials(
std::vector<CompromisedCredentials> compromised_credentials) override; 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. // Non-federated credentials of the same scheme as the observed form.
std::vector<const autofill::PasswordForm*> non_federated_same_scheme_; std::vector<const autofill::PasswordForm*> non_federated_same_scheme_;
......
...@@ -113,14 +113,11 @@ void MultiStoreFormFetcher::OnGetPasswordStoreResultsFrom( ...@@ -113,14 +113,11 @@ void MultiStoreFormFetcher::OnGetPasswordStoreResultsFrom(
DCHECK_EQ(State::WAITING, state_); DCHECK_EQ(State::WAITING, state_);
DCHECK_GT(wait_counter_, 0); DCHECK_GT(wait_counter_, 0);
if (store.get() == client_->GetProfilePasswordStore() && if (should_migrate_http_passwords_ && results.empty() &&
should_migrate_http_passwords_ && results.empty() &&
form_digest_.url.SchemeIs(url::kHttpsScheme)) { form_digest_.url.SchemeIs(url::kHttpsScheme)) {
// TODO(crbug.com/1107741): Consider also supporting HTTP->HTTPS migration http_migrators_[store.get()] = std::make_unique<HttpPasswordStoreMigrator>(
// for the account store. url::Origin::Create(form_digest_.url), store.get(),
http_migrator_ = std::make_unique<HttpPasswordStoreMigrator>( client_->GetNetworkContext(), this);
url::Origin::Create(form_digest_.url),
client_->GetProfilePasswordStore(), client_->GetNetworkContext(), this);
// The migrator will call us back at ProcessMigratedForms(). // The migrator will call us back at ProcessMigratedForms().
return; return;
} }
......
...@@ -56,6 +56,9 @@ class MultiStoreFormFetcher : public FormFetcherImpl { ...@@ -56,6 +56,9 @@ class MultiStoreFormFetcher : public FormFetcherImpl {
int wait_counter_ = 0; int wait_counter_ = 0;
std::vector<std::unique_ptr<autofill::PasswordForm>> partial_results_; std::vector<std::unique_ptr<autofill::PasswordForm>> partial_results_;
base::flat_map<PasswordStore*, std::unique_ptr<HttpPasswordStoreMigrator>>
http_migrators_;
DISALLOW_COPY_AND_ASSIGN(MultiStoreFormFetcher); 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