| 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..61ba5d6aec9055da9fa260c4a00d7fcbef2032bc 100644
|
| --- a/chrome/browser/ui/browser_init.cc
|
| +++ b/chrome/browser/ui/browser_init.cc
|
| @@ -296,7 +296,8 @@ void CheckDefaultBrowserTask::Run() {
|
| class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate {
|
| public:
|
| SessionCrashedInfoBarDelegate(Profile* profile,
|
| - InfoBarTabHelper* infobar_helper);
|
| + InfoBarTabHelper* infobar_helper,
|
| + bool session_restore_enabled);
|
|
|
| private:
|
| virtual ~SessionCrashedInfoBarDelegate();
|
| @@ -307,18 +308,25 @@ 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 session_restore_enabled_;
|
| + bool action_taken_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(SessionCrashedInfoBarDelegate);
|
| };
|
|
|
| SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate(
|
| Profile* profile,
|
| - InfoBarTabHelper* infobar_helper)
|
| + InfoBarTabHelper* infobar_helper,
|
| + bool session_restore_enabled)
|
| : ConfirmInfoBarDelegate(infobar_helper),
|
| - profile_(profile) {
|
| + profile_(profile),
|
| + session_restore_enabled_(session_restore_enabled),
|
| + action_taken_(false) {
|
| }
|
|
|
| SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() {
|
| @@ -344,6 +352,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 +362,23 @@ bool SessionCrashedInfoBarDelegate::Accept() {
|
| // clobber it.
|
| behavior = SessionRestore::CLOBBER_CURRENT_TAB;
|
| }
|
| + if (session_restore_enabled_)
|
| + profile_->RestoreSessionState();
|
| SessionRestore::RestoreSession(
|
| profile_, browser, behavior, std::vector<GURL>());
|
| return true;
|
| }
|
|
|
| +void SessionCrashedInfoBarDelegate::InfoBarDismissed() {
|
| + action_taken_ = true;
|
| + if (session_restore_enabled_)
|
| + profile_->DiscardSessionState();
|
| +}
|
| +
|
| +void SessionCrashedInfoBarDelegate::InfoBarClosing() {
|
| + if (!action_taken_ && session_restore_enabled_)
|
| + profile_->DiscardSessionState();
|
| +}
|
|
|
| // Utility functions ----------------------------------------------------------
|
|
|
| @@ -916,6 +937,10 @@ bool BrowserInit::LaunchWithProfile::ProcessStartupURLs(
|
| // infobar.
|
| return false;
|
| }
|
| + if (command_line_.HasSwitch(switches::kEnableRestoreSessionState) &&
|
| + command_line_.HasSwitch(switches::kRestoreLastSession)) {
|
| + profile_->RestoreSessionState();
|
| + }
|
|
|
| uint32 restore_behavior = SessionRestore::SYNCHRONOUS |
|
| SessionRestore::ALWAYS_CREATE_TABBED_BROWSER;
|
| @@ -1093,8 +1118,11 @@ void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary(
|
| // The last session didn't exit cleanly. Show an infobar to the user
|
| // so that they can restore if they want. The delegate deletes itself when
|
| // it is closed.
|
| + bool session_restore_enabled =
|
| + command_line_.HasSwitch(switches::kEnableRestoreSessionState);
|
| tab->infobar_tab_helper()->AddInfoBar(
|
| - new SessionCrashedInfoBarDelegate(profile_, tab->infobar_tab_helper()));
|
| + new SessionCrashedInfoBarDelegate(profile_, tab->infobar_tab_helper(),
|
| + session_restore_enabled));
|
| }
|
| }
|
|
|
|
|