| 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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 tab->restore_tab_helper()->session_id()); | 598 tab->restore_tab_helper()->session_id()); |
| 599 if (tab->extension_tab_helper()->extension_app()) { | 599 if (tab->extension_tab_helper()->extension_app()) { |
| 600 SetTabExtensionAppID( | 600 SetTabExtensionAppID( |
| 601 tab->restore_tab_helper()->window_id(), | 601 tab->restore_tab_helper()->window_id(), |
| 602 tab->restore_tab_helper()->session_id(), | 602 tab->restore_tab_helper()->session_id(), |
| 603 tab->extension_tab_helper()->extension_app()->id()); | 603 tab->extension_tab_helper()->extension_app()->id()); |
| 604 } | 604 } |
| 605 | 605 |
| 606 // Record the association between the SessionStorageNamespace and the | 606 // Record the association between the SessionStorageNamespace and the |
| 607 // tab. | 607 // tab. |
| 608 // |
| 609 // TODO(ajwong): This should be processing the whole map rather than |
| 610 // just the default. This in particular will not work for tabs with only |
| 611 // isolated apps which won't have a default partition. |
| 608 content::SessionStorageNamespace* session_storage_namespace = | 612 content::SessionStorageNamespace* session_storage_namespace = |
| 609 tab->web_contents()->GetController().GetSessionStorageNamespace(); | 613 tab->web_contents()->GetController(). |
| 614 GetDefaultSessionStorageNamespace(); |
| 610 ScheduleCommand(CreateSessionStorageAssociatedCommand( | 615 ScheduleCommand(CreateSessionStorageAssociatedCommand( |
| 611 tab->restore_tab_helper()->session_id(), | 616 tab->restore_tab_helper()->session_id(), |
| 612 session_storage_namespace->persistent_id())); | 617 session_storage_namespace->persistent_id())); |
| 613 session_storage_namespace->SetShouldPersist(true); | 618 session_storage_namespace->SetShouldPersist(true); |
| 614 break; | 619 break; |
| 615 } | 620 } |
| 616 | 621 |
| 617 case chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED: { | 622 case chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED: { |
| 618 TabContents* tab = content::Source<TabContents>(source).ptr(); | 623 TabContents* tab = content::Source<TabContents>(source).ptr(); |
| 619 if (!tab || tab->profile() != profile()) | 624 if (!tab || tab->profile() != profile()) |
| 620 return; | 625 return; |
| 621 // Allow the associated sessionStorage to get deleted; it won't be needed | 626 // Allow the associated sessionStorage to get deleted; it won't be needed |
| 622 // in the session restore. | 627 // in the session restore. |
| 623 content::SessionStorageNamespace* session_storage_namespace = | 628 content::SessionStorageNamespace* session_storage_namespace = |
| 624 tab->web_contents()->GetController().GetSessionStorageNamespace(); | 629 tab->web_contents()->GetController(). |
| 630 GetDefaultSessionStorageNamespace(); |
| 625 session_storage_namespace->SetShouldPersist(false); | 631 session_storage_namespace->SetShouldPersist(false); |
| 626 TabClosed(tab->restore_tab_helper()->window_id(), | 632 TabClosed(tab->restore_tab_helper()->window_id(), |
| 627 tab->restore_tab_helper()->session_id(), | 633 tab->restore_tab_helper()->session_id(), |
| 628 tab->web_contents()->GetClosedByUserGesture()); | 634 tab->web_contents()->GetClosedByUserGesture()); |
| 629 RecordSessionUpdateHistogramData(type, &last_updated_tab_closed_time_); | 635 RecordSessionUpdateHistogramData(type, &last_updated_tab_closed_time_); |
| 630 break; | 636 break; |
| 631 } | 637 } |
| 632 | 638 |
| 633 case content::NOTIFICATION_NAV_LIST_PRUNED: { | 639 case content::NOTIFICATION_NAV_LIST_PRUNED: { |
| 634 TabContents* tab = TabContents::FromWebContents( | 640 TabContents* tab = TabContents::FromWebContents( |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 commands->push_back( | 1345 commands->push_back( |
| 1340 CreateSetSelectedNavigationIndexCommand(session_id, current_index)); | 1346 CreateSetSelectedNavigationIndexCommand(session_id, current_index)); |
| 1341 | 1347 |
| 1342 if (index_in_window != -1) { | 1348 if (index_in_window != -1) { |
| 1343 commands->push_back( | 1349 commands->push_back( |
| 1344 CreateSetTabIndexInWindowCommand(session_id, index_in_window)); | 1350 CreateSetTabIndexInWindowCommand(session_id, index_in_window)); |
| 1345 } | 1351 } |
| 1346 | 1352 |
| 1347 // Record the association between the sessionStorage namespace and the tab. | 1353 // Record the association between the sessionStorage namespace and the tab. |
| 1348 content::SessionStorageNamespace* session_storage_namespace = | 1354 content::SessionStorageNamespace* session_storage_namespace = |
| 1349 tab->web_contents()->GetController().GetSessionStorageNamespace(); | 1355 tab->web_contents()->GetController().GetDefaultSessionStorageNamespace(); |
| 1350 ScheduleCommand(CreateSessionStorageAssociatedCommand( | 1356 ScheduleCommand(CreateSessionStorageAssociatedCommand( |
| 1351 tab->restore_tab_helper()->session_id(), | 1357 tab->restore_tab_helper()->session_id(), |
| 1352 session_storage_namespace->persistent_id())); | 1358 session_storage_namespace->persistent_id())); |
| 1353 } | 1359 } |
| 1354 | 1360 |
| 1355 void SessionService::BuildCommandsForBrowser( | 1361 void SessionService::BuildCommandsForBrowser( |
| 1356 Browser* browser, | 1362 Browser* browser, |
| 1357 std::vector<SessionCommand*>* commands, | 1363 std::vector<SessionCommand*>* commands, |
| 1358 IdToRange* tab_to_available_range, | 1364 IdToRange* tab_to_available_range, |
| 1359 std::set<SessionID::id_type>* windows_to_track) { | 1365 std::set<SessionID::id_type>* windows_to_track) { |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1725 50); | 1731 50); |
| 1726 if (use_long_period) { | 1732 if (use_long_period) { |
| 1727 std::string long_name_("SessionRestore.SaveLongPeriod"); | 1733 std::string long_name_("SessionRestore.SaveLongPeriod"); |
| 1728 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, | 1734 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, |
| 1729 delta, | 1735 delta, |
| 1730 save_delay_in_mins_, | 1736 save_delay_in_mins_, |
| 1731 save_delay_in_hrs_, | 1737 save_delay_in_hrs_, |
| 1732 50); | 1738 50); |
| 1733 } | 1739 } |
| 1734 } | 1740 } |
| OLD | NEW |