diff --git a/chrome/browser/ui/views/autofill/popup/popup_base_view.cc b/chrome/browser/ui/views/autofill/popup/popup_base_view.cc index 269b903884504..72030cb1d3187 100644 --- a/chrome/browser/ui/views/autofill/popup/popup_base_view.cc +++ b/chrome/browser/ui/views/autofill/popup/popup_base_view.cc @@ -566,6 +566,23 @@ bool PopupBaseView::DoUpdateBoundsAndRedrawPopup() { element_bounds, visible_content_area_bounds, preferred_size, kDefaultPreferredPopupSides); + // Hoist the prompt-overlap checks from PopupViewViews so subclasses that + // inherit this implementation directly (PasswordGenerationPopupViewViews, + // PasswordCrossDomainConfirmationPopupViewViews) cannot be positioned on + // top of permission bubbles or other browser dialogs. The popup widget is + // created with ZOrderLevel::kSecuritySurface, so without these checks it + // would render above the permission prompt. + if (content::WebContents* web_contents = GetWebContents()) { + if (BoundsOverlapWithAnyOpenPrompt(popup_bounds, web_contents) || + BoundsOverlapWithOpenPermissionsPrompt(popup_bounds, web_contents) || + (base::FeatureList::IsEnabled( + features::kAutofillPopupCheckHtmlFormPopupOverlap) && + BoundsOverlapWithHtmlFormPopup(popup_bounds, web_contents))) { + HideController(SuggestionHidingReason::kOverlappingWithAnotherPrompt); + return false; + } + } + if (BoundsOverlapWithPictureInPictureWindow(popup_bounds)) { HideController( SuggestionHidingReason::kOverlappingWithPictureInPictureWindow);