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

Side by Side Diff: chrome/browser/browser_init.cc

Issue 13368: Fixes two session restore bugs:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/sessions/session_restore.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/browser_init.h" 5 #include "chrome/browser/browser_init.h"
6 6
7 #include <shellapi.h> 7 #include <shellapi.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 *result = IsWindowVisible(window) != 0; 108 *result = IsWindowVisible(window) != 0;
109 // Stops enumeration if a visible window has been found. 109 // Stops enumeration if a visible window has been found.
110 return !*result; 110 return !*result;
111 } 111 }
112 112
113 SessionStartupPref GetSessionStartupPref(Profile* profile, 113 SessionStartupPref GetSessionStartupPref(Profile* profile,
114 const CommandLine& command_line) { 114 const CommandLine& command_line) {
115 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); 115 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile);
116 if (command_line.HasSwitch(switches::kRestoreLastSession)) 116 if (command_line.HasSwitch(switches::kRestoreLastSession))
117 pref.type = SessionStartupPref::LAST; 117 pref.type = SessionStartupPref::LAST;
118 if (command_line.HasSwitch(switches::kIncognito) &&
119 pref.type == SessionStartupPref::LAST) {
120 // We don't store session information when incognito. If the user has
121 // chosen to restore last session and launched incognito, fallback to
122 // default launch behavior.
123 pref.type = SessionStartupPref::DEFAULT;
124 }
118 return pref; 125 return pref;
119 } 126 }
120 127
121 } // namespace 128 } // namespace
122 129
123 // MessageWindow -------------------------------------------------------------- 130 // MessageWindow --------------------------------------------------------------
124 131
125 static bool in_startup = false; 132 static bool in_startup = false;
126 133
127 // static 134 // static
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 urls[i], GURL(), PageTransition::START_PAGE, (i == 0), NULL); 546 urls[i], GURL(), PageTransition::START_PAGE, (i == 0), NULL);
540 if (i == 0 && process_startup) 547 if (i == 0 && process_startup)
541 AddCrashedInfoBarIfNecessary(tab); 548 AddCrashedInfoBarIfNecessary(tab);
542 } 549 }
543 browser->window()->Show(); 550 browser->window()->Show();
544 return browser; 551 return browser;
545 } 552 }
546 553
547 void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary( 554 void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary(
548 TabContents* tab) { 555 TabContents* tab) {
549 if (!profile_->DidLastSessionExitCleanly()) { 556 // Assume that if the user is launching incognito they were previously
557 // running incognito so that we have nothing to restore from.
558 if (!profile_->DidLastSessionExitCleanly() &&
559 !profile_->IsOffTheRecord()) {
550 // The last session didn't exit cleanly. Show an infobar to the user 560 // The last session didn't exit cleanly. Show an infobar to the user
551 // so that they can restore if they want. The delegate deletes itself when 561 // so that they can restore if they want. The delegate deletes itself when
552 // it is closed. 562 // it is closed.
553 tab->AddInfoBar(new SessionCrashedInfoBarDelegate(tab)); 563 tab->AddInfoBar(new SessionCrashedInfoBarDelegate(tab));
554 } 564 }
555 } 565 }
556 566
557 std::vector<GURL> BrowserInit::LaunchWithProfile::GetURLsFromCommandLine( 567 std::vector<GURL> BrowserInit::LaunchWithProfile::GetURLsFromCommandLine(
558 const CommandLine& command_line, Profile* profile) { 568 const CommandLine& command_line, Profile* profile) {
559 std::vector<GURL> urls; 569 std::vector<GURL> urls;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 if (!launched) { 722 if (!launched) {
713 LOG(ERROR) << "launch error"; 723 LOG(ERROR) << "launch error";
714 if (return_code != NULL) { 724 if (return_code != NULL) {
715 *return_code = ResultCodes::INVALID_CMDLINE_URL; 725 *return_code = ResultCodes::INVALID_CMDLINE_URL;
716 } 726 }
717 return false; 727 return false;
718 } 728 }
719 729
720 return true; 730 return true;
721 } 731 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sessions/session_restore.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698