| Index: chrome/browser/sessions/session_service.cc
|
| diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc
|
| index 9dbb0c909e3a181abe0200b5428e81df77c70608..9b5531a9d5f15ad9f933c3dab3079a6aef6a30d0 100644
|
| --- a/chrome/browser/sessions/session_service.cc
|
| +++ b/chrome/browser/sessions/session_service.cc
|
| @@ -618,17 +618,22 @@ void SessionService::Observe(int type,
|
|
|
| // Record the association between the SessionStorageNamespace and the
|
| // tab.
|
| - //
|
| - // TODO(ajwong): This should be processing the whole map rather than
|
| - // just the default. This in particular will not work for tabs with only
|
| - // isolated apps which won't have a default partition.
|
| - content::SessionStorageNamespace* session_storage_namespace =
|
| - tab->web_contents()->GetController().
|
| - GetDefaultSessionStorageNamespace();
|
| - ScheduleCommand(CreateSessionStorageAssociatedCommand(
|
| - tab->restore_tab_helper()->session_id(),
|
| - session_storage_namespace->persistent_id()));
|
| - session_storage_namespace->SetShouldPersist(true);
|
| + // Record the association between all the SessionStorageNamespaces and
|
| + // their containing tab.
|
| + const content::SessionStorageNamespaceMap& session_storage_namespace_map =
|
| + tab->web_contents()->GetController().GetSessionStorageNamespaceMap();
|
| + LOG(ERROR) << "Associating map of size " << session_storage_namespace_map.size();
|
| + for (content::SessionStorageNamespaceMap::const_iterator it =
|
| + session_storage_namespace_map.begin();
|
| + it != session_storage_namespace_map.end();
|
| + ++it) {
|
| + LOG(ERROR) << "Associating --" << it->first << "++ with --" << it->second->persistent_id();
|
| + ScheduleCommand(CreateSessionStorageAssociatedCommand(
|
| + tab->restore_tab_helper()->session_id(),
|
| + it->second->persistent_id(),
|
| + it->first));
|
| + it->second->SetShouldPersist(true);
|
| + }
|
| break;
|
| }
|
|
|
| @@ -638,10 +643,14 @@ void SessionService::Observe(int type,
|
| return;
|
| // Allow the associated sessionStorage to get deleted; it won't be needed
|
| // in the session restore.
|
| - content::SessionStorageNamespace* session_storage_namespace =
|
| - tab->web_contents()->GetController().
|
| - GetDefaultSessionStorageNamespace();
|
| - session_storage_namespace->SetShouldPersist(false);
|
| + const content::SessionStorageNamespaceMap& session_storage_namespace_map =
|
| + tab->web_contents()->GetController().GetSessionStorageNamespaceMap();
|
| + for (content::SessionStorageNamespaceMap::const_iterator it =
|
| + session_storage_namespace_map.begin();
|
| + it != session_storage_namespace_map.end();
|
| + ++it) {
|
| + it->second->SetShouldPersist(false);
|
| + }
|
| TabClosed(tab->restore_tab_helper()->window_id(),
|
| tab->restore_tab_helper()->session_id(),
|
| tab->web_contents()->GetClosedByUserGesture());
|
| @@ -863,10 +872,12 @@ SessionCommand* SessionService::CreatePinnedStateCommand(
|
|
|
| SessionCommand* SessionService::CreateSessionStorageAssociatedCommand(
|
| const SessionID& tab_id,
|
| - const std::string& session_storage_persistent_id) {
|
| + const std::string& session_storage_persistent_id,
|
| + const std::string& partiton_id) {
|
| Pickle pickle;
|
| pickle.WriteInt(tab_id.id());
|
| pickle.WriteString(session_storage_persistent_id);
|
| + pickle.WriteString(partiton_id);
|
| return new SessionCommand(kCommandSessionStorageAssociated, pickle);
|
| }
|
|
|
| @@ -1270,13 +1281,16 @@ bool SessionService::CreateTabsAndWindows(
|
| scoped_ptr<Pickle> command_pickle(command->PayloadAsPickle());
|
| SessionID::id_type command_tab_id;
|
| std::string session_storage_persistent_id;
|
| + std::string partition_id;
|
| PickleIterator iter(*command_pickle.get());
|
| if (!command_pickle->ReadInt(&iter, &command_tab_id) ||
|
| - !command_pickle->ReadString(&iter, &session_storage_persistent_id))
|
| - return true;
|
| + !command_pickle->ReadString(&iter, &session_storage_persistent_id) ||
|
| + !command_pickle->ReadString(&iter, &partition_id))
|
| + continue; // We can safely just lose SessionStorage on a restore.
|
| // Associate the session storage back.
|
| - GetTab(command_tab_id, tabs)->session_storage_persistent_id =
|
| - session_storage_persistent_id;
|
| + GetTab(command_tab_id, tabs)->
|
| + session_storage_persistent_id_map[partition_id] =
|
| + session_storage_persistent_id;
|
| break;
|
| }
|
|
|
| @@ -1350,12 +1364,19 @@ void SessionService::BuildCommandsForTab(
|
| CreateSetTabIndexInWindowCommand(session_id, index_in_window));
|
| }
|
|
|
| - // Record the association between the sessionStorage namespace and the tab.
|
| - content::SessionStorageNamespace* session_storage_namespace =
|
| - tab->web_contents()->GetController().GetDefaultSessionStorageNamespace();
|
| - ScheduleCommand(CreateSessionStorageAssociatedCommand(
|
| - tab->restore_tab_helper()->session_id(),
|
| - session_storage_namespace->persistent_id()));
|
| + // Record the association between the SessionStorageNamespaces and the tab.
|
| + const content::SessionStorageNamespaceMap& session_storage_namespace_map =
|
| + tab->web_contents()->GetController().GetSessionStorageNamespaceMap();
|
| + for (content::SessionStorageNamespaceMap::const_iterator it =
|
| + session_storage_namespace_map.begin();
|
| + it != session_storage_namespace_map.end();
|
| + ++it) {
|
| + // TODO(ajwong): Again I wonder if we should do this?
|
| + it->second->SetShouldPersist(true);
|
| + ScheduleCommand(CreateSessionStorageAssociatedCommand(
|
| + tab->restore_tab_helper()->session_id(),
|
| + it->second->persistent_id(), it->first));
|
| + }
|
| }
|
|
|
| void SessionService::BuildCommandsForBrowser(
|
|
|