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( ...@@ -506,17 +506,20 @@ void ChromePasswordManagerClient::AutomaticPasswordSave(
#endif #endif
} }
void ChromePasswordManagerClient::PasswordWasAutofilled( void ChromePasswordManagerClient::UpdateCredentialCache(
const std::vector<const PasswordForm*>& best_matches,
const GURL& origin, const GURL& origin,
const std::vector<const PasswordForm*>* federated_matches) { const std::vector<const autofill::PasswordForm*>& best_matches) {
#if defined(OS_ANDROID) #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, credential_cache_.SaveCredentialsForOrigin(best_matches,
url::Origin::Create(origin)); 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 = PasswordsClientUIDelegate* manage_passwords_ui_controller =
PasswordsClientUIDelegateFromWebContents(web_contents()); PasswordsClientUIDelegateFromWebContents(web_contents());
manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin, manage_passwords_ui_controller->OnPasswordAutofilled(best_matches, origin,
......
...@@ -115,6 +115,9 @@ class ChromePasswordManagerClient ...@@ -115,6 +115,9 @@ class ChromePasswordManagerClient
void AutomaticPasswordSave( void AutomaticPasswordSave(
std::unique_ptr<password_manager::PasswordFormManagerForUI> std::unique_ptr<password_manager::PasswordFormManagerForUI>
saved_form_manager) override; saved_form_manager) override;
void UpdateCredentialCache(
const GURL& origin,
const std::vector<const autofill::PasswordForm*>& best_matches) override;
void PasswordWasAutofilled( void PasswordWasAutofilled(
const std::vector<const autofill::PasswordForm*>& best_matches, const std::vector<const autofill::PasswordForm*>& best_matches,
const GURL& origin, const GURL& origin,
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <utility> #include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h" #include "base/metrics/user_metrics_action.h"
...@@ -558,7 +559,6 @@ PasswordFormManager::PasswordFormManager( ...@@ -558,7 +559,6 @@ PasswordFormManager::PasswordFormManager(
void PasswordFormManager::OnFetchCompleted() { void PasswordFormManager::OnFetchCompleted() {
received_stored_credentials_time_ = TimeTicks::Now(); received_stored_credentials_time_ = TimeTicks::Now();
// Copy out blacklisted matches.
newly_blacklisted_ = false; newly_blacklisted_ = false;
autofills_left_ = kMaxTimesAutofill; autofills_left_ = kMaxTimesAutofill;
...@@ -568,6 +568,9 @@ void PasswordFormManager::OnFetchCompleted() { ...@@ -568,6 +568,9 @@ void PasswordFormManager::OnFetchCompleted() {
return; return;
} }
client_->UpdateCredentialCache(observed_form_.url.GetOrigin(),
form_fetcher_->GetBestMatches());
if (is_submitted_) if (is_submitted_)
CreatePendingCredentials(); CreatePendingCredentials();
......
...@@ -40,6 +40,10 @@ BiometricAuthenticator* PasswordManagerClient::GetBiometricAuthenticator() { ...@@ -40,6 +40,10 @@ BiometricAuthenticator* PasswordManagerClient::GetBiometricAuthenticator() {
void PasswordManagerClient::GeneratePassword() {} void PasswordManagerClient::GeneratePassword() {}
void PasswordManagerClient::UpdateCredentialCache(
const GURL& origin,
const std::vector<const autofill::PasswordForm*>& best_matches) {}
void PasswordManagerClient::PasswordWasAutofilled( void PasswordManagerClient::PasswordWasAutofilled(
const std::vector<const autofill::PasswordForm*>& best_matches, const std::vector<const autofill::PasswordForm*>& best_matches,
const GURL& origin, const GURL& origin,
......
...@@ -198,8 +198,14 @@ class PasswordManagerClient { ...@@ -198,8 +198,14 @@ class PasswordManagerClient {
// Inform the embedder that the site called 'store()'. // Inform the embedder that the site called 'store()'.
virtual void NotifyStorePasswordCalled() = 0; 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 // 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( virtual void AutomaticPasswordSave(
std::unique_ptr<PasswordFormManagerForUI> saved_form_manager) = 0; 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