Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/startup/startup_browser_creator.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 6 | 6 |
| 7 #include <algorithm> // For max(). | 7 #include <algorithm> // For max(). |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 pref_service->SetBoolean(prefs::kWasRestarted, false); | 223 pref_service->SetBoolean(prefs::kWasRestarted, false); |
| 224 was_restarted_read_ = true; | 224 was_restarted_read_ = true; |
| 225 } | 225 } |
| 226 return was_restarted; | 226 return was_restarted; |
| 227 } | 227 } |
| 228 | 228 |
| 229 // static | 229 // static |
| 230 SessionStartupPref StartupBrowserCreator::GetSessionStartupPref( | 230 SessionStartupPref StartupBrowserCreator::GetSessionStartupPref( |
| 231 const CommandLine& command_line, | 231 const CommandLine& command_line, |
| 232 Profile* profile) { | 232 Profile* profile) { |
| 233 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile); | 233 DCHECK(profile); |
| 234 PrefService *prefs = profile->GetPrefs(); | |
| 235 SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs); | |
| 234 | 236 |
| 235 // Session restore should be avoided on the first run. | 237 // The pref has an OS-dependent default value. For the first run only, this |
| 236 if (first_run::IsChromeFirstRun()) | 238 // default is overridden with SessionStartupPref::DEFAULT so that first run |
| 239 // behavior (sync promo, welcome page) is consistently invoked. | |
| 240 // This applies only if the pref is still at its default and has not been | |
| 241 // set by the user, managed prefs or policy. | |
| 242 if (first_run::IsChromeFirstRun() && SessionStartupPref::TypeIsDefault(prefs)) | |
| 237 pref.type = SessionStartupPref::DEFAULT; | 243 pref.type = SessionStartupPref::DEFAULT; |
| 238 | 244 |
| 239 if (command_line.HasSwitch(switches::kRestoreLastSession) || | 245 if (command_line.HasSwitch(switches::kRestoreLastSession) || |
| 240 StartupBrowserCreator::WasRestarted()) { | 246 StartupBrowserCreator::WasRestarted()) { |
| 241 pref.type = SessionStartupPref::LAST; | 247 pref.type = SessionStartupPref::LAST; |
| 242 } | 248 } |
| 243 if (pref.type == SessionStartupPref::LAST && | 249 if (pref.type == SessionStartupPref::LAST && |
| 244 IncognitoModePrefs::ShouldLaunchIncognito(command_line, | 250 IncognitoModePrefs::ShouldLaunchIncognito(command_line, |
| 245 profile->GetPrefs())) { | 251 profile->GetPrefs())) { |
|
Joao da Silva
2012/05/23 12:49:46
Nit: use |prefs| here too. This can probably be co
bartfab (slow)
2012/05/23 12:55:10
Done.
| |
| 246 // We don't store session information when incognito. If the user has | 252 // We don't store session information when incognito. If the user has |
| 247 // chosen to restore last session and launched incognito, fallback to | 253 // chosen to restore last session and launched incognito, fallback to |
| 248 // default launch behavior. | 254 // default launch behavior. |
| 249 pref.type = SessionStartupPref::DEFAULT; | 255 pref.type = SessionStartupPref::DEFAULT; |
| 250 } | 256 } |
| 251 return pref; | 257 return pref; |
| 252 } | 258 } |
| 253 | 259 |
| 254 std::vector<GURL> StartupBrowserCreator::GetURLsFromCommandLine( | 260 std::vector<GURL> StartupBrowserCreator::GetURLsFromCommandLine( |
| 255 const CommandLine& command_line, | 261 const CommandLine& command_line, |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 return; | 575 return; |
| 570 } | 576 } |
| 571 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); | 577 ProcessCmdLineImpl(cmd_line, cur_dir, false, profile, Profiles(), NULL, NULL); |
| 572 } | 578 } |
| 573 | 579 |
| 574 bool HasPendingUncleanExit(Profile* profile) { | 580 bool HasPendingUncleanExit(Profile* profile) { |
| 575 return !profile->DidLastSessionExitCleanly() && | 581 return !profile->DidLastSessionExitCleanly() && |
| 576 !profile_launch_observer.Get().HasBeenLaunched(profile); | 582 !profile_launch_observer.Get().HasBeenLaunched(profile); |
| 577 } | 583 } |
| 578 | 584 |
| OLD | NEW |