| 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/android/tab_android.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 Profile* profile = Profile::FromBrowserContext(context); | 30 Profile* profile = Profile::FromBrowserContext(context); |
| 31 TabModel* tab_model = TabModelList::GetTabModelForWebContents(web_contents); | 31 TabModel* tab_model = TabModelList::GetTabModelForWebContents(web_contents); |
| 32 DCHECK(tab_model); | 32 DCHECK(tab_model); |
| 33 std::vector<std::unique_ptr<content::NavigationEntry>> entries = | 33 std::vector<std::unique_ptr<content::NavigationEntry>> entries = |
| 34 sessions::ContentSerializedNavigationBuilder::ToNavigationEntries( | 34 sessions::ContentSerializedNavigationBuilder::ToNavigationEntries( |
| 35 session_tab.navigations, profile); | 35 session_tab.navigations, profile); |
| 36 content::WebContents* new_web_contents = content::WebContents::Create( | 36 content::WebContents* new_web_contents = content::WebContents::Create( |
| 37 content::WebContents::CreateParams(context)); | 37 content::WebContents::CreateParams(context)); |
| 38 int selected_index = session_tab.normalized_navigation_index(); | 38 int selected_index = session_tab.normalized_navigation_index(); |
| 39 new_web_contents->GetController().Restore( | 39 new_web_contents->GetController().Restore( |
| 40 selected_index, | 40 selected_index, content::RestoreType::LAST_SESSION_EXITED_CLEANLY, |
| 41 content::NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, | |
| 42 &entries); | 41 &entries); |
| 43 | 42 |
| 44 TabAndroid* current_tab = TabAndroid::FromWebContents(web_contents); | 43 TabAndroid* current_tab = TabAndroid::FromWebContents(web_contents); |
| 45 DCHECK(current_tab); | 44 DCHECK(current_tab); |
| 46 if (disposition == CURRENT_TAB) { | 45 if (disposition == CURRENT_TAB) { |
| 47 current_tab->SwapTabContents(web_contents, new_web_contents, false, false); | 46 current_tab->SwapTabContents(web_contents, new_web_contents, false, false); |
| 48 delete web_contents; | 47 delete web_contents; |
| 49 } else { | 48 } else { |
| 50 DCHECK(disposition == NEW_FOREGROUND_TAB || | 49 DCHECK(disposition == NEW_FOREGROUND_TAB || |
| 51 disposition == NEW_BACKGROUND_TAB); | 50 disposition == NEW_BACKGROUND_TAB); |
| 52 tab_model->CreateTab(current_tab, new_web_contents, | 51 tab_model->CreateTab(current_tab, new_web_contents, |
| 53 current_tab->GetAndroidId()); | 52 current_tab->GetAndroidId()); |
| 54 } | 53 } |
| 55 return new_web_contents; | 54 return new_web_contents; |
| 56 } | 55 } |
| 57 | 56 |
| 58 // static | 57 // static |
| 59 std::vector<Browser*> SessionRestore::RestoreForeignSessionWindows( | 58 std::vector<Browser*> SessionRestore::RestoreForeignSessionWindows( |
| 60 Profile* profile, | 59 Profile* profile, |
| 61 std::vector<const sessions::SessionWindow*>::const_iterator begin, | 60 std::vector<const sessions::SessionWindow*>::const_iterator begin, |
| 62 std::vector<const sessions::SessionWindow*>::const_iterator end) { | 61 std::vector<const sessions::SessionWindow*>::const_iterator end) { |
| 63 NOTREACHED(); | 62 NOTREACHED(); |
| 64 return std::vector<Browser*>(); | 63 return std::vector<Browser*>(); |
| 65 } | 64 } |
| OLD | NEW |