• Lukasz Anforowicz's avatar
    Focus tab contents in BeginNavigation case of NTP-initiated navigations. · b4d501e3
    Lukasz Anforowicz authored
    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
    Change-Id: Ib57c260b2f85f276ff1dad3aabedd59d1d864c8a
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1970834
    Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
    Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
    Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
    Reviewed-by: default avatarBrian Sheedy <bsheedy@chromium.org>
    Reviewed-by: default avatarBill Budge <bbudge@chromium.org>
    Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
    Reviewed-by: default avatarCharlie Reis <creis@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#735048}
    b4d501e3
focus_tab_after_navigation_helper.cc 3.52 KB