feat: add focusOnNavigation flag to WebPreferences (#49425)

* feat: add focusOnNavigation webPreference

* WebContentsView tests

* fix

* fix
This commit is contained in:
Kyle Cutler
2026-01-23 11:29:34 -08:00
committed by GitHub
parent 8a11d5afb1
commit d5de8883a2
7 changed files with 77 additions and 0 deletions

View File

@@ -2098,6 +2098,10 @@ void WebContents::ReadyToCommitNavigation(
// Only focus for top-level contents.
if (type_ != Type::kBrowserWindow)
return;
// Don't focus if focusOnNavigation is disabled.
auto* prefs = WebContentsPreferences::From(web_contents());
if (prefs && !prefs->ShouldFocusOnNavigation())
return;
web_contents()->SetInitialFocus();
}