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

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

Issue 672083002: Refactoring of SessionService to get componentized. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
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 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 bool has_visible_browser = false; 839 bool has_visible_browser = false;
840 for (std::vector<SessionWindow*>::iterator i = windows->begin(); 840 for (std::vector<SessionWindow*>::iterator i = windows->begin();
841 i != windows->end(); ++i) { 841 i != windows->end(); ++i) {
842 if ((*i)->show_state != ui::SHOW_STATE_MINIMIZED) 842 if ((*i)->show_state != ui::SHOW_STATE_MINIMIZED)
843 has_visible_browser = true; 843 has_visible_browser = true;
844 } 844 }
845 845
846 for (std::vector<SessionWindow*>::iterator i = windows->begin(); 846 for (std::vector<SessionWindow*>::iterator i = windows->begin();
847 i != windows->end(); ++i) { 847 i != windows->end(); ++i) {
848 Browser* browser = NULL; 848 Browser* browser = NULL;
849 if (!has_tabbed_browser && (*i)->type == Browser::TYPE_TABBED) 849 if (!has_tabbed_browser && (*i)->type == SessionWindow::TYPE_TABBED)
850 has_tabbed_browser = true; 850 has_tabbed_browser = true;
851 if (i == windows->begin() && (*i)->type == Browser::TYPE_TABBED && 851 if (i == windows->begin() && (*i)->type == SessionWindow::TYPE_TABBED &&
852 browser_ && browser_->is_type_tabbed() && 852 browser_ && browser_->is_type_tabbed() &&
853 !browser_->profile()->IsOffTheRecord()) { 853 !browser_->profile()->IsOffTheRecord()) {
854 // The first set of tabs is added to the existing browser. 854 // The first set of tabs is added to the existing browser.
855 browser = browser_; 855 browser = browser_;
856 } else { 856 } else {
857 #if defined(OS_CHROMEOS) 857 #if defined(OS_CHROMEOS)
858 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( 858 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(
859 "SessionRestore-CreateRestoredBrowser-Start", false); 859 "SessionRestore-CreateRestoredBrowser-Start", false);
860 #endif 860 #endif
861 // Show the first window if none are visible. 861 // Show the first window if none are visible.
862 ui::WindowShowState show_state = (*i)->show_state; 862 ui::WindowShowState show_state = (*i)->show_state;
863 if (!has_visible_browser) { 863 if (!has_visible_browser) {
864 show_state = ui::SHOW_STATE_NORMAL; 864 show_state = ui::SHOW_STATE_NORMAL;
865 has_visible_browser = true; 865 has_visible_browser = true;
866 } 866 }
867 browser = CreateRestoredBrowser( 867 browser = CreateRestoredBrowser(
868 static_cast<Browser::Type>((*i)->type), 868 static_cast<Browser::Type>((*i)->type),
869 (*i)->bounds, 869 (*i)->bounds,
870 show_state, 870 show_state,
871 (*i)->app_name); 871 (*i)->app_name);
872 #if defined(OS_CHROMEOS) 872 #if defined(OS_CHROMEOS)
873 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker( 873 chromeos::BootTimesLoader::Get()->AddLoginTimeMarker(
874 "SessionRestore-CreateRestoredBrowser-End", false); 874 "SessionRestore-CreateRestoredBrowser-End", false);
875 #endif 875 #endif
876 } 876 }
877 if ((*i)->type == Browser::TYPE_TABBED) 877 if ((*i)->type == SessionWindow::TYPE_TABBED)
878 last_browser = browser; 878 last_browser = browser;
879 WebContents* active_tab = 879 WebContents* active_tab =
880 browser->tab_strip_model()->GetActiveWebContents(); 880 browser->tab_strip_model()->GetActiveWebContents();
881 int initial_tab_count = browser->tab_strip_model()->count(); 881 int initial_tab_count = browser->tab_strip_model()->count();
882 bool close_active_tab = clobber_existing_tab_ && 882 bool close_active_tab = clobber_existing_tab_ &&
883 i == windows->begin() && 883 i == windows->begin() &&
884 (*i)->type == Browser::TYPE_TABBED && 884 (*i)->type == SessionWindow::TYPE_TABBED &&
885 active_tab && browser == browser_ && 885 active_tab && browser == browser_ &&
886 (*i)->tabs.size() > 0; 886 (*i)->tabs.size() > 0;
887 if (close_active_tab) 887 if (close_active_tab)
888 --initial_tab_count; 888 --initial_tab_count;
889 int selected_tab_index = 889 int selected_tab_index =
890 initial_tab_count > 0 ? browser->tab_strip_model()->active_index() 890 initial_tab_count > 0 ? browser->tab_strip_model()->active_index()
891 : std::max(0, 891 : std::max(0,
892 std::min((*i)->selected_tab_index, 892 std::min((*i)->selected_tab_index,
893 static_cast<int>((*i)->tabs.size()) - 1)); 893 static_cast<int>((*i)->tabs.size()) - 1));
894 if ((*i)->window_id.id() == active_window_id) { 894 if ((*i)->window_id.id() == active_window_id) {
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 if (!active_session_restorers) 1291 if (!active_session_restorers)
1292 return false; 1292 return false;
1293 for (std::set<SessionRestoreImpl*>::const_iterator it = 1293 for (std::set<SessionRestoreImpl*>::const_iterator it =
1294 active_session_restorers->begin(); 1294 active_session_restorers->begin();
1295 it != active_session_restorers->end(); ++it) { 1295 it != active_session_restorers->end(); ++it) {
1296 if ((*it)->synchronous()) 1296 if ((*it)->synchronous())
1297 return true; 1297 return true;
1298 } 1298 }
1299 return false; 1299 return false;
1300 } 1300 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698