Chromium Code Reviews| 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..56d9d70bb44e8200aedf52805c4176ca5f135bf7 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. |
| @@ -641,6 +622,9 @@ BrowserInit::BrowserInit() {} |
| BrowserInit::~BrowserInit() {} |
| +// static |
| +bool BrowserInit::was_restarted_read_ = false; |
| + |
| void BrowserInit::AddFirstRunTab(const GURL& url) { |
| first_run_tabs_.push_back(url); |
| } |
| @@ -735,18 +719,36 @@ bool BrowserInit::WasRestarted() { |
| // Stores the value of the preference kWasRestarted had when it was read. |
| static bool was_restarted = false; |
| - // True if we have already read and reset the preference kWasRestarted. |
| - static bool was_restarted_read = false; |
| - |
| - if (!was_restarted_read) { |
| + if (!was_restarted_read_) { |
| PrefService* pref_service = g_browser_process->local_state(); |
| was_restarted = pref_service->GetBoolean(prefs::kWasRestarted); |
| pref_service->SetBoolean(prefs::kWasRestarted, false); |
| - was_restarted_read = true; |
| + was_restarted_read_ = true; |
| } |
| 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,16 +1688,22 @@ 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)) |
| + if (!browser_init->LaunchBrowser((*it == last_used_profile) ? |
| + command_line : command_line_without_urls, *it, cur_dir, |
|
Peter Kasting
2012/01/18 17:30:03
Nit: Indent 4, not 8
marja
2012/01/18 18:01:12
Done.
|
| + is_process_startup, is_first_run, return_code)) |
| + return false; |
| + // We've launched at least one browser. |
| + is_process_startup = BrowserInit::IS_NOT_PROCESS_STARTUP; |
| + } |
| + // If |last_used_profile| is the default profile, it won't be included in |
| + // |last_opened_profiles|. Make sure it's launched. |
|
Peter Kasting
2012/01/18 17:30:03
Is launching this last correct, or do we need to l
marja
2012/01/18 18:01:12
Clarified this: .empty() instead of find(), and in
|
| + if (std::find(last_opened_profiles.begin(), last_opened_profiles.end(), |
| + last_used_profile) == last_opened_profiles.end()) { |
| + if (!browser_init->LaunchBrowser(command_line, last_used_profile, cur_dir, |
| + is_process_startup, is_first_run, return_code)) |
| return false; |
| } |
| } |