Index: chrome/browser/sessions/session_restore.cc |
diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc |
index eeafc2d4fed5bd8ac73abeea509a04cf4f662b5f..bc9cdea408b64872c828fcbdf9dd18e822ea3e55 100644 |
--- a/chrome/browser/sessions/session_restore.cc |
+++ b/chrome/browser/sessions/session_restore.cc |
@@ -399,6 +399,16 @@ class SessionRestoreImpl : public content::NotificationObserver { |
has_visible_browser = true; |
} |
+ // Always move the session window with |active_window_id| to the front, so |
sky
2017/03/07 17:34:19
Now that I think about it you shouldn't reorder wi
Qiang(Joe) Xu
2017/03/07 21:17:04
ok, thanks for the info. Another solution I upload
|
+ // that if the first session window is restored to the existing tabbed |
+ // browser, the existing browser is the |browser_to_activate|. |
+ for (auto i = windows->begin(); i != windows->end(); ++i) { |
+ if ((*i)->window_id.id() == active_window_id) { |
+ std::iter_swap(windows->begin(), i); |
+ break; |
+ } |
+ } |
+ |
for (auto i = windows->begin(); i != windows->end(); ++i) { |
Browser* browser = nullptr; |
if (!has_tabbed_browser && |
@@ -656,7 +666,8 @@ class SessionRestoreImpl : public content::NotificationObserver { |
// TODO(jcampan): http://crbug.com/8123 we should not need to set the |
// initial focus explicitly. |
- browser->tab_strip_model()->GetActiveWebContents()->SetInitialFocus(); |
+ if (browser->window()->IsActive()) |
+ browser->tab_strip_model()->GetActiveWebContents()->SetInitialFocus(); |
} |
// Appends the urls in |urls| to |browser|. |