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

Unified Diff: chrome/browser/sessions/chrome_tab_restore_service_client.cc

Issue 1319473014: Introduce TabRestoreServiceClient and //chrome implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to review Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sessions/chrome_tab_restore_service_client.cc
diff --git a/chrome/browser/sessions/chrome_tab_restore_service_client.cc b/chrome/browser/sessions/chrome_tab_restore_service_client.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1eb5e910082b2ecafaa4e8cb77f4603826361d74
--- /dev/null
+++ b/chrome/browser/sessions/chrome_tab_restore_service_client.cc
@@ -0,0 +1,41 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sessions/chrome_tab_restore_service_client.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sessions/session_service.h"
+#include "chrome/browser/sessions/session_service_factory.h"
+
+ChromeTabRestoreServiceClient::ChromeTabRestoreServiceClient(Profile* profile)
+ : profile_(profile) {}
+
+ChromeTabRestoreServiceClient::~ChromeTabRestoreServiceClient() {}
+
+bool ChromeTabRestoreServiceClient::HasLastSession() {
+#if defined(ENABLE_SESSION_SERVICE)
+ SessionService* session_service =
+ SessionServiceFactory::GetForProfile(profile_);
+ Profile::ExitType exit_type = profile_->GetLastSessionExitType();
+ // The previous session crashed and wasn't restored, or was a forced
+ // shutdown. Both of which won't have notified us of the browser close so
+ // that we need to load the windows from session service (which will have
+ // saved them).
+ return (!profile_->restored_last_session() && session_service &&
+ (exit_type == Profile::EXIT_CRASHED ||
+ exit_type == Profile::EXIT_SESSION_ENDED));
+#else
+ return false;
+#endif
+}
+
+void ChromeTabRestoreServiceClient::GetLastSession(
+ const sessions::GetLastSessionCallback& callback,
+ base::CancelableTaskTracker* tracker) {
+ DCHECK(HasLastSession());
+#if defined(ENABLE_SESSION_SERVICE)
+ SessionServiceFactory::GetForProfile(profile_)
+ ->GetLastSession(callback, tracker);
+#endif
+}
« no previous file with comments | « chrome/browser/sessions/chrome_tab_restore_service_client.h ('k') | chrome/browser/sessions/in_memory_tab_restore_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698