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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sessions/chrome_tab_restore_service_client.h"
6
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/sessions/session_service.h"
9 #include "chrome/browser/sessions/session_service_factory.h"
10
11 ChromeTabRestoreServiceClient::ChromeTabRestoreServiceClient(Profile* profile)
12 : profile_(profile) {}
13
14 ChromeTabRestoreServiceClient::~ChromeTabRestoreServiceClient() {}
15
16 bool ChromeTabRestoreServiceClient::HasLastSession() {
17 #if defined(ENABLE_SESSION_SERVICE)
18 SessionService* session_service =
19 SessionServiceFactory::GetForProfile(profile_);
20 Profile::ExitType exit_type = profile_->GetLastSessionExitType();
21 // The previous session crashed and wasn't restored, or was a forced
22 // shutdown. Both of which won't have notified us of the browser close so
23 // that we need to load the windows from session service (which will have
24 // saved them).
25 return (!profile_->restored_last_session() && session_service &&
26 (exit_type == Profile::EXIT_CRASHED ||
27 exit_type == Profile::EXIT_SESSION_ENDED));
28 #else
29 return false;
30 #endif
31 }
32
33 void ChromeTabRestoreServiceClient::GetLastSession(
34 const sessions::GetLastSessionCallback& callback,
35 base::CancelableTaskTracker* tracker) {
36 DCHECK(HasLastSession());
37 #if defined(ENABLE_SESSION_SERVICE)
38 SessionServiceFactory::GetForProfile(profile_)
39 ->GetLastSession(callback, tracker);
40 #endif
41 }
OLDNEW
« 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