| 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/session_service.h" | 5 #include "chrome/browser/sessions/session_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 const SessionID& window_id, | 480 const SessionID& window_id, |
| 481 const SessionID& tab_id, | 481 const SessionID& tab_id, |
| 482 const std::string& extension_app_id) { | 482 const std::string& extension_app_id) { |
| 483 if (!ShouldTrackChangesToWindow(window_id)) | 483 if (!ShouldTrackChangesToWindow(window_id)) |
| 484 return; | 484 return; |
| 485 | 485 |
| 486 ScheduleCommand(sessions::CreateSetTabExtensionAppIDCommand( | 486 ScheduleCommand(sessions::CreateSetTabExtensionAppIDCommand( |
| 487 tab_id, extension_app_id).Pass()); | 487 tab_id, extension_app_id).Pass()); |
| 488 } | 488 } |
| 489 | 489 |
| 490 void SessionService::SetLastActiveTime(const SessionID& window_id, |
| 491 const SessionID& tab_id, |
| 492 base::TimeTicks last_active_time) { |
| 493 if (!ShouldTrackChangesToWindow(window_id)) |
| 494 return; |
| 495 |
| 496 ScheduleCommand( |
| 497 sessions::CreateLastActiveTimeCommand(tab_id, last_active_time).Pass()); |
| 498 } |
| 499 |
| 490 base::CancelableTaskTracker::TaskId SessionService::GetLastSession( | 500 base::CancelableTaskTracker::TaskId SessionService::GetLastSession( |
| 491 const SessionCallback& callback, | 501 const SessionCallback& callback, |
| 492 base::CancelableTaskTracker* tracker) { | 502 base::CancelableTaskTracker* tracker) { |
| 493 // OnGotSessionCommands maps the SessionCommands to browser state, then run | 503 // OnGotSessionCommands maps the SessionCommands to browser state, then run |
| 494 // the callback. | 504 // the callback. |
| 495 return base_session_service_->ScheduleGetLastSessionCommands( | 505 return base_session_service_->ScheduleGetLastSessionCommands( |
| 496 base::Bind(&SessionService::OnGotSessionCommands, | 506 base::Bind(&SessionService::OnGotSessionCommands, |
| 497 weak_factory_.GetWeakPtr(), | 507 weak_factory_.GetWeakPtr(), |
| 498 callback), | 508 callback), |
| 499 tracker); | 509 tracker); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 if (tab_to_available_range) { | 730 if (tab_to_available_range) { |
| 721 (*tab_to_available_range)[session_id.id()] = | 731 (*tab_to_available_range)[session_id.id()] = |
| 722 std::pair<int, int>(min_index, max_index); | 732 std::pair<int, int>(min_index, max_index); |
| 723 } | 733 } |
| 724 | 734 |
| 725 if (is_pinned) { | 735 if (is_pinned) { |
| 726 base_session_service_->AppendRebuildCommand( | 736 base_session_service_->AppendRebuildCommand( |
| 727 sessions::CreatePinnedStateCommand(session_id, true)); | 737 sessions::CreatePinnedStateCommand(session_id, true)); |
| 728 } | 738 } |
| 729 | 739 |
| 740 if (SessionRestore::GetSmartRestoreMode() == |
| 741 SessionRestore::SMART_RESTORE_MODE_MRU) { |
| 742 base_session_service_->AppendRebuildCommand( |
| 743 sessions::CreateLastActiveTimeCommand(session_id, |
| 744 tab->GetLastActiveTime())); |
| 745 } |
| 746 |
| 730 extensions::TabHelper* extensions_tab_helper = | 747 extensions::TabHelper* extensions_tab_helper = |
| 731 extensions::TabHelper::FromWebContents(tab); | 748 extensions::TabHelper::FromWebContents(tab); |
| 732 if (extensions_tab_helper->extension_app()) { | 749 if (extensions_tab_helper->extension_app()) { |
| 733 base_session_service_->AppendRebuildCommand( | 750 base_session_service_->AppendRebuildCommand( |
| 734 sessions::CreateSetTabExtensionAppIDCommand( | 751 sessions::CreateSetTabExtensionAppIDCommand( |
| 735 session_id, | 752 session_id, |
| 736 extensions_tab_helper->extension_app()->id())); | 753 extensions_tab_helper->extension_app()->id())); |
| 737 } | 754 } |
| 738 | 755 |
| 739 const std::string& ua_override = tab->GetUserAgentOverride(); | 756 const std::string& ua_override = tab->GetUserAgentOverride(); |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 1110 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
| 1094 if ((*it)->profile() == profile()) | 1111 if ((*it)->profile() == profile()) |
| 1095 return; | 1112 return; |
| 1096 } | 1113 } |
| 1097 DeleteSessionOnlyData(profile()); | 1114 DeleteSessionOnlyData(profile()); |
| 1098 } | 1115 } |
| 1099 | 1116 |
| 1100 sessions::BaseSessionService* SessionService::GetBaseSessionServiceForTest() { | 1117 sessions::BaseSessionService* SessionService::GetBaseSessionServiceForTest() { |
| 1101 return base_session_service_.get(); | 1118 return base_session_service_.get(); |
| 1102 } | 1119 } |
| OLD | NEW |