| 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 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 commands->push_back( | 1327 commands->push_back( |
| 1328 CreateSetSelectedNavigationIndexCommand(session_id, current_index)); | 1328 CreateSetSelectedNavigationIndexCommand(session_id, current_index)); |
| 1329 | 1329 |
| 1330 if (index_in_window != -1) { | 1330 if (index_in_window != -1) { |
| 1331 commands->push_back( | 1331 commands->push_back( |
| 1332 CreateSetTabIndexInWindowCommand(session_id, index_in_window)); | 1332 CreateSetTabIndexInWindowCommand(session_id, index_in_window)); |
| 1333 } | 1333 } |
| 1334 | 1334 |
| 1335 // Record the association between the sessionStorage namespace and the tab. | 1335 // Record the association between the sessionStorage namespace and the tab. |
| 1336 content::SessionStorageNamespace* session_storage_namespace = | 1336 content::SessionStorageNamespace* session_storage_namespace = |
| 1337 tab->GetController().GetDefaultSessionStorageNamespace(); | 1337 tab->GetController().GetSessionStorageNamespace(); |
| 1338 ScheduleCommand(CreateSessionStorageAssociatedCommand( | 1338 ScheduleCommand(CreateSessionStorageAssociatedCommand( |
| 1339 session_tab_helper->session_id(), | 1339 session_tab_helper->session_id(), |
| 1340 session_storage_namespace->persistent_id())); | 1340 session_storage_namespace->persistent_id())); |
| 1341 } | 1341 } |
| 1342 | 1342 |
| 1343 void SessionService::BuildCommandsForBrowser( | 1343 void SessionService::BuildCommandsForBrowser( |
| 1344 Browser* browser, | 1344 Browser* browser, |
| 1345 std::vector<SessionCommand*>* commands, | 1345 std::vector<SessionCommand*>* commands, |
| 1346 IdToRange* tab_to_available_range, | 1346 IdToRange* tab_to_available_range, |
| 1347 std::set<SessionID::id_type>* windows_to_track) { | 1347 std::set<SessionID::id_type>* windows_to_track) { |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1729 if (extensions_tab_helper && | 1729 if (extensions_tab_helper && |
| 1730 extensions_tab_helper->extension_app()) { | 1730 extensions_tab_helper->extension_app()) { |
| 1731 SetTabExtensionAppID( | 1731 SetTabExtensionAppID( |
| 1732 session_tab_helper->window_id(), | 1732 session_tab_helper->window_id(), |
| 1733 session_tab_helper->session_id(), | 1733 session_tab_helper->session_id(), |
| 1734 extensions_tab_helper->extension_app()->id()); | 1734 extensions_tab_helper->extension_app()->id()); |
| 1735 } | 1735 } |
| 1736 | 1736 |
| 1737 // Record the association between the SessionStorageNamespace and the | 1737 // Record the association between the SessionStorageNamespace and the |
| 1738 // tab. | 1738 // tab. |
| 1739 // | |
| 1740 // TODO(ajwong): This should be processing the whole map rather than | |
| 1741 // just the default. This in particular will not work for tabs with only | |
| 1742 // isolated apps which won't have a default partition. | |
| 1743 content::SessionStorageNamespace* session_storage_namespace = | 1739 content::SessionStorageNamespace* session_storage_namespace = |
| 1744 contents->GetController().GetDefaultSessionStorageNamespace(); | 1740 contents->GetController().GetSessionStorageNamespace(); |
| 1745 ScheduleCommand(CreateSessionStorageAssociatedCommand( | 1741 ScheduleCommand(CreateSessionStorageAssociatedCommand( |
| 1746 session_tab_helper->session_id(), | 1742 session_tab_helper->session_id(), |
| 1747 session_storage_namespace->persistent_id())); | 1743 session_storage_namespace->persistent_id())); |
| 1748 session_storage_namespace->SetShouldPersist(true); | 1744 session_storage_namespace->SetShouldPersist(true); |
| 1749 } | 1745 } |
| 1750 | 1746 |
| 1751 void SessionService::TabClosing(WebContents* contents) { | 1747 void SessionService::TabClosing(WebContents* contents) { |
| 1752 // Allow the associated sessionStorage to get deleted; it won't be needed | 1748 // Allow the associated sessionStorage to get deleted; it won't be needed |
| 1753 // in the session restore. | 1749 // in the session restore. |
| 1754 content::SessionStorageNamespace* session_storage_namespace = | 1750 content::SessionStorageNamespace* session_storage_namespace = |
| 1755 contents->GetController().GetDefaultSessionStorageNamespace(); | 1751 contents->GetController().GetSessionStorageNamespace(); |
| 1756 session_storage_namespace->SetShouldPersist(false); | 1752 session_storage_namespace->SetShouldPersist(false); |
| 1757 SessionTabHelper* session_tab_helper = | 1753 SessionTabHelper* session_tab_helper = |
| 1758 SessionTabHelper::FromWebContents(contents); | 1754 SessionTabHelper::FromWebContents(contents); |
| 1759 TabClosed(session_tab_helper->window_id(), | 1755 TabClosed(session_tab_helper->window_id(), |
| 1760 session_tab_helper->session_id(), | 1756 session_tab_helper->session_id(), |
| 1761 contents->GetClosedByUserGesture()); | 1757 contents->GetClosedByUserGesture()); |
| 1762 RecordSessionUpdateHistogramData(content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1758 RecordSessionUpdateHistogramData(content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1763 &last_updated_tab_closed_time_); | 1759 &last_updated_tab_closed_time_); |
| 1764 } | 1760 } |
| OLD | NEW |