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

Unified Diff: chrome/browser/ui/startup/session_crashed_prompt.cc

Issue 9963107: Persist sessionStorage on disk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: session only rules Created 8 years, 6 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
Index: chrome/browser/ui/startup/session_crashed_prompt.cc
diff --git a/chrome/browser/ui/startup/session_crashed_prompt.cc b/chrome/browser/ui/startup/session_crashed_prompt.cc
index b8abd19503db5ab8c0daebbd3681f4b87b35dfdd..f79c1c613d2c0c9043d2ba88cdd115c47fdcad34 100644
--- a/chrome/browser/ui/startup/session_crashed_prompt.cc
+++ b/chrome/browser/ui/startup/session_crashed_prompt.cc
@@ -11,7 +11,11 @@
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/url_constants.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/dom_storage_context.h"
#include "content/public/browser/web_contents.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -23,7 +27,8 @@
namespace {
// A delegate for the InfoBar shown when the previous session has crashed.
-class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate {
+class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate,
+ public content::NotificationObserver {
public:
SessionCrashedInfoBarDelegate(Profile* profile,
InfoBarTabHelper* infobar_helper);
@@ -38,8 +43,15 @@ class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate {
virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
virtual bool Accept() OVERRIDE;
+ // content::NotificationObserver implementation.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
// The Profile that we restore sessions from.
Profile* profile_;
+ content::NotificationRegistrar registrar_;
+ bool accepted_;
DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate);
};
@@ -48,7 +60,10 @@ SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate(
Profile* profile,
InfoBarTabHelper* infobar_helper)
: ConfirmInfoBarDelegate(infobar_helper),
- profile_(profile) {
+ profile_(profile),
+ accepted_(false) {
+ registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
+ content::NotificationService::AllSources());
}
SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() {
@@ -85,9 +100,30 @@ bool SessionCrashedInfoBarDelegate::Accept() {
}
SessionRestore::RestoreSession(
profile_, browser, behavior, std::vector<GURL>());
+ accepted_ = true;
return true;
}
+void SessionCrashedInfoBarDelegate::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ switch (type) {
+ case chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED:
+ // If the info bar wasn't accepted, it was either dismissed or expired. In
+ // that case, session restore won't happen.
+ if (!accepted_) {
+ content::DOMStorageContext* dom_storage_context =
+ content::BrowserContext::GetDOMStorageContext(profile_);
+ dom_storage_context->StartScavengingUnusedSessionStorage();
+ }
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+}
+
} // namespace
@@ -115,4 +151,3 @@ void ShowSessionCrashedPrompt(Browser* browser) {
}
} // namespace browser
-

Powered by Google App Engine
This is Rietveld 408576698