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

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

Issue 10832080: Upstream session_backend_android. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/glue/window_open_disposition.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h"
11 #include "chrome/browser/ui/android/tab_model/tab_model.h"
12 #include "chrome/browser/ui/android/tab_model/tab_model_list.h"
13 #include "content/public/browser/navigation_controller.h"
14 #include "content/public/browser/web_contents.h"
15 #include "ipc/ipc_message.h"
10 16
11 // static 17 // static
18 // The android implementation does not do anything "foreign session" specific.
19 // We use it to restore tabs from "recently closed" too.
12 void SessionRestore::RestoreForeignSessionTab( 20 void SessionRestore::RestoreForeignSessionTab(
13 content::WebContents* source_web_contents, 21 content::WebContents* web_contents,
14 const SessionTab& session_tab, 22 const SessionTab& session_tab,
15 WindowOpenDisposition disposition) { 23 WindowOpenDisposition disposition) {
16 NOTIMPLEMENTED() << "TODO(yfriedman, dtrainor): Upstream this."; 24 // FIXME: This is ugly, but right now we don't have a better way of getting
25 // the profile from here.
26 Profile* profile = static_cast<Profile*>(web_contents->GetBrowserContext());
27 TabModel* tab_model = TabModelList::GetTabModelWithProfile(profile);
28 DCHECK(tab_model);
29
30 std::vector<content::NavigationEntry*> entries;
31 TabNavigation::CreateNavigationEntriesFromTabNavigations(
32 profile, session_tab.navigations, &entries);
33 content::BrowserContext* context = profile;
34 content::WebContents* new_web_contents = content::WebContents::Create(
35 context, NULL, MSG_ROUTING_NONE, 0, 0);
36 int selected_index = session_tab.current_navigation_index;
37 // Since the current_navigation_index can be larger than the index for number
38 // of navigations in the current sessions (chrome://newtab is not stored), we
39 // must perform bounds checking. Lowest value allowed is 0, so we need to
40 // check for max if navigations.size() == 0 or if selected_index is negative.
41 selected_index = std::max(
42 0,
43 std::min(selected_index,
44 static_cast<int>(session_tab.navigations.size() - 1)));
sky 2012/07/31 15:26:09 This is problematic if navigations is empty
felipeg 2012/08/01 16:00:58 Good catch. I am surprised that we did not see the
45 new_web_contents->GetController().Restore(selected_index,
46 true, /* from_last_session */
47 &entries);
48 tab_model->CreateTab(new_web_contents);
17 } 49 }
18 50
19 // static 51 // static
20 void SessionRestore::RestoreForeignSessionWindows( 52 void SessionRestore::RestoreForeignSessionWindows(
21 Profile* profile, 53 Profile* profile,
22 std::vector<const SessionWindow*>::const_iterator begin, 54 std::vector<const SessionWindow*>::const_iterator begin,
23 std::vector<const SessionWindow*>::const_iterator end) { 55 std::vector<const SessionWindow*>::const_iterator end) {
24 NOTREACHED(); 56 NOTIMPLEMENTED();
25 } 57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698