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

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

Issue 10692195: Consolidate Browser Creation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 WindowOpenDisposition disposition) { 571 WindowOpenDisposition disposition) {
572 DCHECK(!tab.navigations.empty()); 572 DCHECK(!tab.navigations.empty());
573 int selected_index = tab.current_navigation_index; 573 int selected_index = tab.current_navigation_index;
574 selected_index = std::max( 574 selected_index = std::max(
575 0, 575 0,
576 std::min(selected_index, 576 std::min(selected_index,
577 static_cast<int>(tab.navigations.size() - 1))); 577 static_cast<int>(tab.navigations.size() - 1)));
578 578
579 bool use_new_window = disposition == NEW_WINDOW; 579 bool use_new_window = disposition == NEW_WINDOW;
580 580
581 Browser* browser = use_new_window ? Browser::Create(profile_) : browser_; 581 Browser* browser = use_new_window ?
582 new Browser(Browser::CreateParams(profile_)) : browser_;
582 583
583 RecordAppLaunchForTab(browser, tab, selected_index); 584 RecordAppLaunchForTab(browser, tab, selected_index);
584 585
585 if (disposition == CURRENT_TAB) { 586 if (disposition == CURRENT_TAB) {
586 DCHECK(!use_new_window); 587 DCHECK(!use_new_window);
587 chrome::ReplaceRestoredTab(browser, 588 chrome::ReplaceRestoredTab(browser,
588 tab.navigations, 589 tab.navigations,
589 selected_index, 590 selected_index,
590 true, 591 true,
591 tab.extension_app_id, 592 tab.extension_app_id,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 // |created_tabbed_browser| indicates whether a tabbed browser was created, 657 // |created_tabbed_browser| indicates whether a tabbed browser was created,
657 // or we used an existing tabbed browser. 658 // or we used an existing tabbed browser.
658 // 659 //
659 // If successful, this begins loading tabs and deletes itself when all tabs 660 // If successful, this begins loading tabs and deletes itself when all tabs
660 // have been loaded. 661 // have been loaded.
661 // 662 //
662 // Returns the Browser that was created, if any. 663 // Returns the Browser that was created, if any.
663 Browser* FinishedTabCreation(bool succeeded, bool created_tabbed_browser) { 664 Browser* FinishedTabCreation(bool succeeded, bool created_tabbed_browser) {
664 Browser* browser = NULL; 665 Browser* browser = NULL;
665 if (!created_tabbed_browser && always_create_tabbed_browser_) { 666 if (!created_tabbed_browser && always_create_tabbed_browser_) {
666 browser = Browser::Create(profile_); 667 browser = new Browser(Browser::CreateParams(profile_));
667 if (urls_to_open_.empty()) { 668 if (urls_to_open_.empty()) {
668 // No tab browsers were created and no URLs were supplied on the command 669 // No tab browsers were created and no URLs were supplied on the command
669 // line. Add an empty URL, which is treated as opening the users home 670 // line. Add an empty URL, which is treated as opening the users home
670 // page. 671 // page.
671 urls_to_open_.push_back(GURL()); 672 urls_to_open_.push_back(GURL());
672 } 673 }
673 AppendURLsToBrowser(browser, urls_to_open_); 674 AppendURLsToBrowser(browser, urls_to_open_);
674 browser->window()->Show(); 675 browser->window()->Show();
675 } 676 }
676 677
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 921
921 Browser* CreateRestoredBrowser(Browser::Type type, 922 Browser* CreateRestoredBrowser(Browser::Type type,
922 gfx::Rect bounds, 923 gfx::Rect bounds,
923 ui::WindowShowState show_state, 924 ui::WindowShowState show_state,
924 const std::string& app_name) { 925 const std::string& app_name) {
925 Browser::CreateParams params(type, profile_); 926 Browser::CreateParams params(type, profile_);
926 params.app_name = app_name; 927 params.app_name = app_name;
927 params.initial_bounds = bounds; 928 params.initial_bounds = bounds;
928 params.initial_show_state = show_state; 929 params.initial_show_state = show_state;
929 params.is_session_restore = true; 930 params.is_session_restore = true;
930 return Browser::CreateWithParams(params); 931 return new Browser(params);
931 } 932 }
932 933
933 void ShowBrowser(Browser* browser, int selected_tab_index) { 934 void ShowBrowser(Browser* browser, int selected_tab_index) {
934 DCHECK(browser); 935 DCHECK(browser);
935 DCHECK(browser->tab_count()); 936 DCHECK(browser->tab_count());
936 chrome::ActivateTabAt(browser, selected_tab_index, true); 937 chrome::ActivateTabAt(browser, selected_tab_index, true);
937 938
938 if (browser_ == browser) 939 if (browser_ == browser)
939 return; 940 return;
940 941
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 if (active_session_restorers == NULL) 1090 if (active_session_restorers == NULL)
1090 return false; 1091 return false;
1091 for (std::set<SessionRestoreImpl*>::const_iterator it = 1092 for (std::set<SessionRestoreImpl*>::const_iterator it =
1092 active_session_restorers->begin(); 1093 active_session_restorers->begin();
1093 it != active_session_restorers->end(); ++it) { 1094 it != active_session_restorers->end(); ++it) {
1094 if ((*it)->profile() == profile) 1095 if ((*it)->profile() == profile)
1095 return true; 1096 return true;
1096 } 1097 }
1097 return false; 1098 return false;
1098 } 1099 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager_unittest.cc ('k') | chrome/browser/sessions/session_restore_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698