OLD | NEW |
(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 } |
OLD | NEW |