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

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

Issue 9232007: Fix: after updating, restore tabs from all profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test fixes + better tests. Created 8 years, 11 months 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
« no previous file with comments | « chrome/browser/ui/browser_init.h ('k') | chrome/browser/ui/browser_init_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser_init.cc
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index d59e0bf1f5c25108aeb338bcba5f720991933c83..96d90342715d2c85ed681db0271d67c9f7a5a34d 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -45,7 +45,6 @@
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.h"
#include "chrome/browser/printing/print_dialog_cloud.h"
@@ -465,24 +464,6 @@ bool SessionCrashedInfoBarDelegate::Accept() {
// Utility functions ----------------------------------------------------------
-SessionStartupPref GetSessionStartupPref(const CommandLine& command_line,
- Profile* profile) {
- SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile);
- if (command_line.HasSwitch(switches::kRestoreLastSession) ||
- BrowserInit::WasRestarted()) {
- pref.type = SessionStartupPref::LAST;
- }
- if (pref.type == SessionStartupPref::LAST &&
- IncognitoModePrefs::ShouldLaunchIncognito(command_line,
- profile->GetPrefs())) {
- // 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;
-}
-
enum LaunchMode {
LM_TO_BE_DECIDED = 0, // Possibly direct launch or via a shortcut.
LM_AS_WEBAPP, // Launched as a installed web application.
@@ -747,6 +728,27 @@ bool BrowserInit::WasRestarted() {
return was_restarted;
}
+// static
+SessionStartupPref BrowserInit::GetSessionStartupPref(
+ const CommandLine& command_line,
+ Profile* profile) {
+ SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile);
+ if (command_line.HasSwitch(switches::kRestoreLastSession) ||
+ BrowserInit::WasRestarted()) {
+ pref.type = SessionStartupPref::LAST;
+ }
+ if (pref.type == SessionStartupPref::LAST &&
+ IncognitoModePrefs::ShouldLaunchIncognito(command_line,
+ profile->GetPrefs())) {
+ // 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;
+}
+
+
// BrowserInit::LaunchWithProfile::Tab ----------------------------------------
BrowserInit::LaunchWithProfile::Tab::Tab() : is_app(false), is_pinned(true) {}
@@ -1686,17 +1688,20 @@ bool BrowserInit::ProcessCmdLineImpl(
command_line_without_urls.AppendSwitchNative(switch_it->first,
switch_it->second);
}
- if (!browser_init->LaunchBrowser(command_line, last_used_profile, cur_dir,
- is_process_startup, is_first_run, return_code))
- return false;
- is_process_startup = BrowserInit::IS_NOT_PROCESS_STARTUP;
-
+ // Launch the profiles in the order they became active.
for (Profiles::const_iterator it = last_opened_profiles.begin();
it != last_opened_profiles.end(); ++it) {
- if (*it != last_used_profile &&
- !browser_init->LaunchBrowser(command_line_without_urls, *it,
- cur_dir, is_process_startup, is_first_run, return_code))
- return false;
+ if (*it == last_used_profile) {
Peter Kasting 2012/01/16 20:13:05 Nit: Shorter and (IMO) clearer: if (!browse
marja 2012/01/18 17:08:17 Done.
+ if (!browser_init->LaunchBrowser(command_line, *it, cur_dir,
+ is_process_startup, is_first_run, return_code))
+ return false;
+ } else {
+ if (!browser_init->LaunchBrowser(command_line_without_urls, *it,
+ cur_dir, is_process_startup, is_first_run, return_code))
+ return false;
+ }
+ // We've started at least one browser.
+ is_process_startup = BrowserInit::IS_NOT_PROCESS_STARTUP;
}
}
return true;
« no previous file with comments | « chrome/browser/ui/browser_init.h ('k') | chrome/browser/ui/browser_init_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698