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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 } | 475 } |
476 | 476 |
477 void SessionService::SetSelectedTabInWindow(const SessionID& window_id, | 477 void SessionService::SetSelectedTabInWindow(const SessionID& window_id, |
478 int index) { | 478 int index) { |
479 if (!ShouldTrackChangesToWindow(window_id)) | 479 if (!ShouldTrackChangesToWindow(window_id)) |
480 return; | 480 return; |
481 | 481 |
482 ScheduleCommand(CreateSetSelectedTabInWindow(window_id, index)); | 482 ScheduleCommand(CreateSetSelectedTabInWindow(window_id, index)); |
483 } | 483 } |
484 | 484 |
| 485 void SessionService::SetTabUserAgentOverride( |
| 486 const SessionID& window_id, |
| 487 const SessionID& tab_id, |
| 488 const std::string& user_agent_override) { |
| 489 if (!ShouldTrackChangesToWindow(window_id)) |
| 490 return; |
| 491 |
| 492 ScheduleCommand(CreateSetTabUserAgentOverrideCommand( |
| 493 kCommandSetTabUserAgentOverride, |
| 494 tab_id.id(), |
| 495 user_agent_override)); |
| 496 } |
| 497 |
485 SessionService::Handle SessionService::GetLastSession( | 498 SessionService::Handle SessionService::GetLastSession( |
486 CancelableRequestConsumerBase* consumer, | 499 CancelableRequestConsumerBase* consumer, |
487 const SessionCallback& callback) { | 500 const SessionCallback& callback) { |
488 return ScheduleGetLastSessionCommands( | 501 return ScheduleGetLastSessionCommands( |
489 new InternalSessionRequest( | 502 new InternalSessionRequest( |
490 base::Bind(&SessionService::OnGotSessionCommands, | 503 base::Bind(&SessionService::OnGotSessionCommands, |
491 base::Unretained(this)), | 504 base::Unretained(this)), |
492 callback), | 505 callback), |
493 consumer); | 506 consumer); |
494 } | 507 } |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 const std::string& extension_app_id) { | 739 const std::string& extension_app_id) { |
727 if (!ShouldTrackChangesToWindow(window_id)) | 740 if (!ShouldTrackChangesToWindow(window_id)) |
728 return; | 741 return; |
729 | 742 |
730 ScheduleCommand(CreateSetTabExtensionAppIDCommand( | 743 ScheduleCommand(CreateSetTabExtensionAppIDCommand( |
731 kCommandSetExtensionAppID, | 744 kCommandSetExtensionAppID, |
732 tab_id.id(), | 745 tab_id.id(), |
733 extension_app_id)); | 746 extension_app_id)); |
734 } | 747 } |
735 | 748 |
736 void SessionService::SetTabUserAgentOverride( | |
737 const SessionID& window_id, | |
738 const SessionID& tab_id, | |
739 const std::string& user_agent_override) { | |
740 if (!ShouldTrackChangesToWindow(window_id)) | |
741 return; | |
742 | |
743 ScheduleCommand(CreateSetTabUserAgentOverrideCommand( | |
744 kCommandSetTabUserAgentOverride, | |
745 tab_id.id(), | |
746 user_agent_override)); | |
747 } | |
748 | |
749 SessionCommand* SessionService::CreateSetSelectedTabInWindow( | 749 SessionCommand* SessionService::CreateSetSelectedTabInWindow( |
750 const SessionID& window_id, | 750 const SessionID& window_id, |
751 int index) { | 751 int index) { |
752 SelectedTabInIndexPayload payload = { 0 }; | 752 SelectedTabInIndexPayload payload = { 0 }; |
753 payload.id = window_id.id(); | 753 payload.id = window_id.id(); |
754 payload.index = index; | 754 payload.index = index; |
755 SessionCommand* command = new SessionCommand(kCommandSetSelectedTabInIndex, | 755 SessionCommand* command = new SessionCommand(kCommandSetSelectedTabInIndex, |
756 sizeof(payload)); | 756 sizeof(payload)); |
757 memcpy(command->contents(), &payload, sizeof(payload)); | 757 memcpy(command->contents(), &payload, sizeof(payload)); |
758 return command; | 758 return command; |
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 50); | 1731 50); |
1732 if (use_long_period) { | 1732 if (use_long_period) { |
1733 std::string long_name_("SessionRestore.SaveLongPeriod"); | 1733 std::string long_name_("SessionRestore.SaveLongPeriod"); |
1734 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, | 1734 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, |
1735 delta, | 1735 delta, |
1736 save_delay_in_mins_, | 1736 save_delay_in_mins_, |
1737 save_delay_in_hrs_, | 1737 save_delay_in_hrs_, |
1738 50); | 1738 50); |
1739 } | 1739 } |
1740 } | 1740 } |
OLD | NEW |