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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 Browser* browser = NULL; | 533 Browser* browser = NULL; |
534 if (!created_tabbed_browser && always_create_tabbed_browser_) { | 534 if (!created_tabbed_browser && always_create_tabbed_browser_) { |
535 browser = Browser::Create(profile_); | 535 browser = Browser::Create(profile_); |
536 if (urls_to_open_.empty()) { | 536 if (urls_to_open_.empty()) { |
537 // No tab browsers were created and no URLs were supplied on the command | 537 // No tab browsers were created and no URLs were supplied on the command |
538 // line. Add an empty URL, which is treated as opening the users home | 538 // line. Add an empty URL, which is treated as opening the users home |
539 // page. | 539 // page. |
540 urls_to_open_.push_back(GURL()); | 540 urls_to_open_.push_back(GURL()); |
541 } | 541 } |
542 AppendURLsToBrowser(browser, urls_to_open_); | 542 AppendURLsToBrowser(browser, urls_to_open_); |
543 browser->window()->Show(); | 543 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_RESTORE); |
544 } | 544 } |
545 | 545 |
546 if (succeeded) { | 546 if (succeeded) { |
547 DCHECK(tab_loader_.get()); | 547 DCHECK(tab_loader_.get()); |
548 // TabLoader delets itself when done loading. | 548 // TabLoader delets itself when done loading. |
549 tab_loader_.release()->StartLoading(); | 549 tab_loader_.release()->StartLoading(); |
550 } | 550 } |
551 | 551 |
552 if (!synchronous_) { | 552 if (!synchronous_) { |
553 // If we're not synchronous we need to delete ourself. | 553 // If we're not synchronous we need to delete ourself. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 int selected_session_index) { | 723 int selected_session_index) { |
724 DCHECK(browser); | 724 DCHECK(browser); |
725 DCHECK(browser->tab_count()); | 725 DCHECK(browser->tab_count()); |
726 browser->ActivateTabAt( | 726 browser->ActivateTabAt( |
727 std::min(initial_tab_count + std::max(0, selected_session_index), | 727 std::min(initial_tab_count + std::max(0, selected_session_index), |
728 browser->tab_count() - 1), true); | 728 browser->tab_count() - 1), true); |
729 | 729 |
730 if (browser_ == browser) | 730 if (browser_ == browser) |
731 return; | 731 return; |
732 | 732 |
733 browser->window()->Show(); | 733 browser->window()->Show(BrowserWindow::SHOW_CONTEXT_RESTORE); |
734 // TODO(jcampan): http://crbug.com/8123 we should not need to set the | 734 // TODO(jcampan): http://crbug.com/8123 we should not need to set the |
735 // initial focus explicitly. | 735 // initial focus explicitly. |
736 browser->GetSelectedTabContents()->view()->SetInitialFocus(); | 736 browser->GetSelectedTabContents()->view()->SetInitialFocus(); |
737 } | 737 } |
738 | 738 |
739 // Appends the urls in |urls| to |browser|. | 739 // Appends the urls in |urls| to |browser|. |
740 void AppendURLsToBrowser(Browser* browser, | 740 void AppendURLsToBrowser(Browser* browser, |
741 const std::vector<GURL>& urls) { | 741 const std::vector<GURL>& urls) { |
742 for (size_t i = 0; i < urls.size(); ++i) { | 742 for (size_t i = 0; i < urls.size(); ++i) { |
743 int add_types = TabStripModel::ADD_FORCE_INDEX; | 743 int add_types = TabStripModel::ADD_FORCE_INDEX; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 std::vector<GURL> gurls; | 852 std::vector<GURL> gurls; |
853 SessionRestoreImpl restorer(profile, | 853 SessionRestoreImpl restorer(profile, |
854 static_cast<Browser*>(NULL), true, false, true, gurls); | 854 static_cast<Browser*>(NULL), true, false, true, gurls); |
855 restorer.RestoreForeignTab(tab); | 855 restorer.RestoreForeignTab(tab); |
856 } | 856 } |
857 | 857 |
858 // static | 858 // static |
859 bool SessionRestore::IsRestoring() { | 859 bool SessionRestore::IsRestoring() { |
860 return restoring; | 860 return restoring; |
861 } | 861 } |
OLD | NEW |