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

Unified Diff: chrome/browser/ui/browser_init.cc

Issue 8533013: SessionRestore: Store session cookies and restore them if chrome crashes or auto-restarts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 1 month 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/browser_init.cc
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index 3e485073d5543807a5c4fd4b2d72d2615126377d..bb81ae038744db0e756c2e0b8ae5d2ac6cefe0b6 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -307,9 +307,12 @@ class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate {
virtual int GetButtons() const OVERRIDE;
virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
virtual bool Accept() OVERRIDE;
+ virtual void InfoBarDismissed() OVERRIDE;
+ virtual void InfoBarClosing() OVERRIDE;
// The Profile that we restore sessions from.
Profile* profile_;
+ bool action_taken_;
DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate);
};
@@ -318,7 +321,8 @@ SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate(
Profile* profile,
InfoBarTabHelper* infobar_helper)
: ConfirmInfoBarDelegate(infobar_helper),
- profile_(profile) {
+ profile_(profile),
+ action_taken_(false) {
}
SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() {
@@ -344,6 +348,7 @@ string16 SessionCrashedInfoBarDelegate::GetButtonLabel(
}
bool SessionCrashedInfoBarDelegate::Accept() {
+ action_taken_ = true;
uint32 behavior = 0;
Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
if (browser && browser->tab_count() == 1
@@ -353,11 +358,21 @@ bool SessionCrashedInfoBarDelegate::Accept() {
// clobber it.
behavior = SessionRestore::CLOBBER_CURRENT_TAB;
}
+ profile_->RestoreSessionState();
SessionRestore::RestoreSession(
profile_, browser, behavior, std::vector<GURL>());
return true;
}
+void SessionCrashedInfoBarDelegate::InfoBarDismissed() {
+ action_taken_ = true;
+ profile_->DiscardSessionState();
+}
+
+void SessionCrashedInfoBarDelegate::InfoBarClosing() {
+ if (!action_taken_)
+ profile_->DiscardSessionState();
+}
// Utility functions ----------------------------------------------------------
@@ -916,6 +931,12 @@ bool BrowserInit::LaunchWithProfile::ProcessStartupURLs(
// infobar.
return false;
}
+ if (command_line_.HasSwitch(switches::kEnableRestoreSessionState) &&
+ command_line_.HasSwitch(switches::kRestoreLastSession)) {
+ profile_->RestoreSessionState();
+ } else {
+ profile_->DiscardSessionState();
+ }
uint32 restore_behavior = SessionRestore::SYNCHRONOUS |
SessionRestore::ALWAYS_CREATE_TABBED_BROWSER;
@@ -935,6 +956,8 @@ bool BrowserInit::LaunchWithProfile::ProcessStartupURLs(
urls_to_open);
AddInfoBarsIfNecessary(browser);
return true;
+ } else if (profile_->DidLastSessionExitCleanly()) {
+ profile_->DiscardSessionState();
}
Browser* browser = ProcessSpecifiedURLs(urls_to_open);

Powered by Google App Engine
This is Rietveld 408576698