summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_init.cc12
-rw-r--r--chrome/browser/sessions/session_restore.cc7
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,