diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-11 03:36:50 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-11 03:36:50 +0000 |
commit | 4831051e6bce5f55c3954bea208c0ce118ea25ff (patch) | |
tree | 2e322210d62b1078b6c5c6279ddd597c00640312 | |
parent | bbe50755c1a8d0cdea4b3b0699b70806dfae2e23 (diff) | |
download | chromium_src-4831051e6bce5f55c3954bea208c0ce118ea25ff.zip chromium_src-4831051e6bce5f55c3954bea208c0ce118ea25ff.tar.gz chromium_src-4831051e6bce5f55c3954bea208c0ce118ea25ff.tar.bz2 |
Fixes two session restore bugs:
. If the user launches incognito we don't attempt to restore last
session and instead just do default launch behavior (new tab page).
. Don't show the session restore info bar when launched incognito. I'm
assuming that if the user launched in incognito they were previously
running incognito so that there is nothing to restore.
BUG=4381 5119
TEST=turn on session restore and launch with --incognito, make sure
the incognito window comes up.
Review URL: http://codereview.chromium.org/13368
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6776 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser_init.cc | 12 | ||||
-rw-r--r-- | chrome/browser/sessions/session_restore.cc | 7 |
2 files changed, 17 insertions, 2 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index 6084a53..0d6d128 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -115,6 +115,13 @@ SessionStartupPref GetSessionStartupPref(Profile* profile, SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); if (command_line.HasSwitch(switches::kRestoreLastSession)) pref.type = SessionStartupPref::LAST; + if (command_line.HasSwitch(switches::kIncognito) && + pref.type == SessionStartupPref::LAST) { + // We don't store session information when incognito. If the user has + // chosen to restore last session and launched incognito, fallback to + // default launch behavior. + pref.type = SessionStartupPref::DEFAULT; + } return pref; } @@ -546,7 +553,10 @@ Browser* BrowserInit::LaunchWithProfile::OpenURLsInBrowser( void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary( TabContents* tab) { - if (!profile_->DidLastSessionExitCleanly()) { + // Assume that if the user is launching incognito they were previously + // running incognito so that we have nothing to restore from. + if (!profile_->DidLastSessionExitCleanly() && + !profile_->IsOffTheRecord()) { // 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. diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index 74038ce..e9e0b1d1 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc @@ -417,8 +417,13 @@ static void Restore(Profile* profile, bool always_create_tabbed_browser, const std::vector<GURL>& urls_to_open) { DCHECK(profile); - if (!profile->GetSessionService()) + // Always restore from the original profile (incognito profiles have no + // session service). + profile = profile->GetOriginalProfile(); + if (!profile->GetSessionService()) { + NOTREACHED(); return; + } // SessionRestoreImpl takes care of deleting itself when done. SessionRestoreImpl* restorer = new SessionRestoreImpl(profile, browser, synchronous, |