OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "base/stl_util-inl.h" | 12 #include "base/stl_util-inl.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "chrome/browser/browser.h" | 14 #include "chrome/browser/browser.h" |
15 #include "chrome/browser/browser_list.h" | 15 #include "chrome/browser/browser_list.h" |
| 16 #include "chrome/browser/browser_navigator.h" |
16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/browser_window.h" | 18 #include "chrome/browser/browser_window.h" |
18 #include "chrome/browser/extensions/extensions_service.h" | 19 #include "chrome/browser/extensions/extensions_service.h" |
19 #include "chrome/browser/profile.h" | 20 #include "chrome/browser/profile.h" |
20 #include "chrome/browser/sessions/session_service.h" | 21 #include "chrome/browser/sessions/session_service.h" |
21 #include "chrome/browser/sessions/session_types.h" | 22 #include "chrome/browser/sessions/session_types.h" |
22 #include "chrome/browser/tab_contents/navigation_controller.h" | 23 #include "chrome/browser/tab_contents/navigation_controller.h" |
23 #include "chrome/browser/tab_contents/tab_contents.h" | 24 #include "chrome/browser/tab_contents/tab_contents.h" |
24 #include "chrome/browser/tab_contents/tab_contents_view.h" | 25 #include "chrome/browser/tab_contents/tab_contents_view.h" |
25 #include "chrome/browser/tabs/tab_strip_model.h" | 26 #include "chrome/browser/tabs/tab_strip_model.h" |
(...skipping 519 matching lines...) Loading... |
545 } | 546 } |
546 | 547 |
547 // Appends the urls in |urls| to |browser|. | 548 // Appends the urls in |urls| to |browser|. |
548 void AppendURLsToBrowser(Browser* browser, | 549 void AppendURLsToBrowser(Browser* browser, |
549 const std::vector<GURL>& urls) { | 550 const std::vector<GURL>& urls) { |
550 for (size_t i = 0; i < urls.size(); ++i) { | 551 for (size_t i = 0; i < urls.size(); ++i) { |
551 int add_types = TabStripModel::ADD_FORCE_INDEX; | 552 int add_types = TabStripModel::ADD_FORCE_INDEX; |
552 if (i == 0) | 553 if (i == 0) |
553 add_types |= TabStripModel::ADD_SELECTED; | 554 add_types |= TabStripModel::ADD_SELECTED; |
554 int index = browser->GetIndexForInsertionDuringRestore(i); | 555 int index = browser->GetIndexForInsertionDuringRestore(i); |
555 Browser::AddTabWithURLParams params(urls[i], PageTransition::START_PAGE); | 556 browser::NavigateParams params(browser, urls[i], |
556 params.index = index; | 557 PageTransition::START_PAGE); |
557 params.add_types = add_types; | 558 params.disposition = i == 0 ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; |
558 browser->AddTabWithURL(¶ms); | 559 params.tabstrip_index = index; |
| 560 params.tabstrip_add_types = add_types; |
| 561 browser::Navigate(¶ms); |
559 } | 562 } |
560 } | 563 } |
561 | 564 |
562 // Invokes TabRestored on the SessionService for all tabs in browser after | 565 // Invokes TabRestored on the SessionService for all tabs in browser after |
563 // initial_count. | 566 // initial_count. |
564 void NotifySessionServiceOfRestoredTabs(Browser* browser, int initial_count) { | 567 void NotifySessionServiceOfRestoredTabs(Browser* browser, int initial_count) { |
565 SessionService* session_service = profile_->GetSessionService(); | 568 SessionService* session_service = profile_->GetSessionService(); |
566 for (int i = initial_count; i < browser->tab_count(); ++i) | 569 for (int i = initial_count; i < browser->tab_count(); ++i) |
567 session_service->TabRestored(&browser->GetTabContentsAt(i)->controller(), | 570 session_service->TabRestored(&browser->GetTabContentsAt(i)->controller(), |
568 browser->tabstrip_model()->IsTabPinned(i)); | 571 browser->tabstrip_model()->IsTabPinned(i)); |
(...skipping 94 matching lines...) Loading... |
663 void SessionRestore::RestoreSessionSynchronously( | 666 void SessionRestore::RestoreSessionSynchronously( |
664 Profile* profile, | 667 Profile* profile, |
665 const std::vector<GURL>& urls_to_open) { | 668 const std::vector<GURL>& urls_to_open) { |
666 Restore(profile, NULL, true, false, true, urls_to_open); | 669 Restore(profile, NULL, true, false, true, urls_to_open); |
667 } | 670 } |
668 | 671 |
669 // static | 672 // static |
670 bool SessionRestore::IsRestoring() { | 673 bool SessionRestore::IsRestoring() { |
671 return restoring; | 674 return restoring; |
672 } | 675 } |
OLD | NEW |