Commit acdee337 authored by Sidney San Martín's avatar Sidney San Martín Committed by Commit Bot

Tighten scope of activation changes made as part of Mac spaces restore.

There was multi-platform fallout from making activation less aggressive
in r701411 so that when a session is restored on Mac with windows in
multiple spaces, the system won't switch spaces as those windows are
created and activated.

This rolls back all of the cross-platform changes from r701411 and
r710397, replacing them with behind one tweak to skip activating windows
after restoring their tabs, currently guarded to macOS-only.

Bug: 1019048, 1018885
Change-Id: Id45d2029cf8a5f2af08e7ec3aba911ff2b664a10
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1910282Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Sidney San Martín <sdy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714657}
parent 0d7bd7fa
...@@ -478,12 +478,8 @@ class SessionRestoreImpl : public BrowserListObserver { ...@@ -478,12 +478,8 @@ class SessionRestoreImpl : public BrowserListObserver {
chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker(
"SessionRestore-CreatingTabs-End", false); "SessionRestore-CreatingTabs-End", false);
#endif #endif
if (browser_to_activate) { if (browser_to_activate)
// |browser_to_activate| may be minimized. Show it before activating it to
// avoid having a window with no content. https://crbug.com/1018885
browser_to_activate->window()->Show();
browser_to_activate->window()->Activate(); browser_to_activate->window()->Activate();
}
// If last_normal_browser is NULL and urls_to_open_ is non-empty, // If last_normal_browser is NULL and urls_to_open_ is non-empty,
// FinishedTabCreation will create a new TabbedBrowser and add the urls to // FinishedTabCreation will create a new TabbedBrowser and add the urls to
...@@ -663,8 +659,7 @@ class SessionRestoreImpl : public BrowserListObserver { ...@@ -663,8 +659,7 @@ class SessionRestoreImpl : public BrowserListObserver {
if (browser_ == browser) if (browser_ == browser)
return; return;
if (!browser->window()->IsVisible() && !browser->window()->IsMinimized()) browser->window()->Show();
browser->window()->Show();
browser->set_is_session_restore(false); browser->set_is_session_restore(false);
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "build/build_config.h"
#include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/session_restore.h" #include "chrome/browser/sessions/session_restore.h"
...@@ -126,8 +127,16 @@ WebContents* AddRestoredTab( ...@@ -126,8 +127,16 @@ WebContents* AddRestoredTab(
} }
if (select) { if (select) {
if (!browser->window()->IsMinimized()) if (
browser->window()->Show(); #if defined(OS_MACOSX)
// Activating a window on another space causes the system to switch to
// that space. Since the session restore process shows and activates
// windows itself, activating windows here should be safe to skip.
// Cautiously apply only to macOS, for now (https://crbug.com/1019048).
!from_session_restore &&
#endif
!browser->window()->IsMinimized())
browser->window()->Activate();
} else { } else {
// We set the size of the view here, before Blink does its initial layout. // We set the size of the view here, before Blink does its initial layout.
// If we don't, the initial layout of background tabs will be performed // If we don't, the initial layout of background tabs will be performed
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment