Index: chrome/browser/sessions/session_service.cc |
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc |
index eb406fcf225fc6110bc78af3b84e270b8ac66967..4d63bbf2ffa5a80bff1d432b4d9ddf617d70342e 100644 |
--- a/chrome/browser/sessions/session_service.cc |
+++ b/chrome/browser/sessions/session_service.cc |
@@ -521,10 +521,6 @@ void SessionService::Save() { |
void SessionService::Init() { |
// Register for the notifications we're interested in. |
- registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED, |
- content::NotificationService::AllSources()); |
- registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
- content::NotificationService::AllSources()); |
registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED, |
content::NotificationService::AllSources()); |
registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED, |
@@ -602,58 +598,6 @@ void SessionService::Observe(int type, |
break; |
} |
- case chrome::NOTIFICATION_TAB_PARENTED: { |
- WebContents* web_contents = content::Source<WebContents>(source).ptr(); |
- if (web_contents->GetBrowserContext() != profile()) |
- return; |
- SessionTabHelper* session_tab_helper = |
- SessionTabHelper::FromWebContents(web_contents); |
- SetTabWindow(session_tab_helper->window_id(), |
- session_tab_helper->session_id()); |
- extensions::TabHelper* extensions_tab_helper = |
- extensions::TabHelper::FromWebContents(web_contents); |
- if (extensions_tab_helper && |
- extensions_tab_helper->extension_app()) { |
- SetTabExtensionAppID( |
- session_tab_helper->window_id(), |
- session_tab_helper->session_id(), |
- extensions_tab_helper->extension_app()->id()); |
- } |
- |
- // 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 = |
- web_contents->GetController().GetDefaultSessionStorageNamespace(); |
- ScheduleCommand(CreateSessionStorageAssociatedCommand( |
- session_tab_helper->session_id(), |
- session_storage_namespace->persistent_id())); |
- session_storage_namespace->SetShouldPersist(true); |
- break; |
- } |
- |
- case chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED: { |
- TabContents* tab = content::Source<TabContents>(source).ptr(); |
- if (!tab || tab->profile() != profile()) |
- 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); |
- SessionTabHelper* session_tab_helper = |
- SessionTabHelper::FromWebContents(tab->web_contents()); |
- TabClosed(session_tab_helper->window_id(), |
- session_tab_helper->session_id(), |
- tab->web_contents()->GetClosedByUserGesture()); |
- RecordSessionUpdateHistogramData(type, &last_updated_tab_closed_time_); |
- break; |
- } |
- |
case content::NOTIFICATION_NAV_LIST_PRUNED: { |
WebContents* web_contents = |
content::Source<content::NavigationController>(source).ptr()-> |
@@ -1763,3 +1707,47 @@ void SessionService::RecordUpdatedSaveTime(base::TimeDelta delta, |
50); |
} |
} |
+ |
+void SessionService::TabInserted(WebContents* contents) { |
+ SessionTabHelper* session_tab_helper = |
+ SessionTabHelper::FromWebContents(contents); |
+ SetTabWindow(session_tab_helper->window_id(), |
+ session_tab_helper->session_id()); |
+ extensions::TabHelper* extensions_tab_helper = |
+ extensions::TabHelper::FromWebContents(contents); |
+ if (extensions_tab_helper && |
+ extensions_tab_helper->extension_app()) { |
+ SetTabExtensionAppID( |
+ session_tab_helper->window_id(), |
+ session_tab_helper->session_id(), |
+ extensions_tab_helper->extension_app()->id()); |
+ } |
+ |
+ // 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 = |
+ contents->GetController().GetDefaultSessionStorageNamespace(); |
+ ScheduleCommand(CreateSessionStorageAssociatedCommand( |
+ session_tab_helper->session_id(), |
+ session_storage_namespace->persistent_id())); |
+ session_storage_namespace->SetShouldPersist(true); |
+} |
+ |
+void SessionService::TabClosing(WebContents* contents) { |
+ // Allow the associated sessionStorage to get deleted; it won't be needed |
+ // in the session restore. |
+ content::SessionStorageNamespace* session_storage_namespace = |
+ contents->GetController().GetDefaultSessionStorageNamespace(); |
+ session_storage_namespace->SetShouldPersist(false); |
+ SessionTabHelper* session_tab_helper = |
+ SessionTabHelper::FromWebContents(contents); |
+ TabClosed(session_tab_helper->window_id(), |
+ session_tab_helper->session_id(), |
+ contents->GetClosedByUserGesture()); |
+ RecordSessionUpdateHistogramData(chrome::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
+ &last_updated_tab_closed_time_); |
+} |