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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sessions/session_restore_android.cc
diff --git a/chrome/browser/sessions/session_restore_android.cc b/chrome/browser/sessions/session_restore_android.cc
index e283e88b70f6ec0fa3ef89b0057350d039fe2ec3..b842af6fb3c25e2b09f46b38706bc1dadc3082af 100644
--- a/chrome/browser/sessions/session_restore_android.cc
+++ b/chrome/browser/sessions/session_restore_android.cc
@@ -6,14 +6,45 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/session_types.h"
-#include "webkit/glue/window_open_disposition.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/android/tab_model/tab_model.h"
+#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
+#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/web_contents.h"
+#include "ipc/ipc_message.h"
// static
+// The android implementation does not do anything "foreign session" specific.
+// We use it to restore tabs from "recently closed" too.
void SessionRestore::RestoreForeignSessionTab(
- content::WebContents* source_web_contents,
+ content::WebContents* web_contents,
const SessionTab& session_tab,
WindowOpenDisposition disposition) {
- NOTIMPLEMENTED() << "TODO(yfriedman, dtrainor): Upstream this.";
+ content::BrowserContext* context = web_contents->GetBrowserContext();
+ Profile* profile = Profile::FromBrowserContext(context);
+ TabModel* tab_model = TabModelList::GetTabModelWithProfile(profile);
+ DCHECK(tab_model);
+ std::vector<content::NavigationEntry*> entries;
+ TabNavigation::CreateNavigationEntriesFromTabNavigations(
+ profile, session_tab.navigations, &entries);
+ content::WebContents* new_web_contents = content::WebContents::Create(
+ context, NULL, MSG_ROUTING_NONE, 0, 0);
+ int selected_index = session_tab.current_navigation_index;
+ // Since the current_navigation_index can be larger than the index for number
+ // of navigations in the current sessions (chrome://newtab is not stored), we
+ // must perform bounds checking. Lowest value allowed is 0, so we need to
+ // check for max if navigations.size() == 0 or if selected_index is negative.
+ selected_index = std::max(
+ 0,
+ std::min(selected_index,
+ static_cast<int>(session_tab.navigations.size() - 1)));
+ if (session_tab.navigations.size() > 0) {
+ new_web_contents->GetController().Restore(selected_index,
+ true, /* from_last_session */
+ &entries);
+ }
+ tab_model->CreateTab(new_web_contents);
}
// static
@@ -21,5 +52,5 @@ void SessionRestore::RestoreForeignSessionWindows(
Profile* profile,
std::vector<const SessionWindow*>::const_iterator begin,
std::vector<const SessionWindow*>::const_iterator end) {
- NOTREACHED();
+ NOTIMPLEMENTED();
Yaron 2012/08/01 20:45:02 This should remain NOTREACHED. We have no plans to
felipeg 2012/08/02 13:07:01 Done.
}
« no previous file with comments | « no previous file | chrome/browser/sessions/session_service_factory.cc » ('j') | chrome/browser/sessions/tab_restore_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698