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::SetActivationTime(const SessionID& window_id, | |
491 const SessionID& tab_id, | |
492 base::TimeTicks activation_time) { | |
493 if (!ShouldTrackChangesToWindow(window_id)) | |
494 return; | |
495 | |
496 ScheduleCommand( | |
sky
2015/05/12 21:25:30
Don't you want to gate this by SessionRestore::Get
Georges Khalil
2015/05/15 16:55:30
Good idea. I'm actually going to gate the call to
| |
497 sessions::CreateActivationTimeCommand(tab_id, activation_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 // This works because we are persisting the last activation when restoring | |
sky
2015/05/12 21:25:30
I don't understand this comment. It likely can be
Georges Khalil
2015/05/15 16:55:30
Removed.
| |
741 // tabs. | |
742 base_session_service_->AppendRebuildCommand( | |
743 sessions::CreateActivationTimeCommand(session_id, | |
744 tab->GetLastActiveTime())); | |
745 | |
730 extensions::TabHelper* extensions_tab_helper = | 746 extensions::TabHelper* extensions_tab_helper = |
731 extensions::TabHelper::FromWebContents(tab); | 747 extensions::TabHelper::FromWebContents(tab); |
732 if (extensions_tab_helper->extension_app()) { | 748 if (extensions_tab_helper->extension_app()) { |
733 base_session_service_->AppendRebuildCommand( | 749 base_session_service_->AppendRebuildCommand( |
734 sessions::CreateSetTabExtensionAppIDCommand( | 750 sessions::CreateSetTabExtensionAppIDCommand( |
735 session_id, | 751 session_id, |
736 extensions_tab_helper->extension_app()->id())); | 752 extensions_tab_helper->extension_app()->id())); |
737 } | 753 } |
738 | 754 |
739 const std::string& ua_override = tab->GetUserAgentOverride(); | 755 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()) { | 1109 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
1094 if ((*it)->profile() == profile()) | 1110 if ((*it)->profile() == profile()) |
1095 return; | 1111 return; |
1096 } | 1112 } |
1097 DeleteSessionOnlyData(profile()); | 1113 DeleteSessionOnlyData(profile()); |
1098 } | 1114 } |
1099 | 1115 |
1100 sessions::BaseSessionService* SessionService::GetBaseSessionServiceForTest() { | 1116 sessions::BaseSessionService* SessionService::GetBaseSessionServiceForTest() { |
1101 return base_session_service_.get(); | 1117 return base_session_service_.get(); |
1102 } | 1118 } |
OLD | NEW |