Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: chrome/browser/sessions/session_restore_android.cc

Issue 2225343002: Navigation: move RestoreType and ReloadType into a separate file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [rebase] Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/net/predictor_tab_helper.cc ('k') | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
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 "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_finder.h" 14 #include "chrome/browser/ui/browser_finder.h"
15 #include "components/sessions/content/content_serialized_navigation_builder.h" 15 #include "components/sessions/content/content_serialized_navigation_builder.h"
16 #include "components/sessions/core/session_types.h" 16 #include "components/sessions/core/session_types.h"
17 #include "content/public/browser/navigation_controller.h"
18 #include "content/public/browser/navigation_entry.h" 17 #include "content/public/browser/navigation_entry.h"
18 #include "content/public/browser/restore_type.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 20
21 // The android implementation does not do anything "foreign session" specific. 21 // The android implementation does not do anything "foreign session" specific.
22 // We use it to restore tabs from "recently closed" too. 22 // We use it to restore tabs from "recently closed" too.
23 // static 23 // static
24 content::WebContents* SessionRestore::RestoreForeignSessionTab( 24 content::WebContents* SessionRestore::RestoreForeignSessionTab(
25 content::WebContents* web_contents, 25 content::WebContents* web_contents,
26 const sessions::SessionTab& session_tab, 26 const sessions::SessionTab& session_tab,
27 WindowOpenDisposition disposition) { 27 WindowOpenDisposition disposition) {
28 DCHECK(session_tab.navigations.size() > 0); 28 DCHECK(session_tab.navigations.size() > 0);
29 content::BrowserContext* context = web_contents->GetBrowserContext(); 29 content::BrowserContext* context = web_contents->GetBrowserContext();
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 == WindowOpenDisposition::CURRENT_TAB) { 45 if (disposition == WindowOpenDisposition::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 == WindowOpenDisposition::NEW_FOREGROUND_TAB || 49 DCHECK(disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB ||
51 disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB); 50 disposition == WindowOpenDisposition::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 }
OLDNEW
« no previous file with comments | « chrome/browser/net/predictor_tab_helper.cc ('k') | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698