Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: chrome/browser/sessions/session_restore.cc

Issue 10536074: TabContentsWrapper -> TabContents, part 26. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 10 #include <string>
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 // Restore and show the browser. 542 // Restore and show the browser.
543 const int initial_tab_count = 0; 543 const int initial_tab_count = 0;
544 int selected_tab_index = std::max( 544 int selected_tab_index = std::max(
545 0, 545 0,
546 std::min((*i)->selected_tab_index, 546 std::min((*i)->selected_tab_index,
547 static_cast<int>((*i)->tabs.size()) - 1)); 547 static_cast<int>((*i)->tabs.size()) - 1));
548 selected_tab_index = 548 selected_tab_index =
549 RestoreTabsToBrowser(*(*i), browser, selected_tab_index); 549 RestoreTabsToBrowser(*(*i), browser, selected_tab_index);
550 ShowBrowser(browser, selected_tab_index); 550 ShowBrowser(browser, selected_tab_index);
551 tab_loader_->TabIsLoading( 551 tab_loader_->TabIsLoading(
552 &browser->GetSelectedWebContents()->GetController()); 552 &browser->GetActiveWebContents()->GetController());
553 NotifySessionServiceOfRestoredTabs(browser, initial_tab_count); 553 NotifySessionServiceOfRestoredTabs(browser, initial_tab_count);
554 } 554 }
555 555
556 // Always create in a new window 556 // Always create in a new window
557 FinishedTabCreation(true, true); 557 FinishedTabCreation(true, true);
558 } 558 }
559 559
560 // Restore a single tab from a foreign session. 560 // Restore a single tab from a foreign session.
561 // Opens in the tab in the last active browser, unless disposition is 561 // Opens in the tab in the last active browser, unless disposition is
562 // NEW_WINDOW, in which case the tab will be opened in a new browser. 562 // NEW_WINDOW, in which case the tab will be opened in a new browser.
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 (*i)->bounds, 780 (*i)->bounds,
781 show_state, 781 show_state,
782 (*i)->app_name); 782 (*i)->app_name);
783 #if defined(OS_CHROMEOS) 783 #if defined(OS_CHROMEOS)
784 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( 784 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(
785 "SessionRestore-CreateRestoredBrowser-End", false); 785 "SessionRestore-CreateRestoredBrowser-End", false);
786 #endif 786 #endif
787 } 787 }
788 if ((*i)->type == Browser::TYPE_TABBED) 788 if ((*i)->type == Browser::TYPE_TABBED)
789 last_browser = browser; 789 last_browser = browser;
790 WebContents* active_tab = browser->GetSelectedWebContents(); 790 WebContents* active_tab = browser->GetActiveWebContents();
791 int initial_tab_count = browser->tab_count(); 791 int initial_tab_count = browser->tab_count();
792 int selected_tab_index = std::max( 792 int selected_tab_index = std::max(
793 0, 793 0,
794 std::min((*i)->selected_tab_index, 794 std::min((*i)->selected_tab_index,
795 static_cast<int>((*i)->tabs.size()) - 1)); 795 static_cast<int>((*i)->tabs.size()) - 1));
796 selected_tab_index = 796 selected_tab_index =
797 RestoreTabsToBrowser(*(*i), browser, selected_tab_index); 797 RestoreTabsToBrowser(*(*i), browser, selected_tab_index);
798 ShowBrowser(browser, selected_tab_index); 798 ShowBrowser(browser, selected_tab_index);
799 if (clobber_existing_tab_ && i == windows->begin() && 799 if (clobber_existing_tab_ && i == windows->begin() &&
800 (*i)->type == Browser::TYPE_TABBED && active_tab && 800 (*i)->type == Browser::TYPE_TABBED && active_tab &&
801 browser == browser_ && browser->tab_count() > initial_tab_count) { 801 browser == browser_ && browser->tab_count() > initial_tab_count) {
802 browser->CloseTabContents(active_tab); 802 browser->CloseTabContents(active_tab);
803 active_tab = NULL; 803 active_tab = NULL;
804 } 804 }
805 tab_loader_->TabIsLoading( 805 tab_loader_->TabIsLoading(
806 &browser->GetSelectedWebContents()->GetController()); 806 &browser->GetActiveWebContents()->GetController());
807 NotifySessionServiceOfRestoredTabs(browser, initial_tab_count); 807 NotifySessionServiceOfRestoredTabs(browser, initial_tab_count);
808 } 808 }
809 809
810 if (last_browser && !urls_to_open_.empty()) 810 if (last_browser && !urls_to_open_.empty())
811 AppendURLsToBrowser(last_browser, urls_to_open_); 811 AppendURLsToBrowser(last_browser, urls_to_open_);
812 #if defined(OS_CHROMEOS) 812 #if defined(OS_CHROMEOS)
813 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( 813 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(
814 "SessionRestore-CreatingTabs-End", false); 814 "SessionRestore-CreatingTabs-End", false);
815 #endif 815 #endif
816 // If last_browser is NULL and urls_to_open_ is non-empty, 816 // If last_browser is NULL and urls_to_open_ is non-empty,
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 browser->ActivateTabAt(selected_tab_index, true); 928 browser->ActivateTabAt(selected_tab_index, true);
929 929
930 if (browser_ == browser) 930 if (browser_ == browser)
931 return; 931 return;
932 932
933 browser->window()->Show(); 933 browser->window()->Show();
934 browser->set_is_session_restore(false); 934 browser->set_is_session_restore(false);
935 935
936 // TODO(jcampan): http://crbug.com/8123 we should not need to set the 936 // TODO(jcampan): http://crbug.com/8123 we should not need to set the
937 // initial focus explicitly. 937 // initial focus explicitly.
938 browser->GetSelectedWebContents()->GetView()->SetInitialFocus(); 938 browser->GetActiveWebContents()->GetView()->SetInitialFocus();
939 939
940 if (!browser_shown_) { 940 if (!browser_shown_) {
941 browser_shown_ = true; 941 browser_shown_ = true;
942 base::TimeDelta time_to_first_show = 942 base::TimeDelta time_to_first_show =
943 base::TimeTicks::Now() - restore_started_; 943 base::TimeTicks::Now() - restore_started_;
944 UMA_HISTOGRAM_CUSTOM_TIMES( 944 UMA_HISTOGRAM_CUSTOM_TIMES(
945 "SessionRestore.TimeToFirstShow", 945 "SessionRestore.TimeToFirstShow",
946 time_to_first_show, 946 time_to_first_show,
947 base::TimeDelta::FromMilliseconds(10), 947 base::TimeDelta::FromMilliseconds(10),
948 base::TimeDelta::FromSeconds(1000), 948 base::TimeDelta::FromSeconds(1000),
(...skipping 19 matching lines...) Expand all
968 } 968 }
969 969
970 // Invokes TabRestored on the SessionService for all tabs in browser after 970 // Invokes TabRestored on the SessionService for all tabs in browser after
971 // initial_count. 971 // initial_count.
972 void NotifySessionServiceOfRestoredTabs(Browser* browser, int initial_count) { 972 void NotifySessionServiceOfRestoredTabs(Browser* browser, int initial_count) {
973 SessionService* session_service = 973 SessionService* session_service =
974 SessionServiceFactory::GetForProfile(profile_); 974 SessionServiceFactory::GetForProfile(profile_);
975 if (!session_service) 975 if (!session_service)
976 return; 976 return;
977 for (int i = initial_count; i < browser->tab_count(); ++i) 977 for (int i = initial_count; i < browser->tab_count(); ++i)
978 session_service->TabRestored(browser->GetTabContentsWrapperAt(i), 978 session_service->TabRestored(browser->GetTabContentsAt(i),
979 browser->IsTabPinned(i)); 979 browser->IsTabPinned(i));
980 } 980 }
981 981
982 // The profile to create the sessions for. 982 // The profile to create the sessions for.
983 Profile* profile_; 983 Profile* profile_;
984 984
985 // The first browser to restore to, may be null. 985 // The first browser to restore to, may be null.
986 Browser* browser_; 986 Browser* browser_;
987 987
988 // Whether or not restore is synchronous. 988 // Whether or not restore is synchronous.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 if (active_session_restorers == NULL) 1080 if (active_session_restorers == NULL)
1081 return false; 1081 return false;
1082 for (std::set<SessionRestoreImpl*>::const_iterator it = 1082 for (std::set<SessionRestoreImpl*>::const_iterator it =
1083 active_session_restorers->begin(); 1083 active_session_restorers->begin();
1084 it != active_session_restorers->end(); ++it) { 1084 it != active_session_restorers->end(); ++it) {
1085 if ((*it)->profile() == profile) 1085 if ((*it)->profile() == profile)
1086 return true; 1086 return true;
1087 } 1087 }
1088 return false; 1088 return false;
1089 } 1089 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/restore_tab_helper.cc ('k') | chrome/browser/sessions/session_restore_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698