OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/sessions/session_restore.h" | 5 #include "chrome/browser/sessions/session_restore.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <list> | 8 #include <list> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 "SessionRestore-CreatingTabs-Start", false); | 591 "SessionRestore-CreatingTabs-Start", false); |
592 #endif | 592 #endif |
593 StartTabCreation(); | 593 StartTabCreation(); |
594 | 594 |
595 Browser* current_browser = | 595 Browser* current_browser = |
596 browser_ ? browser_ : BrowserList::GetLastActiveWithProfile(profile_); | 596 browser_ ? browser_ : BrowserList::GetLastActiveWithProfile(profile_); |
597 // After the for loop this contains the last TABBED_BROWSER. Is null if no | 597 // After the for loop this contains the last TABBED_BROWSER. Is null if no |
598 // tabbed browsers exist. | 598 // tabbed browsers exist. |
599 Browser* last_browser = NULL; | 599 Browser* last_browser = NULL; |
600 bool has_tabbed_browser = false; | 600 bool has_tabbed_browser = false; |
| 601 |
| 602 // Determine if there is a visible window. |
| 603 bool has_visible_browser = false; |
| 604 for (std::vector<SessionWindow*>::iterator i = windows->begin(); |
| 605 i != windows->end(); ++i) { |
| 606 if ((*i)->show_state != ui::SHOW_STATE_MINIMIZED) |
| 607 has_visible_browser = true; |
| 608 } |
| 609 |
601 for (std::vector<SessionWindow*>::iterator i = windows->begin(); | 610 for (std::vector<SessionWindow*>::iterator i = windows->begin(); |
602 i != windows->end(); ++i) { | 611 i != windows->end(); ++i) { |
603 Browser* browser = NULL; | 612 Browser* browser = NULL; |
604 if (!has_tabbed_browser && (*i)->type == Browser::TYPE_TABBED) | 613 if (!has_tabbed_browser && (*i)->type == Browser::TYPE_TABBED) |
605 has_tabbed_browser = true; | 614 has_tabbed_browser = true; |
606 if (i == windows->begin() && (*i)->type == Browser::TYPE_TABBED && | 615 if (i == windows->begin() && (*i)->type == Browser::TYPE_TABBED && |
607 current_browser && current_browser->is_type_tabbed() && | 616 current_browser && current_browser->is_type_tabbed() && |
608 !current_browser->profile()->IsOffTheRecord()) { | 617 !current_browser->profile()->IsOffTheRecord()) { |
609 // The first set of tabs is added to the existing browser. | 618 // The first set of tabs is added to the existing browser. |
610 browser = current_browser; | 619 browser = current_browser; |
611 } else { | 620 } else { |
612 #if defined(OS_CHROMEOS) | 621 #if defined(OS_CHROMEOS) |
613 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( | 622 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( |
614 "SessionRestore-CreateRestoredBrowser-Start", false); | 623 "SessionRestore-CreateRestoredBrowser-Start", false); |
615 #endif | 624 #endif |
| 625 // Show the first window if none are visible. |
| 626 ui::WindowShowState show_state = (*i)->show_state; |
| 627 if (!has_visible_browser) { |
| 628 show_state = ui::SHOW_STATE_NORMAL; |
| 629 has_visible_browser = true; |
| 630 } |
| 631 |
616 browser = CreateRestoredBrowser( | 632 browser = CreateRestoredBrowser( |
617 static_cast<Browser::Type>((*i)->type), | 633 static_cast<Browser::Type>((*i)->type), (*i)->bounds, show_state); |
618 (*i)->bounds, | |
619 (*i)->show_state); | |
620 #if defined(OS_CHROMEOS) | 634 #if defined(OS_CHROMEOS) |
621 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( | 635 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( |
622 "SessionRestore-CreateRestoredBrowser-End", false); | 636 "SessionRestore-CreateRestoredBrowser-End", false); |
623 #endif | 637 #endif |
624 } | 638 } |
625 if ((*i)->type == Browser::TYPE_TABBED) | 639 if ((*i)->type == Browser::TYPE_TABBED) |
626 last_browser = browser; | 640 last_browser = browser; |
627 TabContents* active_tab = browser->GetSelectedTabContents(); | 641 TabContents* active_tab = browser->GetSelectedTabContents(); |
628 int initial_tab_count = browser->tab_count(); | 642 int initial_tab_count = browser->tab_count(); |
629 int selected_tab_index = (*i)->selected_tab_index; | 643 int selected_tab_index = (*i)->selected_tab_index; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 std::vector<GURL> gurls; | 866 std::vector<GURL> gurls; |
853 SessionRestoreImpl restorer(profile, | 867 SessionRestoreImpl restorer(profile, |
854 static_cast<Browser*>(NULL), true, false, true, gurls); | 868 static_cast<Browser*>(NULL), true, false, true, gurls); |
855 restorer.RestoreForeignTab(tab); | 869 restorer.RestoreForeignTab(tab); |
856 } | 870 } |
857 | 871 |
858 // static | 872 // static |
859 bool SessionRestore::IsRestoring() { | 873 bool SessionRestore::IsRestoring() { |
860 return restoring; | 874 return restoring; |
861 } | 875 } |
OLD | NEW |