[reland] Focus tab contents in BeginNavigation case of NTP-initiated navigations.
[ This is a reland of https://crrev.com/c/1970834 + changes that remove a redundant test in //chrome/browser/portal/portal_browsertest.cc (see CR comments). Original CL description follows below. ] Tab contents may get focused during some renderer-initiated navigations (e.g. navigations from an NTP-replacement extension - see the regression test added in r723022). This CL ensures that the focus decision is applied not only to navigations that go through OpenURL, but also to navigations that go through (more freqeuent, usual) BeginNavigation. This change helps ensure that we retain the right focus behavior after more navigations switch to the BeginNavigation code path (e.g. after relanding ShouldFork removal in https://crrev.com/c/1949448). The CL covers both the OpenURL and BeginNavigation code paths by handling the focus decisions in a newly added TabContentFocusingHelper class (replicating/moving the focus decisions from OpenURL-only Browser::UpdateUIForNavigationInTab). Adding a new tab-helper class is useful, because the existing, OpenURL/BeginNavigation-shared navigation notifications handlers (e.g. Browser::ScheduleUIUpdate) cannot distinguish between replaceState and new navigations (see also new steps in the OmniboxFocusInteractiveTest.NtpReplacementExtension test). While this CL changes how focus behavior is implemented, it should have no effect on end-to-end/high-level expectations of focus behavior (as observed by end users or browser tests). browser_tests do not guarantee window activation and/or focus, but before this CL navigation in browser_tests would focus WebContents. This is not happening after this CL, and requires moving a handful of focus-dependent tests from browser_tests to interactive_ui_tests. Bug: 1029161 Tbr: Karan Bhatia <karandeepb@chromium.org> Tbr: Rouslan Solomakhin <rouslan@chromium.org> Tbr: Brian Sheedy <bsheedy@chromium.org> Tbr: Bill Budge <bbudge@chromium.org> Tbr: Peter Kasting <pkasting@chromium.org> Tbr: Charlie Reis <creis@chromium.org> Change-Id: I7324e7ecb08a51601b12fba3f57c68af59f33128 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2024155Reviewed-by:Peter Kasting <pkasting@chromium.org> Reviewed-by:
Karan Bhatia <karandeepb@chromium.org> Reviewed-by:
Brian Sheedy <bsheedy@chromium.org> Reviewed-by:
Adithya Srinivasan <adithyas@chromium.org> Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org> Cr-Commit-Position: refs/heads/master@{#737502}
Showing
This diff is collapsed.
Please register or sign in to comment