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