OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/sessions/tab_restore_service.h" | 5 #include "chrome/browser/sessions/tab_restore_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 } | 432 } |
433 | 433 |
434 restoring_ = false; | 434 restoring_ = false; |
435 NotifyTabsChanged(); | 435 NotifyTabsChanged(); |
436 } | 436 } |
437 | 437 |
438 void TabRestoreService::LoadTabsFromLastSession() { | 438 void TabRestoreService::LoadTabsFromLastSession() { |
439 if (load_state_ != NOT_LOADED || entries_.size() == kMaxEntries) | 439 if (load_state_ != NOT_LOADED || entries_.size() == kMaxEntries) |
440 return; | 440 return; |
441 | 441 |
| 442 #if !defined(ENABLE_SESSION_SERVICE) |
| 443 // If sessions are not stored in the SessionService, default to |
| 444 // |LOADED_LAST_SESSION| state. |
| 445 load_state_ = LOADING | LOADED_LAST_SESSION; |
| 446 #else |
442 load_state_ = LOADING; | 447 load_state_ = LOADING; |
443 | 448 |
444 SessionService* session_service = | 449 SessionService* session_service = |
445 SessionServiceFactory::GetForProfile(profile()); | 450 SessionServiceFactory::GetForProfile(profile()); |
446 if (!profile()->restored_last_session() && | 451 if (!profile()->restored_last_session() && |
447 !profile()->DidLastSessionExitCleanly() && | 452 !profile()->DidLastSessionExitCleanly() && |
448 session_service) { | 453 session_service) { |
449 // The previous session crashed and wasn't restored. Load the tabs/windows | 454 // The previous session crashed and wasn't restored. Load the tabs/windows |
450 // that were open at the point of crash from the session service. | 455 // that were open at the point of crash from the session service. |
451 session_service->GetLastSession( | 456 session_service->GetLastSession( |
452 &crash_consumer_, | 457 &crash_consumer_, |
453 base::Bind(&TabRestoreService::OnGotPreviousSession, | 458 base::Bind(&TabRestoreService::OnGotPreviousSession, |
454 base::Unretained(this))); | 459 base::Unretained(this))); |
455 } else { | 460 } else { |
456 load_state_ |= LOADED_LAST_SESSION; | 461 load_state_ |= LOADED_LAST_SESSION; |
457 } | 462 } |
| 463 #endif |
458 | 464 |
459 // Request the tabs closed in the last session. If the last session crashed, | 465 // Request the tabs closed in the last session. If the last session crashed, |
460 // this won't contain the tabs/window that were open at the point of the | 466 // this won't contain the tabs/window that were open at the point of the |
461 // crash (the call to GetLastSession above requests those). | 467 // crash (the call to GetLastSession above requests those). |
462 ScheduleGetLastSessionCommands( | 468 ScheduleGetLastSessionCommands( |
463 new InternalGetCommandsRequest( | 469 new InternalGetCommandsRequest( |
464 base::Bind(&TabRestoreService::OnGotLastSessionCommands, | 470 base::Bind(&TabRestoreService::OnGotLastSessionCommands, |
465 base::Unretained(this))), | 471 base::Unretained(this))), |
466 &load_consumer_); | 472 &load_consumer_); |
467 } | 473 } |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 // the front, not the end and we just added the entries to the end). | 1218 // the front, not the end and we just added the entries to the end). |
1213 entries_to_write_ = staging_entries_.size(); | 1219 entries_to_write_ = staging_entries_.size(); |
1214 | 1220 |
1215 PruneEntries(); | 1221 PruneEntries(); |
1216 NotifyTabsChanged(); | 1222 NotifyTabsChanged(); |
1217 } | 1223 } |
1218 | 1224 |
1219 Time TabRestoreService::TimeNow() const { | 1225 Time TabRestoreService::TimeNow() const { |
1220 return time_factory_ ? time_factory_->TimeNow() : Time::Now(); | 1226 return time_factory_ ? time_factory_->TimeNow() : Time::Now(); |
1221 } | 1227 } |
OLD | NEW |