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

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

Issue 1440573003: Remove ScopedVector from NavigationController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 5 years, 1 month 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
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 "base/memory/scoped_vector.h"
10 #include "chrome/browser/android/tab_android.h" 9 #include "chrome/browser/android/tab_android.h"
11 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/android/tab_model/tab_model.h" 11 #include "chrome/browser/ui/android/tab_model/tab_model.h"
13 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" 12 #include "chrome/browser/ui/android/tab_model/tab_model_list.h"
14 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_finder.h" 14 #include "chrome/browser/ui/browser_finder.h"
16 #include "components/sessions/content/content_serialized_navigation_builder.h" 15 #include "components/sessions/content/content_serialized_navigation_builder.h"
17 #include "components/sessions/core/session_types.h" 16 #include "components/sessions/core/session_types.h"
18 #include "content/public/browser/navigation_controller.h" 17 #include "content/public/browser/navigation_controller.h"
19 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
20 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
21 20
22 // The android implementation does not do anything "foreign session" specific. 21 // The android implementation does not do anything "foreign session" specific.
23 // We use it to restore tabs from "recently closed" too. 22 // We use it to restore tabs from "recently closed" too.
24 // static 23 // static
25 content::WebContents* SessionRestore::RestoreForeignSessionTab( 24 content::WebContents* SessionRestore::RestoreForeignSessionTab(
26 content::WebContents* web_contents, 25 content::WebContents* web_contents,
27 const sessions::SessionTab& session_tab, 26 const sessions::SessionTab& session_tab,
28 WindowOpenDisposition disposition) { 27 WindowOpenDisposition disposition) {
29 DCHECK(session_tab.navigations.size() > 0); 28 DCHECK(session_tab.navigations.size() > 0);
30 content::BrowserContext* context = web_contents->GetBrowserContext(); 29 content::BrowserContext* context = web_contents->GetBrowserContext();
31 Profile* profile = Profile::FromBrowserContext(context); 30 Profile* profile = Profile::FromBrowserContext(context);
32 TabModel* tab_model = TabModelList::GetTabModelForWebContents(web_contents); 31 TabModel* tab_model = TabModelList::GetTabModelForWebContents(web_contents);
33 DCHECK(tab_model); 32 DCHECK(tab_model);
34 ScopedVector<content::NavigationEntry> scoped_entries = 33 std::vector<scoped_ptr<content::NavigationEntry>> entries =
35 sessions::ContentSerializedNavigationBuilder::ToNavigationEntries( 34 sessions::ContentSerializedNavigationBuilder::ToNavigationEntries(
36 session_tab.navigations, profile); 35 session_tab.navigations, profile);
37 content::WebContents* new_web_contents = content::WebContents::Create( 36 content::WebContents* new_web_contents = content::WebContents::Create(
38 content::WebContents::CreateParams(context)); 37 content::WebContents::CreateParams(context));
39 int selected_index = session_tab.normalized_navigation_index(); 38 int selected_index = session_tab.normalized_navigation_index();
40 new_web_contents->GetController().Restore( 39 new_web_contents->GetController().Restore(
41 selected_index, 40 selected_index,
42 content::NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, 41 content::NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY,
43 &scoped_entries); 42 &entries);
44 43
45 TabAndroid* current_tab = TabAndroid::FromWebContents(web_contents); 44 TabAndroid* current_tab = TabAndroid::FromWebContents(web_contents);
46 DCHECK(current_tab); 45 DCHECK(current_tab);
47 if (disposition == CURRENT_TAB) { 46 if (disposition == CURRENT_TAB) {
48 current_tab->SwapTabContents(web_contents, new_web_contents, false, false); 47 current_tab->SwapTabContents(web_contents, new_web_contents, false, false);
49 delete web_contents; 48 delete web_contents;
50 } else { 49 } else {
51 DCHECK(disposition == NEW_FOREGROUND_TAB || 50 DCHECK(disposition == NEW_FOREGROUND_TAB ||
52 disposition == NEW_BACKGROUND_TAB); 51 disposition == NEW_BACKGROUND_TAB);
53 tab_model->CreateTab(new_web_contents, current_tab->GetAndroidId()); 52 tab_model->CreateTab(new_web_contents, 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 chrome::HostDesktopType host_desktop_type, 60 chrome::HostDesktopType host_desktop_type,
62 std::vector<const sessions::SessionWindow*>::const_iterator begin, 61 std::vector<const sessions::SessionWindow*>::const_iterator begin,
63 std::vector<const sessions::SessionWindow*>::const_iterator end) { 62 std::vector<const sessions::SessionWindow*>::const_iterator end) {
64 NOTREACHED(); 63 NOTREACHED();
65 return std::vector<Browser*>(); 64 return std::vector<Browser*>();
66 } 65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698