Commit 62223b1a authored by Ioana Pandele's avatar Ioana Pandele Committed by Commit Bot

Move the CredentialCache update to right when the fetch completes

Up until now, the CredentialCache was populated only when credentials
were ready to be autofilled into the form. The same information is
available slightly earlier, right after the credentials are fetched from the store.

Bug: 1044930
Change-Id: I64e8135b08014d97da249a189a4c199bf605b661
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2013286
Commit-Queue: Ioana Pandele <ioanap@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734922}
parent 4dc06dc8
......@@ -506,17 +506,20 @@ void ChromePasswordManagerClient::AutomaticPasswordSave(
#endif
}
void ChromePasswordManagerClient::PasswordWasAutofilled(
const std::vector<const PasswordForm*>& best_matches,
void ChromePasswordManagerClient::UpdateCredentialCache(
const GURL& origin,
const std::vector<const PasswordForm*>* federated_matches) {
const std::vector<const autofill::PasswordForm*>& best_matches) {
#if defined(OS_ANDROID)
if (!PasswordAccessoryController::AllowedForWebContents(web_contents())) {
return; // No need to even create the bridge if it's not going to be used.
}
credential_cache_.SaveCredentialsForOrigin(best_matches,
url::Origin::Create(origin));
#else // !defined(OS_ANDROID)
#endif
}
void ChromePasswordManagerClient::PasswordWasAutofilled(
const std::vector<const PasswordForm*>& best_matches,
const GURL& origin,
const std::vector<const PasswordForm*>* federated_matches) {
#if !defined(OS_ANDROID)
PasswordsClientUIDelegate* manage_passwords_ui_controller =
PasswordsClientUIDelegateFromWebContents(web_contents());
manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin,
......
......@@ -115,6 +115,9 @@ class ChromePasswordManagerClient
void AutomaticPasswordSave(
std::unique_ptr<password_manager::PasswordFormManagerForUI>
saved_form_manager) override;
void UpdateCredentialCache(
const GURL& origin,
const std::vector<const autofill::PasswordForm*>& best_matches) override;
void PasswordWasAutofilled(
const std::vector<const autofill::PasswordForm*>& best_matches,
const GURL& origin,
......
......@@ -11,6 +11,7 @@
#include <utility>
#include "base/bind.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
......@@ -558,7 +559,6 @@ PasswordFormManager::PasswordFormManager(
void PasswordFormManager::OnFetchCompleted() {
received_stored_credentials_time_ = TimeTicks::Now();
// Copy out blacklisted matches.
newly_blacklisted_ = false;
autofills_left_ = kMaxTimesAutofill;
......@@ -568,6 +568,9 @@ void PasswordFormManager::OnFetchCompleted() {
return;
}
client_->UpdateCredentialCache(observed_form_.url.GetOrigin(),
form_fetcher_->GetBestMatches());
if (is_submitted_)
CreatePendingCredentials();
......
......@@ -40,6 +40,10 @@ BiometricAuthenticator* PasswordManagerClient::GetBiometricAuthenticator() {
void PasswordManagerClient::GeneratePassword() {}
void PasswordManagerClient::UpdateCredentialCache(
const GURL& origin,
const std::vector<const autofill::PasswordForm*>& best_matches) {}
void PasswordManagerClient::PasswordWasAutofilled(
const std::vector<const autofill::PasswordForm*>& best_matches,
const GURL& origin,
......
......@@ -198,8 +198,14 @@ class PasswordManagerClient {
// Inform the embedder that the site called 'store()'.
virtual void NotifyStorePasswordCalled() = 0;
// Update the CredentialCache used to display fetched credentials in the UI.
// Currently only implemented on Android.
virtual void UpdateCredentialCache(
const GURL& origin,
const std::vector<const autofill::PasswordForm*>& best_matches);
// Called when a password is saved in an automated fashion. Embedder may
// inform the user that this save has occured.
// inform the user that this save has occurred.
virtual void AutomaticPasswordSave(
std::unique_ptr<PasswordFormManagerForUI> saved_form_manager) = 0;
......
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