diff --git a/brave/browser/password_manager/brave_password_manager_client.cc b/brave/browser/password_manager/brave_password_manager_client.cc index 4dffc9a86d..b7caae924a 100644 --- a/brave/browser/password_manager/brave_password_manager_client.cc +++ b/brave/browser/password_manager/brave_password_manager_client.cc @@ -15,6 +15,7 @@ #include "base/memory/singleton.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram_macros.h" +#include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browsing_data/browsing_data_helper.h" @@ -92,6 +93,15 @@ void BravePasswordManagerClient::CreateForWebContentsWithAutofillClient( base::MakeUnique(contents, autofill_client)); } +// static +bool BravePasswordManagerClient::IsPossibleConfirmPasswordForm( + const autofill::PasswordForm& form) { + return form.new_password_element.empty() && + form.layout != autofill::PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP && + // https://chromium.googlesource.com/chromium/src/+/fdef64500de7e7cdfcc1a77ae7e82ad4a39d264f + form.username_element == base::UTF8ToUTF16("anonymous_username"); +} + BravePasswordManagerClient::BravePasswordManagerClient( content::WebContents* web_contents, autofill::AutofillClient* autofill_client) @@ -210,7 +220,10 @@ bool BravePasswordManagerClient::PromptUserToSaveOrUpdatePassword( if (!CanShowBubbleOnURL(web_contents()->GetLastCommittedURL())) return false; const autofill::PasswordForm *form = form_to_save->submitted_form(); - form_to_save_ = std::move(form_to_save); + // Don't save password for confirmation page (ex. Trezor passphrase) + if (IsPossibleConfirmPasswordForm(*form)) + return false; + form_to_save_ = std::move(form_to_save); if (update_password) { api_web_contents_->Emit("update-password", form->username_value, form->signon_realm); diff --git a/brave/browser/password_manager/brave_password_manager_client.h b/brave/browser/password_manager/brave_password_manager_client.h index 4477db8fb4..8b3299b433 100644 --- a/brave/browser/password_manager/brave_password_manager_client.h +++ b/brave/browser/password_manager/brave_password_manager_client.h @@ -151,6 +151,8 @@ class BravePasswordManagerClient content::WebContents* contents, autofill::AutofillClient* autofill_client); + static bool IsPossibleConfirmPasswordForm(const autofill::PasswordForm& form); + // Observer for PasswordGenerationPopup events. Used for testing. void SetTestObserver(autofill::PasswordGenerationPopupObserver* observer);