| OLD | NEW |
| 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 <vector> |
| 8 |
| 7 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/sessions/session_types.h" | 10 #include "chrome/browser/sessions/session_types.h" |
| 9 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 11 #include "chrome/browser/ui/android/tab_model/tab_model.h" | 13 #include "chrome/browser/ui/android/tab_model/tab_model.h" |
| 12 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" | 14 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
| 13 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
| 14 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 15 | 17 |
| 16 // The android implementation does not do anything "foreign session" specific. | 18 // The android implementation does not do anything "foreign session" specific. |
| 17 // We use it to restore tabs from "recently closed" too. | 19 // We use it to restore tabs from "recently closed" too. |
| 18 // static | 20 // static |
| 19 void SessionRestore::RestoreForeignSessionTab( | 21 content::WebContents* SessionRestore::RestoreForeignSessionTab( |
| 20 content::WebContents* web_contents, | 22 content::WebContents* web_contents, |
| 21 const SessionTab& session_tab, | 23 const SessionTab& session_tab, |
| 22 WindowOpenDisposition disposition) { | 24 WindowOpenDisposition disposition) { |
| 23 DCHECK(session_tab.navigations.size() > 0); | 25 DCHECK(session_tab.navigations.size() > 0); |
| 24 content::BrowserContext* context = web_contents->GetBrowserContext(); | 26 content::BrowserContext* context = web_contents->GetBrowserContext(); |
| 25 Profile* profile = Profile::FromBrowserContext(context); | 27 Profile* profile = Profile::FromBrowserContext(context); |
| 26 TabModel* tab_model = TabModelList::GetTabModelWithProfile(profile); | 28 TabModel* tab_model = TabModelList::GetTabModelWithProfile(profile); |
| 27 DCHECK(tab_model); | 29 DCHECK(tab_model); |
| 28 std::vector<content::NavigationEntry*> entries = | 30 std::vector<content::NavigationEntry*> entries = |
| 29 sessions::SerializedNavigationEntry::ToNavigationEntries( | 31 sessions::SerializedNavigationEntry::ToNavigationEntries( |
| 30 session_tab.navigations, profile); | 32 session_tab.navigations, profile); |
| 31 content::WebContents* new_web_contents = content::WebContents::Create( | 33 content::WebContents* new_web_contents = content::WebContents::Create( |
| 32 content::WebContents::CreateParams(context)); | 34 content::WebContents::CreateParams(context)); |
| 33 int selected_index = session_tab.normalized_navigation_index(); | 35 int selected_index = session_tab.normalized_navigation_index(); |
| 34 new_web_contents->GetController().Restore( | 36 new_web_contents->GetController().Restore( |
| 35 selected_index, | 37 selected_index, |
| 36 content::NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, | 38 content::NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, |
| 37 &entries); | 39 &entries); |
| 38 tab_model->CreateTab(new_web_contents); | 40 tab_model->CreateTab(new_web_contents); |
| 41 return new_web_contents; |
| 39 } | 42 } |
| 40 | 43 |
| 41 // static | 44 // static |
| 42 void SessionRestore::RestoreForeignSessionWindows( | 45 std::vector<Browser*> SessionRestore::RestoreForeignSessionWindows( |
| 43 Profile* profile, | 46 Profile* profile, |
| 44 chrome::HostDesktopType host_desktop_type, | 47 chrome::HostDesktopType host_desktop_type, |
| 45 std::vector<const SessionWindow*>::const_iterator begin, | 48 std::vector<const SessionWindow*>::const_iterator begin, |
| 46 std::vector<const SessionWindow*>::const_iterator end) { | 49 std::vector<const SessionWindow*>::const_iterator end) { |
| 47 NOTREACHED(); | 50 NOTREACHED(); |
| 51 return std::vector<Browser*>(); |
| 48 } | 52 } |
| OLD | NEW |