Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Unified Diff: chrome/browser/sessions/session_service.cc

Issue 10969012: Fix: Prerendering was confusing SessionService to not save sessionStorage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sessions/session_service.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_);
+}
« no previous file with comments | « chrome/browser/sessions/session_service.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698