• Maria Villarreal's avatar
    Set initial focus on session restore · 414b62b0
    Maria Villarreal authored
    Issue:
    - When On startup setting is set to "Continue where you left off",
    the initial focus is not set after launching the browser.
    - Users have to press Tab to focus the window.
    - This affects users who rely on screen readers since the window
    information is not announced on launch (on UIA mode).
    
    More context:
    - The line calling SetInitialFocus was previously in the code but got
    removed after a startup focus refactor:
    https://chromium-review.googlesource.com/c/chromium/src/+/1313728
    - The refactor added the call to RestoreFocus on
    BrowserView::OnWidgetActivationChanged if the property
    restore_focus_on_activation_ is set to True. This property gets set
    during BrowserView::Show, but only in the case of session restore,
    Show gets called after OnWidgetActivationChanged so RestoreFocus is
    never called.
    - The inverted call stack on session restore is because AddRestoredTab
    on browser_tabrestore calls Activate before showing the window.
    
    Fix:
    - Similar to what we currently have for MacOS, only call Activate
    in AddRestoredTab if it is not |from_session_restore|. This way Show
    will be called before Activate and thus focus will be set as
    expected.
    - This change is only made on Windows due to a couple of reasons
    1) crbug.com/1102685 is only present on this platform.
    2) Making this change on Linux would re-introduce crbug.com/1019048.
    
    Bug: 1102685
    Change-Id: I6e62ebad7693eb5d908770364ba7c8d755ccaa70
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2284382Reviewed-by: default avatarScott Violet <sky@chromium.org>
    Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
    Commit-Queue: Maria Villarreal <mavill@microsoft.com>
    Cr-Commit-Position: refs/heads/master@{#791950}
    414b62b0
browser_tabrestore.cc 9.81 KB