diff --git a/components/password_manager/core/browser/password_suggestion_generator.cc b/components/password_manager/core/browser/password_suggestion_generator.cc index af7fa081dbd79..409b5cd134496 100644 --- a/components/password_manager/core/browser/password_suggestion_generator.cc +++ b/components/password_manager/core/browser/password_suggestion_generator.cc @@ -586,14 +586,25 @@ PasswordSuggestionGenerator::GetManualFallbackSuggestions( sync_service->GetUserSettings()->IsUsingExplicitPassphrase(); std::set suggested_signon_realms; for (const auto& form : suggested_credentials) { - suggested_signon_realms.insert(form.signon_realm); + // Grouped (weakly-affiliated) matches come from a *foreign* origin and + // must trigger the cross-domain confirmation popup, mirroring + // `PasswordAutofillManager::DidAcceptSuggestion()`. Only insert the + // signon_realm into `suggested_signon_realms` for non-grouped matches so + // that the same credential in the "All passwords" section also retains + // `IsCrossDomain(true)`. + const bool is_grouped_match = + password_manager_util::GetMatchType(form) == + password_manager_util::GetLoginMatchType::kGrouped; + if (!is_grouped_match) { + suggested_signon_realms.insert(form.signon_realm); + } const CredentialUIEntry ui_entry = CredentialUIEntry(form); const bool is_from_account = ui_entry.stored_in.contains(PasswordForm::Store::kAccountStore); const bool favicon_can_be_requested_from_google = (is_sync_passwords_enabled || is_from_account) && !is_passphrase_user; AppendManualFallbackSuggestions( - ui_entry, on_password_form, IsCrossDomain(false), + ui_entry, on_password_form, IsCrossDomain(is_grouped_match), favicon_can_be_requested_from_google, &suggestions, Suggestion::FiltrationPolicy::kPresentOnlyWithoutFilter); }