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

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: Build fixes 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 #include "chrome/browser/sessions/session_service_utils.h"
11
12 ChromeTabRestoreServiceClient::ChromeTabRestoreServiceClient(Profile* profile)
13 : profile_(profile) {}
14
15 ChromeTabRestoreServiceClient::~ChromeTabRestoreServiceClient() {}
16
17 int ChromeTabRestoreServiceClient::GetMaxPersistNavigationCount() {
18 #if defined(OS_ANDROID)
19 // Android does persistence in Java (and does not build the code that
20 // defines |gMaxPersistNavigationCount|.
21 NOTREACHED();
22 return 0;
23 #else
24 return gMaxPersistNavigationCount;
25 #endif
26 }
27
28 bool ChromeTabRestoreServiceClient::HasLastSession() {
29 #if defined(ENABLE_SESSION_SERVICE)
30 SessionService* session_service =
31 SessionServiceFactory::GetForProfile(profile_);
32 Profile::ExitType exit_type = profile_->GetLastSessionExitType();
33 // The previous session crashed and wasn't restored, or was a forced
34 // shutdown. Both of which won't have notified us of the browser close so
35 // that we need to load the windows from session service (which will have
36 // saved them).
37 return (!profile_->restored_last_session() && session_service &&
38 (exit_type == Profile::EXIT_CRASHED ||
39 exit_type == Profile::EXIT_SESSION_ENDED));
40 #else
41 return false;
42 #endif
43 }
44
45 void ChromeTabRestoreServiceClient::GetLastSession(
46 const sessions::GotLastSessionCallback& callback,
47 base::CancelableTaskTracker* tracker) {
48 DCHECK(HasLastSession());
49 #if defined(ENABLE_SESSION_SERVICE)
50 SessionServiceFactory::GetForProfile(profile_)
51 ->GetLastSession(callback, tracker);
52 #endif
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698