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