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