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..799aba32f448c5cc6c8ec71fce362bf6ee713bbb 100644 |
--- a/chrome/browser/sessions/session_restore.cc |
+++ b/chrome/browser/sessions/session_restore.cc |
@@ -410,6 +410,17 @@ class SessionRestoreImpl : public content::NotificationObserver { |
!browser_->profile()->IsOffTheRecord()) { |
// The first set of tabs is added to the existing browser. |
browser = browser_; |
+ |
+ // If the existing browser is not nullptr and tabbed, the tabs from the |
+ // session window with |active_window_id| should be restored to this |
+ // existing browser. Therefore, the existing browser is the |
+ // |browser_to_activate|. |
+ for (auto j = windows->begin(); j != windows->end(); ++j) { |
sky
2017/03/07 01:05:36
It's confusing to have this logic here. Could you
Qiang(Joe) Xu
2017/03/07 01:19:31
Done.
|
+ if ((*j)->window_id.id() == active_window_id) { |
+ std::iter_swap(i, j); |
+ break; |
+ } |
+ } |
} else { |
#if defined(OS_CHROMEOS) |
chromeos::BootTimesRecorder::Get()->AddLoginTimeMarker( |
@@ -656,7 +667,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|. |